delphi 如何获取窗口的图标  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 如何获取窗口的图标


如何获取窗口的图标,这里给出一个简单的方法:

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;


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.034526109695435 seconds