Keep a 2nd Window lock on top of the Primary Window without modal

Hello - Happy July 4th

This might be an amateur question for Microsoft Windows behavior. I would like to have 2nd window that opens from the menu to always stay on top of my Main Window even when the main window is clicked on. I don’t want Modal. The 2nd window always gets lost behind the Main Window when it is clicked on making a bad user experience. Is there a windows property in Xojo that does this.


Run this code in your Window.Open

Const HWND_TOPMOST = -1 Const SWP_NOMOVE = &h2 Const SWP_NOSIZE = &h1 Soft Declare Function SetWindowPos Lib "User32" (hWnd As Integer, hWndInsertAfter As Integer, X As Int32, Y As Int32, cx As Int32, cy As Int32, uFlags As UInt32) As Int32 Call SetWindowPos(Self.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)

Thanks Julian

I’ll give it a try.

You might also try setting the window type to “Floating Window”

The simple way is the best way. Thanks Greg it work great