我知道VC里有个getpix什么的函数,但不知在DELPHI中有没有相同的函数,是什么名字。
不是说是某个控件,而是说显示器的屏幕上的某个点。

解决方案 »

  1.   

    if (screen.width>800) then
         TForm(frm).Position:=poDesktopCenter
      else if (screen.width<=800) then
         TForm(frm).WindowState :=wsMaximized;
      

  2.   

    用一变量hnd:=GetDesktopWindow()得到屏幕的句并
    在用一变量dc:=getdc(hnd)将得到桌面的HDC
    在用GetPixel(dc) 得到颜色值就可以了
      

  3.   

    var
    Dc: HDC;
    MyCanvas: TCanvas;
    MyRect: TRect;
    Bmp: TBitmap
    begin
    Dc := GetWindowDC(0);
    MyCanvas := TCanvas.Create;
    try
    MyCanvas.Handle := Dc;
    MyRect:=Rect(0,0,Screen.Width, Screen.Height);
    Bmp.PixelFormat := pf24bit;
    Bmp.Width := MyRect.Right;
    Bmp.Height := MyRect.Bottom;
    Bmp.Canvas.CopyRect(MyRect, MyCanvas, MyRect);
    Bmp.Canvas.Pixels[X,Y] ;
      

  4.   

    应该是getcursorpix这个API吧
    记不清了
      

  5.   

    procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    var 
    DC:HDC; 
    X,Y:Integer; 
    begin 
    X:=Mouse.CursorPos.X; 
    Y:=Mouse.CursorPos.Y; 
    if Key<>VK_Return then Exit; 
    DC:=GetDC(0); 
    Color:=GetPixel(DC,X,Y); 
    end; 
      

  6.   

    补一句,如果你要得到的WINDOWS的DC是在整个WINDOW的,请用GETWINDOWDC函数,如果你用的是WINDOW的client区域,就用GETDC
      

  7.   

    GetPixel(dc)---》应该这么用我写错了getpixel(dc,x,y)
      

  8.   

    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      dc:hdc;
      hnd:hwnd;
      p:Tpoint;
    begin
      hnd:=getdesktopwindow(); //
      dc:=getwindowdc(hnd);    //
      //上面的2句也可以写成dc:=getwindowdc(0)
      windows.GetCursorPos(p);
      label1.caption:=inttostr(getpixel(dc,p.X,p.Y));
      releasedc(handle,dc);
    end;
    我写了一个给你,你要在窗体上放个timer,设置interval小点,为50
      

  9.   

    先谢谢你们!!!
    但是,
    不能直接调用getpixel()这个API函数吗?
    HDC是什么?
      

  10.   

    COLORREF GetPixel(
        HDC hdc, // handle of device context  
        int XPos, // x-coordinate of pixel 
        int nYPos  // y-coordinate of pixel 
       );
    这个函数就是直接调用GDI里面API的。