how to set a dialog always topmost
Hi all~
I design a desktoplock program. When a default idle time is expired, it
will pop up dialogs. One dialog is full-screen picture, another is a child
dialog to input password. I implement the full-screen dialog always topmost
by using the function of "SetWindowPos".
Now i find that the function can not make that user's focus is always
topmost. for example, if i open "MyComputer" and double click "Local Disk
C:", then I create a file in C:\. When inputting filename, i stop my action
and idle to let desktoplock dialog popup. In this situation, sometimes user's
focus will not be desktoplock dialog but "Local Disk C" dialog. And this
problem make user can not input password to unlock desktoplock because the
program lock mouse and some control key too.
May other way or function to implement what i want perfectly? Maybe like
screensaver? I search many web sites but don't get a real solution.Thanks a
lot.
Code Segmant:
Fucll Screen Dialog function-
void SetFullScreen()
{
PostMessage(WM_USER+100, 0, 0);
style = GetWindowLong(m_hWnd, GWL_STYLE);
style &= ~(WS_DLGFRAME | WS_THICKFRAME);
SetWindowLong(m_hWnd, GWL_STYLE, style);
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
::SetWindowPos(m_hWnd, HWND_TOPMOST, -1, -1, cx+3, cy+3,SWP_SHOWWINDOW);
IsFullScreen=TRUE;
UpdateWindow();
::SetWindowPos(m_hWnd, HWND_TOPMOST, -1, -1, cx+3, cy+3,SWP_SHOWWINDOW);
}
child dialog: password dialog -
SetTimer( 110, 500, 0 );
void CDesktopLock::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call default
switch (nIDEvent)
{
case 110:
SetForegroundWindow();
SetActiveWindow();
break;
default:
//SetForegroundWindow();
//SetActiveWindow();
break;
}
CDialog::OnTimer(nIDEvent);
}