Delphi学习:查句柄知多少
添加时间: 2006-2-25 5:10:10 作者: Delphi教程 阅读次数:79 来源: http://www.d9soft.com
| 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; |
上下文章:
上一篇文章: 用Delphi检测IE使用的代理服务器 下一篇文章: Delphi学习:OOP 中的双刃剑
相关文章:

