I was curious how combobox dropdowns and menus work, so I did some more research.
There are two main approaches.
Create a popup as an overlapping window belonging to the main window
This method is necessary if the popup has built-in controls or if you want the popup to appear as a modeless dialog box.
If the user interacts with child controls in a pop-up window, he must receive activation. (Thus, various activation blocking methods, such as WM_MOUSEACTIVATE processing, are red herrings.) And when it receives activation, Windows deactivates the main window. The fix for this is to send the WM_NCACTIVATE message to the parent to update its appearance without changing its activation status. This is the approach used by the .NET ToolStrip, and my other answer illustrates it with code.
Create a popup as a child of the desktop window
This method is used by combobox and (I think) drop-downs, but you cannot implement child controls so that it is not widely applicable.
The popup is a child window, so it does not interfere with activation. He is always on top. Mouse capture is used to detect clicks outside the pop-up window and dismiss it.
However, this is not so easy to implement. Activation remains with the main application, so it retains focus and receives keystrokes. It seems like this excludes the built-in controls in the popup because they cannot receive focus. Combobox handles this by forwarding keystroke messages to a drop-down list. (Note that menus, drop-down lists, drop-down lists, etc. are all completely owner-drawn in the sense that they don't have built-in windows.)
source share