Force window on top
-
Hi, I wrote an application that has to warn a user of a certain state. I want to make sure the user sees my window. How do a I force it to be always on top of all other applications running ? This window is a simple CDialog derived window. Thanks in advance, Shay
-
Hi, I wrote an application that has to warn a user of a certain state. I want to make sure the user sees my window. How do a I force it to be always on top of all other applications running ? This window is a simple CDialog derived window. Thanks in advance, Shay
Does
SetWindowPos()
orBringWindowToTop()
work for you?
"Take only what you need and leave the land as you found it." - Native American Proverb
-
Does
SetWindowPos()
orBringWindowToTop()
work for you?
"Take only what you need and leave the land as you found it." - Native American Proverb
Almost there.... I want to force it on top of all windows and SetWindowPost seems to do the best work. However, I need a way to get the exact size of the bottom right corner. This code is crashing for me:
LPRECT lpRect; this->GetWindowRect(lpRect); this->SetWindowPos(&CWnd::wndTopMost,10,10,lpRect->right,lpRect->bottom,SWP_SHOWWINDOW);
-
Almost there.... I want to force it on top of all windows and SetWindowPost seems to do the best work. However, I need a way to get the exact size of the bottom right corner. This code is crashing for me:
LPRECT lpRect; this->GetWindowRect(lpRect); this->SetWindowPos(&CWnd::wndTopMost,10,10,lpRect->right,lpRect->bottom,SWP_SHOWWINDOW);
Shay Harel wrote:
LPRECT lpRect;
Change to:
RECT Rect;
"Take only what you need and leave the land as you found it." - Native American Proverb
-
Shay Harel wrote:
LPRECT lpRect;
Change to:
RECT Rect;
"Take only what you need and leave the land as you found it." - Native American Proverb
this one worked, thanks !
-
Almost there.... I want to force it on top of all windows and SetWindowPost seems to do the best work. However, I need a way to get the exact size of the bottom right corner. This code is crashing for me:
LPRECT lpRect; this->GetWindowRect(lpRect); this->SetWindowPos(&CWnd::wndTopMost,10,10,lpRect->right,lpRect->bottom,SWP_SHOWWINDOW);
Also, you could be seriously jacking up your window position, if it is already positioned near the upper left corner with only a little bit of the lower right corner showing. I strongly recommend something like: this->SetWindowPos( &CWnd::wndTopMost,10,10, Rect.right - Rect.left, // its width Rect.bottom - Rect.Top, // its height SWP_SHOWWINDOW); Or even this->SetWindowPos( &CWnd::wndTopMost,10,10, max(Rect.right - Rect.left, 100), // its width max(Rect.bottom - Rect.Top, 100), // its height SWP_SHOWWINDOW); If you are REALLY paranoid, like me :omg: