Author Topic: how to stay a window on top  (Read 256 times)

Martin Vieregg

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 157
    • View Profile
how to stay a window on top
« on: April 02, 2020, 09:15:25 pm »
OS/2 distinghishes between a standard "window" and a "dialog window". A visible difference is that a standard window has got an arbitrary icon on the system menu button. A dialog window has only a drop down array icon. Both windows can run in modal and non-modal state. The standard "window" is created with the API call "WinCreateWindow" or "WinCreateStdWindow". A dialog window is created with WinCreateDlg or with WinLoadDlg (from a resource) and a parameter is the address of a message processing function.

An interesting difference in the behaviour of both types of window is that a dialog window continously stays on top, even another window of the program gets the focus, also in non-modal state.

My question: Is there a flag where a window created with WinCreateWindow gets the same behaviour of staying on top like a "dialog window" does?

The reason is that I want to add a specific property to the WDsibyl component library. In Freepascal Lazarus, such a property exists (tForm.Formstyle = fsStayOnTop). The WDsibyl tForm component is completely based on WinCreateWindow, also all standard controls do so.

Laurence Pithie

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 52
    • View Profile
Re: how to stay a window on top
« Reply #1 on: April 03, 2020, 09:32:13 am »
The FCF_SYSMODAL creation flag creates a system modal window. You can also use the WinSetSysModalWindow call to change a window into being the system modal window or from being the system modal window.

Martin Vieregg

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 157
    • View Profile
Re: how to stay a window on top
« Reply #2 on: April 03, 2020, 11:18:20 am »
Quote
The FCF_SYSMODAL creation flag creates a system modal window

But I want that the child window floats only over the main window of my appliction, not system wide. And it should be non-modal.

Alex Taylor

  • Sr. Member
  • ****
  • Thank You
  • -Given: 10
  • -Receive: 18
  • Posts: 280
    • View Profile
Re: how to stay a window on top
« Reply #3 on: April 03, 2020, 06:43:16 pm »
For a PM frame window, try this:
Code: [Select]
#define WS_TOPMOST      0x00200000L
WinSetWindowBits( hwndFrame, QWL_STYLE, WS_TOPMOST, WS_TOPMOST );

Martin Vieregg

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 157
    • View Profile
Re: how to stay a window on top
« Reply #4 on: April 03, 2020, 11:21:38 pm »
I'm sorry, but the WinSetWindowBits code seems not to work.

A system wide Float to top would be helpful, too, because it is also part of the Freepascal Lazarus code. (FormStyle = fsSystemStayOnTop) But all variants are non-modal.

Martin Vieregg

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 157
    • View Profile
Re: how to stay a window on top
« Reply #5 on: April 03, 2020, 11:29:10 pm »
I'm sorry, but the WinSetWindowBits code seems not to work.

A system wide Float to top would be helpful, too, because it is also part of the Freepascal Lazarus code. (FormStyle = fsSystemStayOnTop) But all variants are non-modal.

Laurence Pithie

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 52
    • View Profile
Re: how to stay a window on top
« Reply #6 on: April 04, 2020, 12:51:15 am »
One option would be to place the Main window behind the client window using WiinSetWindowPos when the client program is active. One way to  achieve that is by placing a check for the clinet program being active and calling WinSetWindowPos at the end of processing the WM_PAINT message in the main window procedure. Essentially what you woulld be doing is swapping the Z order of the two windows if the user brings the main window to the front while the client program is active.

Lars

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 45
  • Posts: 497
    • View Profile
Re: how to stay a window on top
« Reply #7 on: April 04, 2020, 09:35:59 pm »
If your child window is a sibling of your main window (whatever "child" and "main" window means in your context), you can use WinSetWindowPos with SWP_ZORDER to place your child window on top of any other sibling windows.

Sibling windows have a common parent window. If you can show us the relationship between your "child" window and "main" window (using PMTree, for example) then it should be possible to come up with a solution.

Lars

  • Sr. Member
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 45
  • Posts: 497
    • View Profile
Re: how to stay a window on top
« Reply #8 on: April 04, 2020, 09:45:20 pm »
Or try WinSetActiveWindow. See the help for this function. The active window will be placed above all other top-level windows on the screen (see "Window activation" in the help).