W
wooiguo
Unregistered / Unconfirmed
GUEST, unregistred user!
我已经知道怎么添加菜单和响应点击,点击时,如何获得此项菜单的Caption? const SC_MyMenuItem = WM_USER + 1; procedure TForm1.FormCreate(Sender: TObject); var myMenu:hMenu; begin Mymenu := getsystemmenu(application.Handle, false); AppendMenu(myMenu,MF_STRING,SC_MyMenuItem,'menu1'); AppendMenu(myMenu,MF_STRING,SC_MyMenuItem+1,'menu2); Application.OnMessage:=OnAppMessage; end; procedure TForm1.OnAppMessage(var Msg:TMsg;var Handled:boolean); var myMenu:hMenu; begin Mymenu := getsystemmenu(application.Handle, false); Handled:=false; if (Msg.message=WM_SYSCOMMAND) and (Msg.wParam=SC_MyMenuItem) then begin showMessage('测试1'); Handled:=True; end; if (Msg.message=WM_SYSCOMMAND) and (Msg.wParam=SC_MyMenuItem+1) then begin showMessage('测试2); Handled:=True; end; end;