Vb教程   Vb.net教程   Vfp教程   C/C++教程   Vc/Vc++教程   Delphi教程   Java教程   Powerbuilder
  杀毒频道 | 短信频道 | 网络电视 | 论文中心 | 教你学上网 | 教你学软件 | 网页特效 | 电脑基础 | 论坛  
  计算机等级 | 程序员考试 | 英语四六级 | 职称英语 | 司法考试 | 报关员考试 | 公务员考试 | 翻译员考试 | 注册会计师  
  Html教程 | Css教程 | Xml教程 | Asp教程 | Asp.net | Php教程 | Jsp教程 | Linux教程 | QQ技巧  
Photoshop Illustrator ImageReady Maya教程 3D Max教程 Lightscape Coredraw教程 Authorware Autocad教程 Freehand教程
Access教程 Mysql教程 Sql server Oracle教程 Word教程 Excel教程 Powerpoint Frontpage Asp.net源码 Php源代码
Flash教程 Fireworks Dreamweaver C#教程 outlook教程 系统安装 vbscript教程 Javascript Jsp源代码 Asp源代码
您的位置:首页 >> delphi教程 >> 正文

Delphi学习:查句柄知多少
文章来源:csdn 作者:pggpjj

 基本上句柄是标志窗口,我可以根据句柄又可引申其中更多如类名,windowtitle等属性所以基于这点,一般开发工具会提供查句柄,查类名等工具,vs提供的spy++就是一个很好例子。现在教你们一查句柄知多少。其实也简单,下面贴出源代码。


  procedure Tform1.TimerTimer(Sender: TObject);
   var
   Pos: TPoint;
   Handle: HWND;
   ScreenDC: HDC;
   Buf: array[0..1024] of Char;
   ScreenColor: COLORREF;
   begin
   GetCursorPos(Pos); // 得到当前光标位置
   Handle := WindowFromPoint(Pos); // 返回当前位置的句柄
   HandleText.Caption := IntToStr(Handle);
   GetClassName(Handle, Buf, 1024); // 得到类名
   ClassNameText.Caption := Buf;
   SendMessage(Handle, WM_GETTEXT, 33, Integer(@Buf)); // 得到标题
   TitleText.Caption := Buf;
   { 得到光标处点的颜色 }
   ScreenDC := GetDC(0);
   ScreenColor := GetPixel(ScreenDC, Pos.X, Pos.Y);
   Shape.Brush.Color := TColor(ScreenColor);
   RGBColorText.Caption := '红: ' + IntToStr(GetRValue(ScreenColor)) +
   '  绿: ' + IntToStr(GetGValue(ScreenColor)) + '  蓝: ' +
   IntToStr(GetBValue(ScreenColor));
   ReleaseDC(0, ScreenDC);
   DelphiColorText.Caption := Format('Delphi中颜色值:$00%2.2x%2.2x%2.2x', [GetBValue(ScreenColor),
   GetGValue(ScreenColor), GetRValue(ScreenColor)]);
   HTMLColorText.Caption := Format('HTML颜色值:#%2.2x%2.2x%2.2x', [GetRValue(ScreenColor),
   GetGValue(ScreenColor), GetBValue(ScreenColor)]);
   end; 

[返回]

     

首页 | 设为首页 | 加入收藏 | 关于本站 | 友情链接 | 版权声明

     
 
Copyright© www.bianceng.cn Powered by 编程入门网 All Rights Reserved
吉ICP备06005558号