question

Daro911-7421 avatar image
0 Votes"
Daro911-7421 asked RLWA32-6355 answered

Creating a popup window above an another.

I have a handle to third party window (not created by me, retrieved using the FindWindow function). Now I'd like to create a small popup style window that will ALWAYS be laid down ovev/on top of that third party window. The case is I don't wanna the popup to be always above all the system windows, but ONLY above the window that I've described so I don't wanna use the HWND_TOPMOST option in the SetWindowPos function.

How can i achieve it without using the HWND_TOPMOST flag?

c++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SM-4238 avatar image
0 Votes"
SM-4238 answered RLWA32-6355 commented

Try passing the thirdpty window HWND as the owner of your popup window when you create it.
Read the section about owned windows here for reference: https://docs.microsoft.com/en-us/windows/win32/winmsg/window-features

-SM

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

There is a subtle risk here when you have a cross-process/cross-thread relationship between windows. The input queues are attached and the third party window does not know that it has an owned window. I suggest you read Is it legal to have a cross-process parent/child or owner/owned window relationship?


1 Vote 1 ·
Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Create a usual main window, then try calling this function:

SetWindowLongPtr( my_main_window, GWLP_HWNDPARENT, (LONG_PTR)third_party_main_window);


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RLWA32-6355 avatar image
0 Votes"
RLWA32-6355 answered

Another approach would be to use a windows hook (WH_CALLWNDPROCRET) to reposition your popup window over the third party window whenever the third party window changes its position in the z-order. Reposition after the third party window has handled a WM_WINDOWPOSCHANGED message indicating the change.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.