Stay On Top - Advice Needed
-
I have an application that allows users to select "stay on top"...however if another application presents a message box (crital error for example), I'd like to trap that and force that message box into the foreground...does anyone have advice on the best way to implement such a feature? TIA! Regards, Norm:confused:
-
I have an application that allows users to select "stay on top"...however if another application presents a message box (crital error for example), I'd like to trap that and force that message box into the foreground...does anyone have advice on the best way to implement such a feature? TIA! Regards, Norm:confused:
-
I have an application that allows users to select "stay on top"...however if another application presents a message box (crital error for example), I'd like to trap that and force that message box into the foreground...does anyone have advice on the best way to implement such a feature? TIA! Regards, Norm:confused:
I hope I will not waste your time. I am a beginner and had never tried making my window on top, but I think that you do it by setting the window's style. I have an idea, but I do not know whether it is correct or applicable. If an application presents a message box, then your application will lose focus. May be you could handle
WM_KILLFOCUS
(orOnKillFocus()
) and test the window getting focus for its style. If the style contains on top (and maybe message box style), put it somehow in front of your app (I think you would need to change your app's Z-order to make it after the message box). Hope this helps, and sorry for anything wrong I may have said.Hosam Aly Mahmoud
-
I hope I will not waste your time. I am a beginner and had never tried making my window on top, but I think that you do it by setting the window's style. I have an idea, but I do not know whether it is correct or applicable. If an application presents a message box, then your application will lose focus. May be you could handle
WM_KILLFOCUS
(orOnKillFocus()
) and test the window getting focus for its style. If the style contains on top (and maybe message box style), put it somehow in front of your app (I think you would need to change your app's Z-order to make it after the message box). Hope this helps, and sorry for anything wrong I may have said.Hosam Aly Mahmoud
As I tried to look it up, I saw that you may be able to handle it as follows:
case WM_KILLFOCUS:
if ( wParam != 0 )
{
WINDOWINFO wi;
GetWindowInfo( (HWND)wParam, &wi ); // sorry, did not check for errors
if ( (wi.dwExStyle & WS_EX_TOPMOST) == WS_EX_TOPMOST )
{
SetWindowPos( (HWND)wParam, HWND_TOP,
0, 0, 0, 0, // ignored
SWP_NOMOVE | SWP_NOSIZE |
SWP_NOOWNERZORDER | SWP_NOSENDCHANGING );
}
}
return 0;Hope this helps (and hope I am not wrong!).
Hosam Aly Mahmoud
-
As I tried to look it up, I saw that you may be able to handle it as follows:
case WM_KILLFOCUS:
if ( wParam != 0 )
{
WINDOWINFO wi;
GetWindowInfo( (HWND)wParam, &wi ); // sorry, did not check for errors
if ( (wi.dwExStyle & WS_EX_TOPMOST) == WS_EX_TOPMOST )
{
SetWindowPos( (HWND)wParam, HWND_TOP,
0, 0, 0, 0, // ignored
SWP_NOMOVE | SWP_NOSIZE |
SWP_NOOWNERZORDER | SWP_NOSENDCHANGING );
}
}
return 0;Hope this helps (and hope I am not wrong!).
Hosam Aly Mahmoud
Thanks, just what I needed! I'll check the wi.dwStyle for WS_POPUP or WS_POPUPWINDOW and if that window's RECT intersects my window will set the appropriate Z-Order for these two windows. best regards, norm
-
Thanks, just what I needed! I'll check the wi.dwStyle for WS_POPUP or WS_POPUPWINDOW and if that window's RECT intersects my window will set the appropriate Z-Order for these two windows. best regards, norm
I am happy it worked! :-D
Hosam Aly Mahmoud