屏幕取色DELPHI源码
http://www.csdn.net/cnshare/soft/openfile.asp?kind=1&id=5441

解决方案 »

  1.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var mousepos:tpoint;
    var handle:hwnd;
    var color:tcolor;
    var dc:hdc;
    begin
    getcursorpos(mousepos);
    handle:=getdesktopwindow;
    dc:=getwindowdc(handle);
    color:=getpixel(dc,mousepos.x,mousepos.y);
    label1.color:=rgb(getrvalue(color),getgvalue(color),getbvalue(color));
    releasedc(handle,dc);
    end;
    把timer控件的interval值改小一些,效果就可以了
      

  2.   

    很容易啊,看下面代码:  TPoint CurPos,WinCurPos;
      TColor MouseColor;
      TRect WinRect;
      COLORREF CurPixel;
      int RV,GV,BV;
      HWND WindowHandle;  GetCursorPos(&CurPos);
      WindowHandle=WindowFromPoint(CurPos);  // Get Position
      GetWindowRect(WindowHandle,&WinRect);
      WinCurPos.x=CurPos.x - WinRect.Left;
      WinCurPos.y=CurPos.y - WinRect.Top;  // Get Color
      CurPixel=GetPixel(GetWindowDC(WindowHandle),WinCurPos.x,WinCurPos.y);  MouseColor=(TColor)CurPixel;  RV=GetRValue(CurPixel);
      GV=GetGValue(CurPixel);
      BV=GetBValue(CurPixel);
      

  3.   

    GetRValue,GetGValue,GetBValue, 返回颜色的R,G, B值,
      

  4.   

    同意 zhuxud(圣东方) ,但可以更简单:handle 用 0就行了,或者 hdc:=GetDC(0);
      

  5.   

    R := Color and $ff;
    G := (Color and $ff00) shr 8;
    B := (Color and $ff0000) shr 16;
    取出RGB的值
      

  6.   

    我没有用过zhuxud(圣东方) 的代码,不过它利用GetDesktopWindow函数,要是
    鼠标在程序窗口上,你怎么办??? 所以我用WindowFromPoint函数得到鼠标底下的窗口,不知对否???
      

  7.   

    BCB_FANS我试了,完全可以啊!