Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 17 Apr 2008 05:04:39 -0700 (PDT),    group: microsoft.public.win32.programmer.gdi        back       


Switching primary monitor   
I have been trying to use ChangeDisplaySettingsEx() to switch the
primary display device as per the post:

http://groups.google.com/group/microsoft.public.win32.programmer.gdi/msg/f298871db17f2c97

However, it doesn't not work.  I'm running it on a Dell Inspiron
laptop with an ATI graphics chip, and running XP, and hoping it will
switch between the LCD screen and the external monitor.  The first
call to ChangeDisplaySettingEx fails with DISP_CHANGE_BADMODE, 'The
graphics mode is not supported'.

Any ideas what might be causing it to fail?  The essential part of the
code is:

	EnumDisplaySettings(devName2, ENUM_REGISTRY_SETTINGS, &dm2);
	dm2.dmFields = DM_POSITION;
	dm2.dmPosition.x = 0;
	dm2.dmPosition.y = 0;
	retCode = ChangeDisplaySettingsEx(devName2, &dm2, NULL,
CDS_SET_PRIMARY |
	CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
	ShowDisplayError("Error in dev2 change", retCode);

	EnumDisplaySettings(devName1, ENUM_REGISTRY_SETTINGS, &dm1);
	dm1.dmFields = DM_POSITION;
	dm1.dmPosition.x = dm2.dmPelsWidth;
	dm1.dmPosition.y = 0;
	retCode = ChangeDisplaySettingsEx(devName1, &dm1, NULL,
CDS_UPDATEREGISTRY |
	CDS_NORESET, NULL);
	ShowDisplayError("Error in dev1 change", retCode);

	retCode = ChangeDisplaySettings(NULL, 0);
	ShowDisplayError("Error in settings change", retCode);

Thanks.

Ian.
date: Thu, 17 Apr 2008 05:04:39 -0700 (PDT)   author:   Ian

Re: Switching primary monitor   
>I have been trying to use ChangeDisplaySettingsEx() to switch the
>primary display device as per the post:
>
>http://groups.google.com/group/microsoft.public.win32.programmer.gdi/msg/f298871db17f2c97
>
>However, it doesn't not work.  I'm running it on a Dell Inspiron
>laptop with an ATI graphics chip, and running XP, and hoping it will
>switch between the LCD screen and the external monitor. 

Ian,

Does the standard Windows Control Panel display applet show this as
having 2 displays?

Have a look at VidRes (www.jddesign.co.uk) and see if it encounters
the same problem as your code does. It uses the same APIs and I can't
spot anything immediately wrong with the code you showed.

Dave
date: Thu, 17 Apr 2008 22:23:32 +0100   author:   David Lowndes lid

Re: Switching primary monitor   
> Does the standard Windows Control Panel display applet show this as
> having 2 displays?
>
> Have a look at VidRes (www.jddesign.co.uk) and see if it encounters
> the same problem as your code does. It uses the same APIs and I can't
> spot anything immediately wrong with the code you showed.

Dave,

Yes, Control Panel shows two displays.

Thanks for the tip on VidRes.  The GUI shows both displays, but on
selecting the second one, the options to 'Make Primary' and 'Make
Sole' grey-out.  The VidRes readme suggests this is deliberate because
the second monitor is removable.  Running the command line switch for
the same confirms this.  I'll see if I can find out from them why this
restriction has been placed and whether there's a way around it -
otherwise I can't see what use the function is!

Ian.
date: Fri, 18 Apr 2008 03:09:27 -0700 (PDT)   author:   Ian

Re: Switching primary monitor   
> Does the standard Windows Control Panel display applet show this as
> having 2 displays?
>
> Have a look at VidRes (www.jddesign.co.uk) and see if it encounters
> the same problem as your code does. It uses the same APIs and I can't
> spot anything immediately wrong with the code you showed.

Dave,

Yes, there are two displays in the Control Panel applet.

Thanks for the tip on VidRes.  The GUI gives the two displays as
options, but does not allow you to 'Make Primary' or 'Make Sole'  the
second display (the buttons grey out).  The VidRes readme says this
was added intentionally a few versions ago so that you can't make
'removable' monitors the primary display.  I suppose this is to
prevent accidental switching, but it seems very restrictive.  The
command line interface has the same restriction.  I will see if I can
find out from them whether there's a workaround, and post back.

Thanks again Dave for the feedback.

Ian.
date: Fri, 18 Apr 2008 03:18:30 -0700 (PDT)   author:   Ian

Re: Switching primary monitor   
>Yes, there are two displays in the Control Panel applet.
>
>Thanks for the tip on VidRes.  The GUI gives the two displays as
>options, but does not allow you to 'Make Primary' or 'Make Sole'  the
>second display (the buttons grey out).  The VidRes readme says this
>was added intentionally a few versions ago so that you can't make
>'removable' monitors the primary display.

Hi Ian,

I'll answer here for the benefit of anyone else reading (VidRes is one
of my projects).

I presume you're referring to this comment:

"Prevent removable displays (often the external connection on notebook
computers) from being the primary or sole monitor.", ... and does the
command line usage give you the error "The device is removable. It
can't be made the primary"?

I'm afraid the details of the particular circumstances leading to
those changes have long since left me, but I think someone contacted
me with a problem, and I vaguely recall checking it on my daughter's
laptop and getting the same results - it didn't work.

Subsequently I found this documentation of DISPLAY_DEVICE_REMOVABLE
for the DISPLAY_DEVICE structure, which says:

"The device is removable; it cannot be the primary display"

Dave
date: Fri, 18 Apr 2008 14:34:07 +0100   author:   David Lowndes lid

Re: Switching primary monitor   
> I'm afraid the details of the particular circumstances leading to
> those changes have long since left me, but I think someone contacted
> me with a problem, and I vaguely recall checking it on my daughter's
> laptop and getting the same results - it didn't work.
>
> Subsequently I found this documentation of DISPLAY_DEVICE_REMOVABLE
> for the DISPLAY_DEVICE structure, which says:
>
> "The device is removable; it cannot be the primary display"

Dave,

My laptop has the same flag set for the second device, so that would
explain the problem.

Thanks for your help.

Ian.
date: Tue, 22 Apr 2008 01:48:57 -0700 (PDT)   author:   Ian

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us