From: tnomad@digital.net (The Nomad)
Subject: [delphi] Focus and Toolbars
Date: Wed, 26 Jul 1995 17:03:36 -0400

There were some questions a while back from David Bowden regarding handling
of focus on floating toolbars.  I replied to David directly, but think that
this forum may be interested in my findings.  The problem David was having
was that when his toolbar was clicked on, focus was transferred to the
window containing his toolbar.  What he wanted to do was transfer control
back to the window.

I experimented with this for a few seconds, and decided that this is really
annoying - you get a little flash as the toolbar window gets focus, and then
transfers focus back.  What he really wanted was a way to prevent his
toolbar from getting focus in the first place.  Enter the message
WM_MOUSEACTIVE.  This message is sent to a window when it doesn't have
focus, and someone clicks in the window (or on a pushbutton, etc).  The
message provides a Result value which you can use to tell windows whether
you want this window to have focus or not.  Setting Message.Result to
MA_NOACTIVATE solves the problem.  Here is a wedge of code:

  TForm2 = class(TForm)
    ButtonPanel1: TButtonPanel;
  private
    procedure WMMouseActivate(var Message: TWMMouseActivate); message
WM_MOUSEACTIVATE;
  public
  end;

...

procedure TForm2.WMMouseActivate(var Message: TWMMouseActivate);
begin
	Message.result := MA_NOActivate;
end;


There is still one more problem in that the title bar of the toolbar window
is never navy blue (indicating active).  So, in my little test, I slammed a
Panel at the top of the window (aligned to top) and colored clActiveText (I
think).  I then set the form's border style to bsNone (no border or title
bar).  I also threw a couple of TShapes on the panel to look like the system
menu in the upper left corner, and added some handlers for the panel to move
the form.  Voila - instant toolbar.

************************************
*           The Nomad              *
*        tnomad@digital.net        *
************************************


