Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting Resolution Change

Status
Not open for further replies.

Zyrenthian

Programmer
Mar 30, 2001
1,440
US
Hi All,
Is there a way to detect when the windows screen resoluiton changes from within my app? I was first thinking along the lines of PreTranslateMessage butI am not sure it this is the way to go concidering my app would need focus for the PreTranslateMessage to happend (and I am not sure if PreTranslateMessage can even detect that). How would you go about doing this? Hooks? Please post any ideas.

matt
 
Answer:

WindowProc with WM_SETTINGCHANGE for a message.

Matt
 
Hi Matt,
Have you seen ON_WM_DEVMODECHANGE and ON_WM_DISPLAYCHANGE?
Although ON_WM_DISPLAYCHANGE is nowhere to be found in the Microsoft documentation, the dev mode change handler that you would write does get control when you change the
screen resolution in the control panel, because all top level CWnd objects get this message. In this event handler,
you could then get the new screen resolution. Eg.

void CTopmostView::OnDevModeChange(LPTSTR lpDeviceName)
{
CView::OnDevModeChange(lpDeviceName);
int xWidth = GetSystemMetrics(SM_CXSCREEN);
int nHeight = GetSystemMetrics(SM_CYSCREEN);
}

Hope this helps [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top