本文整理自网络,侵删。
如何获取窗口的图标,这里给出一个简单的方法:function MyGetWindowIcon(H:Hwnd):Hicon;
begin
result:=GetClassLong(H,GCL_HICON); //第一种方法取图标
if ico=0then
result:=sendmessage(h,wm_geticon,icon_big,0);//第二种方法取
end;
返回值:非0:表示取到了图标,返回值为取得的图标的句柄
0: 表示取不到图标
参数说明:
H:Hwnd,为所要取图标的窗口的句柄.
调用方法:
procedure Tform1.button1click(sender:tobject);
var
h:hwnd;
ico:hico;
begin
h:=findwindow('Notepad',nil);
ico:=myGetWindow(h);
if ico<>0then
image1.picture.icon.handle:=ico;
end;
相关阅读 >>
Delphi2007-Delphi2010 程序不出现在任务栏的方法
更多相关阅读请进入《Delphi》频道 >>