views:

157

answers:

2

I'm developing a custom autocomplete control in pure WinApi, and the problem that I've encountered is that I don't know how to hide the popup window when clicked outside of the control (e.g. emulate the combobox dropdown behavior). How is it usually implemented? Should I use mouse capture? Thanks.

UPD: Tracking keyboard focus doesn't fit the bill since dragging the parent window around should also hide the dropdown.

UPD: Mouse capture doesn't work because it "captures mouse input either when the mouse is over the capturing window, or when the mouse button was pressed while the mouse was over the capturing window and the button is still down".

+2  A: 

After reading this article I now believe that using SetWindowsHookEx and a WH_MOUSE hook is the way to go.

But maybe there is a simpler solution?

Alex Jenter
A: 

Autocomplete is native in Win32 api (Shell)
You don't need code.
(For source code of Windows Shell Autocomplete, see on Win32 group )

it can't do autocomplete for separate words
Alex Jenter