如果给每个程序(比如:记事本、画图等程序)的标题栏加上自己的按钮是可以做到的。(用画的方法),但能不能给每个程序(比如:记事本、画图等程序)标题栏的快捷菜单上加上自己的菜单呢?大家有没有什么思路或代码提供?谢谢了。
procedure TForm1.Timer1Timer(Sender: TObject);
var Forehdle:THandle;
begin
Forehdle:=GetForegroundWindow;
Appendmenu(GetSystemMenu(Forehdle,false),MF_STRING,idMyFunc,'我的菜单');
end;
我用这种方法加的时候,‘我的菜单’会不断的增加。
procedure TForm1.Timer1Timer(Sender: TObject);
var Forehdle:THandle;
begin
Forehdle:=GetForegroundWindow;
Appendmenu(GetSystemMenu(Forehdle,false),MF_STRING,idMyFunc,'我的菜单');
end;
我用这种方法加的时候,‘我的菜单’会不断的增加。
var
hd:HWnd;
sz:array[0..254] of char;
begin
hd:=GetWindow(Handle,GW_HWNDFIRST);
while hd<>0 do
begin
Appendmenu(GetSystemMenu(hd,false),MF_STRING,3,'我的菜单1');
hd:=GetWindow(hd,GW_HWNDNEXT);
end;
end;
当有新的程序运行时,我们必须重新运行它,否则就不能给新的程序加菜单了!但是一运行它的话,原来我们已经加入自己菜单的程序又会多加了一个菜单了!!!!!!!!!hottey(孤独的探索者)(起步中) 和我的方法的最好的解决办法是能不能通过一定的渠道判断出程序是否已经加入了我们自己的菜单,如果已经有了就不在加入!
不知大家还有什么方法或思路????
var
vMenu: THandle;
begin
vMenu := GetSystemMenu(GetForegroundWindow, False);
if FMenuList.IndexOf(Pointer(vMenu)) >= 0 then Exit; //如果已经添加
AppendMenu(GetSystemMenu(GetForegroundWindow, False),
MF_STRING, idMyFunc, '我的菜单');
FMenuList.Add(Pointer(vMenu));
end;procedure TForm1.FormCreate(Sender: TObject);
begin
FMenuList := TList.Create;
end;procedure TForm1.FormDestroy(Sender: TObject);
var
I: Integer;
begin
for I := 0 to FMenuList.Count - 1 do
DeleteMenu(THandle(FMenuList[I]), idMyFunc, MF_BYCOMMAND);
FMenuList.Free;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var Forehdle:THandle;
var ForeMenu:HMENU;
var MenuCount:integer;
var MenuId:longint;
var TStr:array[0..255]of char;
var i:integer;
begin
Forehdle:=GetForegroundWindow;
ForeMenu:=GetSystemMenu(Forehdle,false);
MenuCount:=GetMenuItemCount(ForeMenu); for i:=0 to Menucount do
begin
MenuId:=GetMenuItemID(ForeMenu,i);
if MenuId=11 then
Exit ;
end;
Appendmenu(ForeMenu,MF_STRING,11,'我的菜单');
end;