Saturday, 22 May 2010

The dual displays user debacle

I was looking for a way to have each user configure separate desktop sizes. I have only got space for 1 computer at home, the desktop has 2 attached displays, used when I develop software, I sometimes turn off the secondary to save power - whereupon the mouse pointer gets lost in the black desktop. My problem however is the computer is used by 3 other persons who do not want an extended desktop, if they logon and change the desktop size, everyone unfortunately gets the new desktop setup.
Since the days of Windows NT3.51 I have not detected a way of being able to do this, I'm just missing something, since users with disabilities must be able to dynamically customize Windows for different kinds of peripherals they attach. I know what I am asking is not trivial, since the graphics card drivers need to support this somehow, it's not just an O/S problem. I was thinking of locating the desktop settings and creating symbolic links to coppies of them in each user's registry keys and folders, can this work?
Basically I have this:
I log in : and want to use 2560x1024 over 2 displays .
Wife and kids log in : want 1280x1024 on 1 display ONLY

I posted the question out after googlesearch gave no results, A response to my post on MS forums led toa utility, actually 2. XPKeepPerUserDisplaySettings and XP User Display , between them I was hence inspired to roll my own, and I have now gotten most of it working.

My requirement is to be able to.
1. Disable the secondary display in a user application (which is launched when user logs on)
2. Re-enable the secondary display when a diferent user logs on.
3. Run as a service (for necessary rights), and to monitor logon/logoff without resorting to using Registry "Run" key.

For anyone onto this concept already, I found 2 MSDN tech notes that de-mystify. I have hence gotten what I wanted working, it just needs tidying up so that it will run standalone.
Enumeration and Display Control[^] and PRB: You Must Restart the Computer After You Use the ChangeDisplaySettingsEx Function to Attach a Secondary Monitor[^] .
The second note describes the work-around for a unexpected way that the ChangeDisplaySettingsEx() function operates. Once I have a tidy commandline callable application, I will be uploading the sources.

I've still to implement item 3, it will probably involve a Windows 7 compliant Tray-Icon management application, so watch this space if you want to do same.

2 comments:

  1. Another thing I found, there appears to be a bug in the prologe code when you want to disable the display by setting it's size to 0. So the msdn sample did not work, the function was returning -2, but if you set the bpp and refresh rate to valid values viola! I accidentally had it work, but during refactoring took these 2 vital lines out and had to put them back in.
    DEVMODE DevMode;
    ...
    DevMode.dmDisplayFrequency = 60;
    DevMode.dmBitsPerPel = 32;
    result = ChangeDisplaySettingsEx(pDeviceName,
    &DevMode,
    NULL,
    CDS_NORESET|CDS_UPDATEREGISTRY,
    NULL);
    ...
    It turns out the DM_BITSPERPEL and DM_DISPLAYFREQUENCY are not wanted when disabling a display. My mistake really.

    ReplyDelete
  2. Google code repo (SVN) http://code.google.com/p/dualdisplaypowersave/

    ReplyDelete