Forum > LCL
Howto send mouse-msg to ToolButton or DropDown-ToolButton Menu?
SunyD:
Hello,
i am writing Toolbarmenu-component. A toolbar that can act as Mainmenu.
I don't find out howto dropdown menuitem associated with toolbutton at runtime. With mouse-clicks it works. But I want open/close menus if mouse-moved like in MainMenu.
I get at runtime which toolbutton is under mouse-cursor.
Toolbutton.Click or Toolbutton.Dispatch don't helps :(
Howto send mouse-msg to ToolButton or DropDown-ToolButton Menu?
SunyD:
I can send mouse-message to toolbutton but the MenuItem doesn't popup.
You must really click with your finger at your mouse-hardware to popup toolbutton menus :o
I give it up.
Ocye:
Can't you call popup() directly?
SunyD:
--- Quote from: Ocye on July 26, 2010, 05:59:55 am ---Can't you call popup() directly?
--- End quote ---
To popup ToolButton's PopupMenu or MenuItem there is only one way:
ToolButton.CheckMenuDropdown;
You can create 1 MainMenu(File, Edit and Helpmenu with Subitems) and ToolBar with 3 ToolButtons.
Associate each ToolButton.MenuItem property with File, Edit and Help menuitem.
Then put 3 TButtons and call from TButtons.OnClick-Event ToolButton.CheckMenuDropDown-Function. It works because you click before with left Mouse Button on TButton.
And now put a Timer and call in Timer.OnTimer Event ToolButton.CheckMenuDropDown it doesn't work. i.e:
Popup Toolbutton Menus without clicking left-mouse-button:
--- Code: ---procedure TForm1.Button4Click(Sender: TObject);
begin
Timer1.Tag:=0;
Timer1.Enabled:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
case Timer1.Tag of
0: begin
//this works, it will popup because it's first menu
ToolBFileCat.CheckMenuDropdown;
Label1.Caption:='FileMenu';
end;
//from hier the menus will not popup!!!
1: begin
Label1.Caption:='EditMenu';
//Added. Sending LButton-Msg to ToolBar to hide visible-menu. it works PostMessage(ToolBar1.Handle, WM_LBUTTONDOWN, MK_LBUTTON, Longint(PointToSmallPoint(Point(-1,-1))));
Application.ProcessMessages;
//End test
ToolBEditCat.CheckMenuDropdown;
end;
2: begin
ToolBHelpCat.CheckMenuDropdown;
Label1.Caption:='HElpMenu';
end;
else begin
Timer1.Tag:=-1;
Timer1.Enabled:=false;
Label1.Caption:='Timer stopped';
end;
end;
Timer1.Tag:=Timer1.Tag+1;
end;
--- End code ---
I think there is a bug or i make mistake. I looked and don't find any bug in files:
lcl/comctrls.pp
lcl/include/toolbar.inc
-function TToolBar.CheckMenuDropdown
lcl/include/toolbutton.inc
-procedure TToolButton.MouseUp
-function TToolButton.CheckMenuDropdown
If anycone can popup ToolButton.MenuItem without clicking mousebutton (see Timer-Example up) write it here please.
SunyD:
Same results with Delphi7.
I think there is no bug in lcl.
Navigation
[0] Message Index
[#] Next page