Re: Second monitor enumeration

new topic     » goto parent     » topic index » view thread      » older message » newer message

I am now having trouble with Windows ENUM_DEVICE_SETTINGS. I need to set up the DEVMODE structure to pass into the call, but though I have got the Windows SDK installed I can't get the size value properly (i think that's the trouble) so i have gone to an approximate value, and put that in where I think it ought to be. I've been referring to wingdi.h. It always returns False. So if any of you worthies can advise me I'd be very happy. All i need to get is the monitor width & height. Ideally whether it is on or not but that is less important.

The code below is in Eu3 style and uses Win32Lib. I'm old and worn enough that having got a perfectly satisfactory way of writing code for Windows with Judith's IDE I really don't want to start learning a relatively minor variant of it.

The code below is just a "proof of concept" style which is why I haven't freed any allocations up. And I am only interested in the second monitor after the prime screen. The monitor name is also a bit odd ... the output I get is below. The chatty name is just a generic so of no use for specifying.

So as before any help is appreciated. And if Pete Lomax sees this - you put me on the right path even if I can't get to the end, so thanks again.

Call 1:  Device name: \\.\DISPLAY1 
Call 2:  Device name: \\.\DISPLAY1\Monitor0 
EnumDisplaySettings call failed 
Call 1:  Device name: \\.\DISPLAY2 
Call 2:  Device name: \\.\DISPLAY2\Monitor0 
EnumDisplaySettings call failed 
 

with trace 
include Win32Lib.w 
 
--========================  DATA  ============================ 
 
 
constant sizeDD = 424, 
         DD_DeviceName = 4, 
         DD_DeviceString = 36, 
         DD_StateFlags = 164, 
         pDD = allocate(sizeDD), 
         EDD_GET_DEVICE_INTERFACE_NAME = 1, 
          
         user32 = open_dll("user32.dll"), 
         xEnumDisplayDevices = define_c_func(user32,"EnumDisplayDevicesA",{C_POINTER,C_ULONG,C_POINTER,C_ULONG},C_INT), 
         xEnumDisplaySettings = define_c_func(user32,"EnumDisplaySettingsA",{C_POINTER,C_ULONG,C_POINTER},C_INT) 
 
constant sizeDM = 128,	-- This is too big I think - I got 113, not a lot of goof 
	 DM_Size = 32,	-- Where size word held 
	 pDM = allocate(sizeDM) 
 
 
sequence device_name, display_name, display_string, safe 
atom pDeviceName 
 
--=====================  CODE  ======================== 
 
mem_set(pDD, 0, sizeDD) 
poke4  (pDD, sizeDD) 
 
mem_set(pDM, 0, sizeDM) 
poke4  (pDM+DM_Size, sizeDM) 
 
for iDevNum=0 to 1 do 
 
--	First call to get adapter name 
 
    if not c_func(xEnumDisplayDevices, {NULL, iDevNum, pDD, EDD_GET_DEVICE_INTERFACE_NAME}) then 
    	exit 
    end if 
 
    device_name = peek_string(pDD+DD_DeviceName) 
    puts(Screen, "Call 1:  Device name: " & device_name & "\n") 
 
--	Next call to get monitor name 
 
    pDeviceName = allocate_string(device_name) 
 
    if not c_func(xEnumDisplayDevices,{pDeviceName, 0, pDD, EDD_GET_DEVICE_INTERFACE_NAME}) then 
       	printf(1,"EnumDisplayDevices [%s] bad call\n", {safe}) 
   	exit 
    end if 
 
    device_name = peek_string(pDD+DD_DeviceName) 
    safe = device_name 
    puts(Screen, "Call 2:  Device name: " & safe & "\n") 
 
--	Call to get settings for that monitor - or not? 
--	pDD is wrong. refer to wingdi.h: 
--	I need proper values for DEVMODE including length value in [dmSize] etc 
--	I save the monitor name in a Euphoria sequence and re-allocate because somewhere 
--	I read that the string in the DisplayDevices structure gets tromped on 
 
    pDeviceName = allocate_string(safe)	-- Use Euphoria sequence .... 
 
    if not c_func(xEnumDisplaySettings,{pDeviceName, 0, pDM}) then 
	puts(Screen, "EnumDisplaySettings call failed\n") 
    else 
	puts(Screen, "EnumDisplaySettings call succeeded!\n") 
    end if 
 
end for 
 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu