怎么添加一个菜单项到Windows的系统菜单 ?? 本人突然想知道可以不,谁知道啊~~~有的教教我!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个例子将一个菜单项加到系统菜单中去。我们需要两个东西,一个是项名,这可以是如何整数;我们还需要一个程序去收取Windows对确认点击我们创建的菜单项的信息。 Unit OhYeah; Interface Uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, Dialogs, Menus; Type TForm1 = Class (TForm) Procedure FormCreate (Sender : TObject); Private {Private declarations} Public {Public declarations} Procedure WinMsg (Var Msg : TMsg; Var Handled : Boolean); Procedure DoWhatEever; End; Var Form1 : TForm1; Implementation {$R *.DFM} Const ItemID = 99; // 这个ID number代表你的菜单项,可以是任何值。Procedure Tform1.WinMsg (Var Msg : TMsg; Var Handled : Boolean); Begin If Msg.Message = WM_SYSCOMMAND Then If Msg.WParam = ItemID Then DoWhatEver; End; Procedure TForm1.FormCreate (Sender : TObject); Begin Application.OnMessage := WinMsg; AppendMenu (GetSystemMenu (Form1.Handle, False), MF_SEPARATOR, 0, ''); AppendMenu (GetSystemMenu (Form1.Handle, False), MF_BYPOSITION, ItemID, '&My menu'); AppendMenu (GetSystemMenu (Application.Handle, False), MF_SEPARATOR, 0, ''); AppendMenu (GetSystemMenu (Application.Handle, False), MF_BYPOSITION, ItemID,'&My menu minimized'); End; Procedure TForm1.DoWhatEver; Begin Exit; //你可以添加任何你想加的东西到这里End; End. add an item to the systemmenu ? unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons; type TForm1 = class(TForm) BitBtn1: TBitBtn; procedure FormCreate(Sender: TObject); private procedure WMSysCommand(VAR Message: TWMSysCommand); message WM_SYSCOMMAND; { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation uses Unit2; {$R *.DFM} procedure TForm1.WMSysCommand(var Message: TWMSysCommand); begin Inherited; IF Message.CmdType = $F200 THEN form2.showmodal end; procedure TForm1.FormCreate(Sender: TObject); var s : string; begin s := '&Copyright...'; AppendMenu(GetSystemMenu(Handle, False), MF_STRING, $F200, PChar(s)); end; end. 如何获取opera中打开的页面中打开的网页的源代码 为什么我的Delphi6的控件栏上一个控件也没有了 预祝修罗这JR早日找到称心如意的工作!!! 遇到一个问题请大家帮个忙? 读写虚拟内存发生AV异常,高手帮帮忙!让我快快乐乐过新年! 如何从组件面板里移出自己写的控件? 求救!query问题 调用函数指针为什么执行出错了? 如何返回dll路径? postmessage()怎样用?? 请问怎样能改变控件的形状? ODBC默认的用户名和密码是什么
Public {Public declarations} Procedure WinMsg (Var Msg : TMsg; Var Handled : Boolean);
Procedure DoWhatEever; End; Var Form1 : TForm1; Implementation {$R *.DFM} Const ItemID = 99; // 这个ID number代表你的菜单项,可以是任何值。Procedure Tform1.WinMsg (Var Msg : TMsg; Var Handled : Boolean); Begin If Msg.Message = WM_SYSCOMMAND Then
If Msg.WParam = ItemID Then DoWhatEver; End; Procedure TForm1.FormCreate (Sender : TObject); Begin Application.OnMessage := WinMsg;
AppendMenu (GetSystemMenu (Form1.Handle, False), MF_SEPARATOR, 0, '');
AppendMenu (GetSystemMenu (Form1.Handle, False), MF_BYPOSITION, ItemID, '&My menu');
AppendMenu (GetSystemMenu (Application.Handle, False), MF_SEPARATOR, 0, '');
AppendMenu (GetSystemMenu (Application.Handle, False), MF_BYPOSITION, ItemID,'&My menu minimized'); End; Procedure TForm1.DoWhatEver; Begin Exit; //你可以添加任何你想加的东西到这里
End; End.
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons; type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
private
procedure WMSysCommand(VAR Message: TWMSysCommand); message WM_SYSCOMMAND;
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end; var
Form1: TForm1; implementation
uses Unit2; {$R *.DFM} procedure TForm1.WMSysCommand(var Message: TWMSysCommand);
begin
Inherited;
IF Message.CmdType = $F200 THEN form2.showmodal
end; procedure TForm1.FormCreate(Sender: TObject);
var s : string;
begin
s := '&Copyright...';
AppendMenu(GetSystemMenu(Handle, False), MF_STRING, $F200, PChar(s));
end; end.