madagadaguda
Newcomer
- Joined
- May 20, 2004
- Messages
- 2
I'm writing a WinForms application that needs to update its user area on change of resolution by the user. I've overriden the WinProc method of my main form so that I can monitor the changes of the resolution and do what I need to do. Its body looks like this:
private const int WM_DISPLAYCHANGE = 0x007E; // this is the message notifying that the display resolution has been changed
protected override void WndProc(ref Message m)
{
The problem is that the Screen.PrimaryScreen.Bounds property doesn't work properly the first time the resolution is changed by the user after the application is started. It returns the previous resolution of the display. Here comes the strange part: all the following changes work fine.
I've tried using the Microsoft.Win32.SystemEvents.DisplaySettingsChanged event but the result is the same. Is there a way to get this right?
10x
K.
private const int WM_DISPLAYCHANGE = 0x007E; // this is the message notifying that the display resolution has been changed
protected override void WndProc(ref Message m)
{
base.WndProc (ref m);
if(m.Msg == WM_DISPLAYCHANGE)
{
MessageBox.Show("Width: " + Screen.PrimaryScreen.Bounds.Width + "\n" + "Height: " + Screen.PrimaryScreen.Bounds.Height);
}
}The problem is that the Screen.PrimaryScreen.Bounds property doesn't work properly the first time the resolution is changed by the user after the application is started. It returns the previous resolution of the display. Here comes the strange part: all the following changes work fine.
I've tried using the Microsoft.Win32.SystemEvents.DisplaySettingsChanged event but the result is the same. Is there a way to get this right?
10x
K.