OS/2, eCS & ArcaOS - Technical > Programming
how to stay a window on top
Martin Vieregg:
Thank you Doodle for your post. But I wonder why a Dialog Window has the behaviour I would like to have. Dialog Windows always stay on top above the main program (standard) window. I thaught that all windows are internally the same for the operating system and only with different properties. So it seems that you cannot write a Dialog Window call with WinCreateWindow or WinCreateStandardWindow.
In WDsibyl, I have got a list of existing forms of an application in the main form. A form which changes the ZOrder to TOP should send a message to the main form of the application and the main form should send a message back to all other forms. If the other form has got the "StayOnTop" property set, it should get the ZOrder TOP again. This conecpt works without timer messages. I will report if I managed it.
Do you have an idea how to turn off the system wide WS_TOPMOST flag after it has been set?
Doodle:
--- Quote ---I wonder why a Dialog Window has the behaviour I would like to have. Dialog Windows always stay on top above the main program (standard) window.
--- End quote ---
The Dialog Windows are created with a different API (WinCreateDialog), and their window procedure has to follow different rules (return if a message was processed or not). If it's not processed, a default dialog window procedure of the OS/2 system will handle the message, and that already has this logic implemented, that when the dialog window gets activated and shown, it disables its owner window for the time the dialog window is active. If a window is disabled (see WinEnableWindow API), the user cannot interact with it, so you cannot click on the main window if you have a child dialog window active.
It's quite nicely described in the Presentation Manager Programming Guide:
ftp://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/pc/os2/warp_ver_3/G25H-7103-00_OS2_WARP_V3_Presentation_Manager_Programming_Guide_The_Basics_Oct94.pdf
Focus on chapter 15-1 (Dialog Windows), most importantly on "modal" dialogs.
--- Quote ---Do you have an idea how to turn off the system wide WS_TOPMOST flag after it has been set?
--- End quote ---
Sorry, I don't know. I never had to do that, but I always thought that removing the flag would be enough..
Martin Vieregg:
Now I managed to implement all the functionality I wanted for the WDsibyl library:
tForm.Formstyle = fsSystemStayOnTop
tForm.Formstyle = fsStayOnTop
For turning on the TOPMOST functionality, I used
WinSetWindowBits(hwnd, QWL_STYLE, WS_TOPMOST, WS_TOPMOST);
Turning off:
WinSetWindowBits(hwnd, QWL_STYLE, 0, WS_TOPMOST);
If the window is not created while setting the property, the window is created with the WS_TOPMOST flag.
For "fsStayOnTop", I have fetched all events where other window go to HWND_TOP of and in these cases, all the forms of the program which have got the fsStayOnTop property set are going to top after the window which has gone to top by the user. It works already fine.
I send now the changes to Rolf which collects the libary changes. I will send a message here if the new WDsibyl library is available.
Rich Walsh:
--- Quote from: Martin Vieregg on May 09, 2020, 06:33:57 pm ---I wonder why a Dialog Window has the behaviour I would like to have. Dialog Windows always stay on top above the main program (standard) window.
--- End quote ---
This is really sad. Hasn't anyone RTFM?
You're about to abuse a powerful - and possibly very annoying - feature (WS_TOPMOST) simply because neither you nor any of the other respondents knows one of the basics of PM programming: an owned window is always higher in the z-order than the frame window which owns it.
If a dialog is always on top of the window which created it, it's because the dialog is owned by that window. Change its owner to HWND_DESKTOP and the dialog will be free to go anywhere in the z-order. If you need a specific z-order for your windows, establish an ownership chain - don't use WS_TOPMOST.
BTW... there are times when WS_TOPMOST is called for. but it should always be at the user's discretion (i.e. he can turn it off).
Lars:
I think you meant to say "parent-child relationship" instead of "ownership" but the explanation in the "Presentation Manager Programming Guide" is a bit blurry about z-ordering.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version