Mark Derricutt asked:

> So as well as creating my TMyComboThing, I create a subclass of
> the comp I  wanna drop down (in my case a TListView) and
> override CreateParams, and create that.

Exactly. But to keep things simple our library has just one panel
descendant that has this capability and anything we want to pop up is just
parented onto one of these panels. That allows you to have multiple
components on the panel all popping up at once, and not have to be
recreating the popup code all the time.

> Then to pop it up, I just .visible := true/false it?

That's it. The one thing you do need to do is carefully position it in
screen coordinates relative to the component that triggering the popup,
and being careful not to have it fall of the edges of the screen too much.
I do this by having an overridden Visible propertyly that positions the
popup and then passes the new visible state to the base class Visible
property, but there are other way to do that sort of thing.

> Sounds fairly simple...  Assuming I've got it right..

You've got it right. And so save you another trip back to the group to ask
when it works really strangely you have to add in a new event handler as
follows:

procedure TDropDownPanel.WMMouseActivate(var Message: TWMMouseActivate);
begin
  Message.Result := MA_NOACTIVATE
end;

otherwise you will get the popup window becoming the active window, and
the focus on the component that triggered the popup will be lost. Have a
look at the documentation for WM_MOUSEACTIVATE to get reasons for why it
works and how.

And any components on the popup have to be careful about not grabbing the
focus, unless your prepared to manage the madness caused by the focus
shifting into a popup editor and then needing to be restored back later.

Cheers, Max.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to