求救啊,我想读取某程序窗口内某点颜色并显示在我的界面上

solarfeiyang 2013-10-23 08:57:32
我想做一个窗口程序,来实时的反应某程序窗口某点上的颜色,该如何做啊。
...全文
119 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
confucius 2013-10-25
  • 打赏
  • 举报
回复
procedure TfrmMain.FormCreate(Sender: TObject); var MRect: TRect; begin SystemParametersInfo(SPI_GETWORKAREA, 0, @MRect, 0); Left := MRect.Right - Width; Top := MRect.Bottom - Height; end; procedure TfrmMain.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); edtRGBColor.Text := '红:' + IntToStr(GetRValue(ScreenColor)) + ' 绿:' + IntToStr(GetGValue(ScreenColor)) + ' 蓝:' + IntToStr(GetBValue(ScreenColor)); ReleaseDC(0, ScreenDC); edtHtmlColor.Text := Format('#%2.2x%2.2x%2.2x', [GetRValue(ScreenColor), GetGValue(ScreenColor), GetBValue(ScreenColor)]); edtColor.Text := Format('$%2.2x%2.2x%2.2x', [GetBValue(ScreenColor), GetGValue(ScreenColor), GetRValue(ScreenColor)]); end;
鐵蛋 2013-10-24
  • 打赏
  • 举报
回复
GetPixel

5,928

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧