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
[SOLVED] canvas
by
krolikbest
[
Today
at 08:09:53 pm]
Exception Class 'External...
by
Handoko
[
Today
at 08:08:32 pm]
Post-Pascal
by
MarkMLl
[
Today
at 08:04:18 pm]
Running Pyrhon Script
by
lucamar
[
Today
at 07:40:13 pm]
Free Pascal and Lazarus N...
by
ASBzone
[
Today
at 07:37:52 pm]
GitHub Action to setup La...
by
El Salvador
[
Today
at 07:33:07 pm]
Off Topic - Promises - Re...
by
ASBzone
[
Today
at 07:26:26 pm]
Would like some feedback ...
by
lucamar
[
Today
at 07:22:19 pm]
Actioning an IPRo hot lin...
by
wp
[
Today
at 07:02:56 pm]
Contemporary Pascal Discu...
by
ASBzone
[
Today
at 06:57:42 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: MultiMon and Unicode (Read 514 times)
Mr.Madguy
Hero Member
Posts: 649
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: 4342
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: 4342
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: 649
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: 4342
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