Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
MultiMon and Unicode
Free Pascal
Website
Downloads
Wiki
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Bugtracker
IRC channel
Latest SVN
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
File handling, records [p...
by
manahu
[
Today
at 02:16:48 am]
if ImageList
by
jamie
[
Today
at 01:42:12 am]
converting C++ over laz, ...
by
jamie
[
Today
at 01:13:48 am]
Pictures in Forms
by
winni
[
Today
at 12:24:04 am]
[SOLVED] Indicator arrow ...
by
pcurtis
[February 27, 2021, 11:54:02 pm]
MOVED: TChart start posit...
by
trev
[February 27, 2021, 11:05:08 pm]
Icon Application
by
Fred vS
[February 27, 2021, 08:53:45 pm]
FPC on Rasp Pi, non Lazar...
by
AlanTheBeast
[February 27, 2021, 08:34:13 pm]
problem executting tproce...
by
Martin_fr
[February 27, 2021, 08:14:04 pm]
Fpcupdeluxe
by
DonAlfredo
[February 27, 2021, 08:11:02 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: MultiMon and Unicode (Read 465 times)
Mr.Madguy
Hero Member
Posts: 627
MultiMon and Unicode
«
on:
September 06, 2020, 01:39:25 pm »
I need EnumDisplayDevicesW from MultiMon. It requires UNICODE definition, that also requires FPC_OS_UNICODE. How can I define it? I tried to define it in project options, but it didn't work. OS is Win64.
Logged
DynamicData 3.0 is released!
4.0 version is in development! Another complete overhaul! Things are made more simple and, of course, faster!
Aiming at Lazarus support, when closures will be implemented.
jamie
Hero Member
Posts: 4177
Re: MultiMon and Unicode
«
Reply #1 on:
September 06, 2020, 04:42:01 pm »
Code: Pascal
[Select]
[+]
[-]
unit
Unit1
;
{$mode objfpc}{$H+}
interface
uses
Windows
,
Classes
,
SysUtils
,
Forms
,
Controls
,
Graphics
,
Dialogs
,
StdCtrls
;
type
{ TForm1 }
DISPLAY_DEVICEW
=
record
Cb
:
DWORD
;
DeviceName
:
Array
[
0
..
31
]
of
WCHAR
;
// DeviceName[32];
DeviceString
:
array
[
0
..
127
]
of
WCHAR
;
// DeviceString[128];
StateFlags
:
DWORD
;
DeviceID
:
Array
[
0
..
127
]
of
WCHAR
;
//DeviceID[128];
DeviceKey
:
Array
[
0
..
127
]
of
WCHAR
;
// DeviceKey[128];
End
;
PDISPLAY_DEVICEW
=
DISPLAY_DEVICEW
;
TForm1
=
class
(
TForm
)
Button1
:
TButton
;
procedure
Button1Click
(
Sender
:
TObject
)
;
private
public
end
;
Function
EnumDisplayDevicesW
(
lpDevice
:
LPWSTR
;
iDevNum
:
DWORD
;
lpDisplayDevice
:
Pointer
;
//DISPLAY_DEVICEW;
dwFlags
:
DWORD
)
:
WinBool
;
StdCall
External
'user32.dll'
name
'EnumDisplayDevicesW'
;
Const
EDD_GET_DEVICE_INTERFACE_NAME
=
1
;
//(0x00000001
var
Form1
:
TForm1
;
implementation
{$R *.lfm}
{ TForm1 }
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
Var
V
:
Display_DEVICEW
;
begin
Fillchar
(
V
,
sizeof
(
V
)
,
0
)
;
V
.
cb
:
=
Sizeof
(
V
)
;
{Change parameter nnumbre 2 as the index to the monitor to look at}
{ When there are no more monitors it will return false}
If
EnumDisplayDevicesW
(
Pointer
(
0
)
,
0
,
@
V
,
EDD_GET_DEVICE_INTERFACE_NAME
)
then
Begin
caption
:
=
V
.
DeviceName
;
End
;
end
;
end
.
It seems to work, I couldn't find the W version of the record so I changed this one, it seems to work just fine..
Logged
The only true wisdom is knowing you know nothing
jamie
Hero Member
Posts: 4177
Re: MultiMon and Unicode
«
Reply #2 on:
September 06, 2020, 05:30:01 pm »
I have attached a Project that shows the list with their defines. hope this helps others too..
Logged
The only true wisdom is knowing you know nothing
Mr.Madguy
Hero Member
Posts: 627
Re: MultiMon and Unicode
«
Reply #3 on:
September 06, 2020, 05:41:01 pm »
It's in MultiMon.
Code: Pascal
[Select]
[+]
[-]
{$ifdef FPC_OS_UNICODE}
{$define UNICODE}
{$endif}
...
{$ifdef UNICODE}
DISPLAY_DEVICE
=
DISPLAY_DEVICEW
;
PDISPLAY_DEVICE
=
PDISPLAY_DEVICEW
;
LPDISPLAY_DEVICE
=
LPDISPLAY_DEVICEW
;
TDisplayDevice
=
TDisplayDeviceW
;
PDisplayDevice
=
PDisplayDeviceW
;
{$else}
DISPLAY_DEVICE
=
DISPLAY_DEVICEA
;
PDISPLAY_DEVICE
=
PDISPLAY_DEVICEA
;
LPDISPLAY_DEVICE
=
LPDISPLAY_DEVICEA
;
TDisplayDevice
=
TDisplayDeviceA
;
PDisplayDevice
=
PDisplayDeviceA
;
{$endif}
// UNICODE
...
{$ifdef UNICODE}
Pointer
(
g_pfnEnumDisplayDevices
)
:
=
GetProcAddress
(
hUser32
,
'EnumDisplayDevicesW'
)
;
if
IsPlatformNT
then
Pointer
(
g_pfnGetMonitorInfo
)
:
=
GetProcAddress
(
hUser32
,
'GetMonitorInfoW'
)
else
Pointer
(
g_pfnGetMonitorInfo
)
:
=
GetProcAddress
(
hUser32
,
'GetMonitorInfoA'
)
;
{$else}
Pointer
(
g_pfnGetMonitorInfo
)
:
=
GetProcAddress
(
hUser32
,
'GetMonitorInfoA'
)
;
Pointer
(
g_pfnEnumDisplayDevices
)
:
=
GetProcAddress
(
hUser32
,
'EnumDisplayDevicesA'
)
;
{$endif}
UNICODE isn't defined for me. And defining it in project options doesn't help. I've implemented my code as is for now, as I hope, that crucial parts of TDisplayDevice can be english only.
Logged
DynamicData 3.0 is released!
4.0 version is in development! Another complete overhaul! Things are made more simple and, of course, faster!
Aiming at Lazarus support, when closures will be implemented.
jamie
Hero Member
Posts: 4177
Re: MultiMon and Unicode
«
Reply #4 on:
September 06, 2020, 05:47:05 pm »
please look at the attached project.
Unicode as in strings is basically WIDESTRING for windows when it comes to doing this sort of stuff..
I can't help it if the UNICODE define isn't defined...
«
Last Edit: September 06, 2020, 05:50:44 pm by jamie
»
Logged
The only true wisdom is knowing you know nothing
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
MultiMon and Unicode
TinyPortal
© 2005-2018