Dear Sirs, I'm writing a custom dropdown control. The base is a button
(BitBtn), its OnClick event pops up (or rather: drops down) a little
borderless window, with a TrackBar on it.
To show the dropdown form, I use:
SetWindowPos(myForm.Handle,
HWND_TOP,
myForm.Left,
myForm.Top,
0,
0,
SWP_NOSIZE or SWP_NOACTIVATE or SWP_SHOWWINDOW);
myForm.Visible := True;
myForm.Invalidate;
With this, the dropdown shows up, but it doesn't take the focus away
from the main form (=parent of my control). When someone uses the
TrackBar, then clicks elsewhere (so that the dropdown loses focus), I
hide the dropdown using the OnDeactivate event.
BUT: other professional dropdown controls can do this: I click the
button (and it will have the focus), the dropdown shows up, doesn't
take the focus from the parent form, and when I click anywhere on the
parent form (without ever giving the focus to the dropdown!), the
dropdown disappears. Even if I click on the title bar of the parent
window, which does not take away the focus from my button I just
clicked, the dropdown form knows it needs to disappear! How can this
be done?
In other words: the custom control knows that I clicked on the parent
form, even if the button retains the focus, and the dropdown form
itself doesn't have the focus. Can anyone tell me how it is done?


|