How to make a “popup” (hint, drop-down, popup) window in Winforms?

后端 未结 3 882

How can i make, what i will call, a \"popup\" window\" in WinForms?


Since i used my own made-up word \"popup\", let me give examples of this so-called \"p

3条回答
  •  粉色の甜心
    2021-02-06 12:18

    Create your "popup" window as a child window of desktop, then show it without activating it.

    hWnd = CreateWindowEx(..., WS_CHILDWINDOW | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS, ..., GetDesktopWindow(), ...);
    SetWindowPos(hWnd, HWND_TOPMOST, ..., SWP_NOACTIVATE);
    

    After doing this, your original window remains activated even if you click on the "popuped" window. The "popup" window can have its own children controls. You can click the button on it. But if it is an edit control, you cannot edit it, I don't know why. Maybe because there is already a cursor on your original window, blinking.

提交回复
热议问题