请问如何获取另一个应用程序某个坐标点的颜色代码

ribba 2004-04-13 04:29:50
rt, bcb的。
恳盼高手赐教。
...全文
51 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
gyj_china 2004-04-15
  • 打赏
  • 举报
回复
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
GetCursorPos(&p);
hDC = GetDC(0);

pCanvas->Handle = hDC;
TColor PixelColor = pCanvas->Pixels[p.x][p.y];
Edit1->Color = PixelColor;
Label1->Caption = PixelColor;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
delete pCanvas;
ReleaseDC(0, hDC);
}
lovebcb 2004-04-15
  • 打赏
  • 举报
回复
看个例子,
三个Edit,1个button,1个timer(设false),1个panel

点button后,三个edit中分别显示RGB的值,panel显示颜色

//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
TPoint p;
HDC d;
DWord r;
GetCursorPos(&p);
d=GetDC(0);
r=GetPixel(d,p.x,p.y);
Panel1->Color=TColor(r);
Edit1->Text=IntToStr(GetRValue(r));
Edit2->Text=IntToStr(GetGValue(r));
Edit3->Text=IntToStr(GetBValue(r));
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Timer1->Enabled=True;
Button1->Enabled=False;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{

hotkeyid=GlobalAddAtom("UserDefined")-0xC000;
RegisterHotKey(NULL,hotkeyid,MOD_ALT,26);

}
//---------------------------------------------------------------------------



void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
UnregisterHotKey(NULL,hotkeyid);
DeleteAtom(hotkeyid);
}
//---------------------------------------------------------------------------

void TForm1::WMHotKey(TWMHotKey Msg)
{
if (Msg.HotKey==hotkeyid)
{
Msg.Result=1;
Timer1->Enabled=True;
Button1->Enabled=False;
}
}
SCUM 2004-04-15
  • 打赏
  • 举报
回复

思路:

1。用 FindWindow() WindowFromPoint() 之类的 API 获得那个程序的窗口 HANDLE
2。GetDC() 获得它的 DC
3。GetPixel() 取得 pixel 色彩值



代码就不需要再说了吧




wcccc1 2004-04-15
  • 打赏
  • 举报
回复
来晚了。晕
ribba 2004-04-15
  • 打赏
  • 举报
回复
555,有人可以告诉我怎么做吗

13,824

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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