T
terry_zhou82
Unregistered / Unconfirmed
GUEST, unregistred user!
把一个toolbutton设为check状态,执行的代码如下,执行正常,但放在菜单里面,却会在状态栏上面显示的窗体。就其原因,是form2中的的.Createparams(var Params: TCreateParams); 想知道,如果在菜单里面,怎么写才可以和实现和按钮一样的功能呢?(popupmenu2和toolbutton1在同一个FORM1中)procedure TForm1.ToolButton1Click(Sender: TObject); begin if ToolButton1.Down then begin form2:=TForm2.Create(self); with form2 do begin top:=20 ; left:=Screen.Width -form2.Width ; FormStyle:=fsStayOnTop; Show; Timer1.Enabled :=true; end; PopupMenu2.Items[1].Caption :='关闭每日提醒'; end else begin form2.Close ; PopupMenu2.Items[1].Caption :='显示每日提醒'; end; end; procedure TForm2.Createparams(var Params: TCreateParams); begin inherited CreateParams(Params); Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW; Params.WndParent := GetDeskTopWindow; end; //以下是菜单的procedure TForm1.N39Click(Sender: TObject);begin if PopupMenu2.Items[1].Caption ='关闭每日提醒' then begin toolbutton2.Down :=false; form2.Close ; popupMenu2.Items[1].Caption :='显示每日提醒'; end else begin ToolButton1.Down :=true; Toolbutton1.OnClick(self); end; end;