[ Home | Contents | Search | Next | Previous | Up ]
Date: 11/30/99
Time: 1:22:34 AM
Question:
How can i leave a Window (excat an TDialog Object)
always on top (for example like the clock in Win 3.1)
Answer:
To keep a window on top of the others at all time, use the
EV_WM_ACTIAVTE message and EvActivate function. I'll include
some of the code below:
void DFrame::EvActivate(UINT active, BOOL minimized, HWND hWndOther)
{
::BringWindowToTop(GetLastActivePopup());
DefaultProcessing();
}
Also remember to include the lines
HWND hwndInsertAfter = HWND_TOPMOST; and
SetWindowPos(hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
in SetupWindow.
Futher more the InitInstance function in the application class
should read something like this:
void DApp::InitInstance()
{
if (hPrevInstance) {
HWND hwnd = ::FindWindow(WINCLASSNAME, 0);
if (hwnd) {
hwnd = GetLastActivePopup(hwnd);
BringWindowToTop(hwnd);
ShowWindow(hwnd, SW_RESTORE);
}
PostAppMessage(GetCurrentTask(), WM_QUIT, 0, 0);
}
else
TApplication::InitInstance();
}