Главная страница | назад

Article #16489: How to keep a window always on top

 Question and Answer Database

FAQ1489C.txt   How to keep a window always on top
Category   :OWL
Platform    :All
Product    :BC++  5.x


How can i leave a Window (excat an TDialog Object) 
always on top (for example like the clock in Win 3.1)


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)

Also remember to include the lines 
HWND hwndInsertAfter = HWND_TOPMOST; and 
SetWindowPos(hwndInsertAfter, 0, 0, 0, 0, SWP_NOMOVE | 
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);
     ShowWindow(hwnd, SW_RESTORE);

   PostAppMessage(GetCurrentTask(), WM_QUIT, 0, 0);

7/2/98 10:32:32 AM

Last Modified: 01-SEP-99