ChangeDisplaySettingsEx

ChangeDisplaySettingsEx

Post by jlmu » Thu, 29 May 2003 17:43:49



Hi,

I try to change the screen resolution of a secondary Graphics Adapter with
ChangeDisplaySettingsEx.
It works the first time, but even though all parameters are fine, the second
time I want to change the resoltuion nothing happens.
If I change the primary graphics adapter with ChangeDisplaySettingsEx, it
changes resolution all the time, strangely.
Can anybody help, please ?

Thank you,

Jonas

 
 
 

1. Help with API ChangeDisplaySettingsEx -- yep I'm lost

I have successfully changed the display resolution using
ChangeDisplaySettings api call but I need to Use the Ex call for Multiple
Monitors....

When I call it like this it works
    Call ChangeDisplaySettingsEx(0&, DevM, ByVal 0&, CDS_TEST, ByVal 0&)

but only on the default monitor......
taking a look at MSDN i find
The ChangeDisplaySettingsEx function changes the settings of the specified
display device to the specified graphics mode.

LONG ChangeDisplaySettingsEx(
  LPCTSTR lpszDeviceName,  // name of display device
  LPDEVMODE lpDevMode,     // graphics mode
  HWND hwnd,               // not used; must be NULL
  DWORD dwflags,            // graphics mode options
  LPVOID lParam            // video parameters (or NULL)
);

So I try using EnumDisplayDevices to retrieve the Second adapters name
    Dim DD As DISPLAY_DEVICE, DevM As DEVMODE    DD.cb = Len(DD)
EnumDisplayDevices(ByVal 0&, 1, DD, ByVal 0&)
which gives me \\.\DISPLAY2
as the devicename
but calling ChangeDisplaySettingsEx with the  Devicename set does nothing
in either case

 Dim dx As String    dx = DD.DeviceString
Call ChangeDisplaySettingsEx(dx,DevM, ByVal 0&, CDS_TEST, ByVal 0&)
'This no workie
Call ChangeDisplaySettingsEx("\\.\DISPLAY2", DevM, ByVal 0&, CDS_TEST, ByVal
0&)
'This Either
Can someone help me out with an example or good suggestion...THanks for
reading this KD

ps I left out the DevM type as its quite long...will post if necessary
This is all based on sample code from ALLAPI.net
http://www.allapi.net/api/api030.php

2. bmp reading problem