and how do I do so that the windows I open having as parent the main window appear over this image?
Got it — you want your other windows (dialogs/tool windows you open from the main window) to appear above the overlay image.
Easiest fix: don’t make the overlay TOPMOST. Keep it a transparent, borderless window, but use #HWND_TOP (not #HWND_TOPMOST) and add #WS_EX_NOACTIVATE. Then any normal window you open (parented/owned by the main window) will rise above the overlay when it’s shown/activated.
Here’s the minimal tweak from the earlier snippet:
Code: Select all
; ... after OpenWindow(0) and MDIGadget(...)
; overlay window (transparent, click-through, NON-topmost)
OpenWindow(1, 100, 100, w, h, "", #PB_Window_BorderLess | #PB_Window_Invisible)
SetWindowColor(1, RGB(255,0,255))
ImageGadget(1, 0, 0, w, h, ImageID(img), #PB_Image_BorderLess)
; transparent background + no-activate so it never steals focus
Protected ex = GetWindowLongPtr_(WindowID(1), #GWL_EXSTYLE)
SetWindowLongPtr_(WindowID(1), #GWL_EXSTYLE, ex | #WS_EX_LAYERED | #WS_EX_TRANSPARENT | #WS_EX_NOACTIVATE)
SetLayeredWindowAttributes_(WindowID(1), RGB(255,0,255), 0, #LWA_COLORKEY)
; put it above the MDI host, but NOT topmost
SetWindowPos_(WindowID(1), #HWND_TOP, 100, 100, w, h, #SWP_SHOWWINDOW)
Now when you open another window, it’ll show over the image:
Code: Select all
; any normal top-level window you open will be above the overlay
OpenWindow(2, 160, 160, 320, 200, "Child/Dialog", #PB_Window_SystemMenu | #PB_Window_Tool)
; (optional) ensure it’s on top of non-topmost windows right away:
SetWindowPos_(WindowID(2), #HWND_TOP, 0,0,0,0, #SWP_NOMOVE|#SWP_NOSIZE|#SWP_SHOWWINDOW)
Why this works
By removing TOPMOST, the overlay stays above the MDI host but below any currently active normal windows.
#WS_EX_NOACTIVATE ensures the overlay never grabs focus (so your dialogs naturally come to the front).
You still keep the transparent background via the color key, so the overlay window itself isn’t opaque.
If you prefer your dialogs to always sit above everything the moment they’re created, keep that one-line SetWindowPos with #HWND_TOP on creation.
GPT SAID THIS AND IT WORKS!