两年前, 我做过一段时间的iOS开发, 我记得自己用过这样一个工具: 该工具可以实时显示鼠标所在位置的像素值。 下面, 我自己用BCB来做一个这样的工具, 代码如下(定时时间间隔为10ms):
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
HDC hDC = GetWindowDC(NULL);
TPoint Pos = Mouse->CursorPos;
COLORREF nColor = GetPixel(hDC, Pos.x, Pos.y);
ReleaseDC(NULL, hDC);
BYTE R = GetRValue(nColor);
BYTE G = GetGValue(nColor);
BYTE B = GetBValue(nColor);
Label1->Caption

本文介绍了如何利用BCB(Borland C++ Builder)创建一个工具,该工具能够实时显示鼠标指针所在位置的像素颜色值。作者借鉴了之前在iOS开发中的类似经验,分享了自己的BCB实现代码,其采用10毫秒的定时更新间隔。
4530

被折叠的 条评论
为什么被折叠?



