Einzelnen Beitrag anzeigen

teebee

Registriert seit: 17. Jan 2003
Ort: Köln
460 Beiträge
 
Delphi 6 Professional
 
#18

Re: Welcher ToolButton ruft PopupMenu auf?

  Alt 25. Apr 2005, 15:10
Habe jetzt in den Tiefen der API-Doku eine Möglichkeit gefunden, die das ganze ziemlich solide macht (ohne Mausposition oder MouseOver).
Delphi-Quellcode:
 type
  TForm1 = class(TForm)
   ...
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    DropButton: Integer;
    Procedure WMNotify(Var Msg: TWMNotify); message WM_NOTIFY;
end;

...

Procedure TForm1.WMNotify(Var Msg: TWMNotify);
Begin
  If Msg.NMHdr^.code=TBN_DROPDOWN Then
    DropButton := PNMTOOLBAR(Msg.NMHdr)^.iItem;
  inherited;
End;

procedure TForm1.PopupMenu1Popup(Sender: TObject);
begin
  ShowMessage('Gedrückt von: '+ToolBar1.Buttons[DropButton].Name); // hier wahlweise auch Tag-Auswertung :-)
end;
Gruß, teebee
  Mit Zitat antworten Zitat