Link to home
Start Free TrialLog in
Avatar of westy100697
westy100697

asked on

Using ChangeDisplaySettings() ??

Hi,
    Been a while since I have asked a Q so here is what I hope to be a simple one.

I have an application that I use the ChangeDisplaySettings() function in. It works perfectly in that it resizes the screen to the correct default size that I require and also to the correct Bit format.

Now the problem is that the taskbar is sitting in no mans land. On reading the help the WM_DISPLAYCHANGE is supposed to be called automatically and this should in turn refresh the registry. So why if the computer is in 640x480x16bit mode and I want the default to be 800x600x16bit that after the application successfully changes the resolution that the task bar is sitting at the same co-ordinate position as if it were still in 640x480 mode. The same applies is I am in 1024x768 and I resize to 800x600 the taskbar becomes invisible and must not be able to be seen as it is outside the screens new area. A bit strange as when the app finishes it defers back to the default setting and everything is okay.

Why won't it resize the taskbar to suit the mode I am in ??  I am using Win98 second edition and also have the same problem on Win NT.

Also it will magically appear in the right position if you hit the windows button on the keyboard. Obviously it must be a refresh problem but what function should I use since ChangeDisplaySettings should do it automatically ?
Avatar of KobiK
KobiK

Strange, i also read in the documentation that WM_DISPLAYCHANGE is sent...
Mybe a WM_WINDOWPOSCHANGING
with flags SWP_NOZORDER | SWP_NOACTIVATE also needed to be set to the Shell_TrayWnd window...

I used Spy++ to see what realy happens when changinh disply settings in window...

HTH
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can use this to send a message if the registry was updated.

  SendMessage(HWND_BROADCAST,
              WM_WININICHANGE,
              0,
              LongInt(PChar('RegistrySection')));

Bye, TDS.
Avatar of westy100697

ASKER

Brillian everyone..... I will mull over and test what was included here and get back to you soon.

Thanks for the quick responses.

WESTY :)
Avatar of Wim ten Brink
Reading...
listening...
Okay,
         I shall award points to Madshi as I tested all the dwflags and the only one I could get to take was CDS_UPDATEREGISTRY. It didn't seem to reset as easily back to the default settings as doing this

ChangeDisplaySettings(PDevMode(nil)^,0);

I now get all the settings on App start and just use

ChangeDisplaySettings(NewDevMode,CDS_UPDATEREGISTRY);


and then on exit

ChangeDisplaySettings(OldDevMode,CDS_UPDATEREGISTRY);

and it all works perfectly now.

Thanks all,

WESTY :)

Thanx for the points, westy...  :-)  Yep, I had problems with "PDevMode(nil)^", too. On most of our customer's PCs it worked very well, but on some few PCs (with an old ATI) it didn't work at all. So I'm using the same logic as you do now, namely saving the old mode instead of using "PDevMode(nil)^" and it works fine...

Regards, Madshi.
Madshi,
            Yeh it is amazing how you come across these unexpected faults. Keeps it interesting I suppose. Just a pity it always seems to occur after deployment of an app.
 
 Cheers and thanks,

 WESTY