Creating a popup window above an another.

Daro911 1 Reputation point
2021-10-04T15:43:18.65+00:00

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++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,516 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. SM 416 Reputation points
    2021-10-04T17:01:20.867+00:00

    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://learn.microsoft.com/en-us/windows/win32/winmsg/window-features

    -SM


  2. Viorel 111.7K Reputation points
    2021-10-04T18:30:46.97+00:00

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

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

    0 comments No comments

  3. RLWA32 40,021 Reputation points
    2021-10-05T09:55:08.433+00:00

    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.

    0 comments No comments