Search results for 'GetDeviceCaps'. 3 post(s) found.

  1. 2007/09/11 TDesktopCanvas - draw on Windows Desktop
  2. 2007/09/11 How to Convert Pixels to Millimeters
  3. 2007/09/11 How to capture Windows Desktop to Bitmap
2007/09/11 08:01

TDesktopCanvas - draw on Windows Desktop


This canvas class allows you to access the Windows Desktop, and draw on it.

type
   TDesktopCanvas = class(TCanvas)
   private
     DC : hDC;
     function GetWidth:Integer;
     function GetHeight:Integer;
   public
     constructor Create;
     destructor Destroy; override;
   published
     property Width: Integer read GetWidth;
     property Height: Integer read GetHeight;
   end;

{ TDesktopCanvas object }
function TDesktopCanvas.GetWidth:Integer;
begin
   Result:=GetDeviceCaps(Handle,HORZRES) ;
end;

function TDesktopCanvas.GetHeight:Integer;
begin
   Result:=GetDeviceCaps(Handle,VERTRES) ;
end;

constructor TDesktopCanvas.Create;
begin
   inherited Create;
   DC := GetDC(0) ;
   Handle := DC;
end;

destructor TDesktopCanvas.Destroy;
begin
   Handle := 0;
   ReleaseDC(0, DC) ;
   inherited Destroy;
end;
Trackback 4 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Buy vicodin online.

    Tracked from Buy cheap no prescription vicodin. 2010/01/20 00:39 delete

    Buy vicodin no prescription. Buy vicodin online. Buy vicodin without a prescription. Buy vicodin without script. Buy vicodin. Buy vicodin from mexico.

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 02:15 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 10:43 delete

    moneyideas

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:39 delete

    moneyideas

2007/09/11 07:44

How to Convert Pixels to Millimeters


If you need to convert pixel value to millimeters (inches, centimeters, etc.) use the code provided here.

The code uses the API function GetDeviceCaps to get the metrics you need.

procedure PixelsPerMM(
   canvas: TCanvas;
   var x, y: single) ;
var
    H:HDC;
    hres,vres,
    hsiz,vsiz:integer;
begin
    H:=canvas.handle;
    hres := GetDeviceCaps(H,HORZRES) ; {display width in pixels}
    vres := GetDeviceCaps(H,VERTRES) ; {display height in pixels}
    hsiz := GetDeviceCaps(H,HORZSIZE) ; {display width in mm}
    vsiz := GetDeviceCaps(H,VERTSIZE) ; {display height in mm}
    x := hres/hsiz;
    y := vres/vsiz;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 23:38 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 07:59 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:39 delete

    moneyideas

2007/09/11 07:43

How to capture Windows Desktop to Bitmap


Here's a piece of Delphi code capable of capturing the Windows Desktop image into a TBitmap object:

procedure ScreenShot(DestBitmap : TBitmap) ;
var
  DC : HDC;
begin
  DC := GetDC (GetDesktopWindow) ;
  try
  DestBitmap.Width := GetDeviceCaps (DC, HORZRES) ;
  DestBitmap.Height := GetDeviceCaps (DC, VERTRES) ;
  BitBlt(DestBitmap.Canvas.Handle,
         0,
         0,
         DestBitmap.Width,
         DestBitmap.Height,
         DC,
         0,
         0,
         SRCCOPY) ;
  finally
  ReleaseDC (GetDesktopWindow, DC) ;
  end;
end;
Trackback 4 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/25 08:59 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 22:17 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:38 delete

    moneyideas

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:39 delete

    moneyideas