Search results for 'GetDeviceCaps'. 3 post(s) found.
- 2007/09/11 TDesktopCanvas - draw on Windows Desktop
- 2007/09/11 How to Convert Pixels to Millimeters
- 2007/09/11 How to capture Windows Desktop to Bitmap
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;
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;
Another posts included in "Delphi"
| TImage.Bitmap fade out (0) | 2007/09/11 |
| Rotate Bitmap (any angle, any center of rotation) (0) | 2007/09/11 |
| Are we connected to the Internet? (0) | 2007/09/18 |
| TColor to HTML color (0) | 2007/09/11 |
| Show *any* graphics as Glyph on a SpeedButton (0) | 2007/09/11 |
| Rotating Text (0) | 2007/09/11 |
| Paint a Form with a tiled bitmap image (0) | 2007/09/11 |
| Is Point in Polygon? (0) | 2007/09/11 |
Trackback : Cannot send a trackbact to this post.
-
Subject Buy vicodin online.
2010/01/20 00:39
Buy vicodin no prescription. Buy vicodin online. Buy vicodin without a prescription. Buy vicodin without script. Buy vicodin. Buy vicodin from mexico.
-
Subject different money making ideas
2010/01/29 02:15
moneyideas
-
Subject different money making ideas
2010/01/29 10:43
moneyideas
-
Subject different money making ideas
2010/01/31 16:39
moneyideas
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;
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;
Another posts included in "Delphi"
| How to convert an ICO to a BMP (0) | 2007/09/11 |
| How to draw rotated text (0) | 2007/09/11 |
| How to draw transparent text on Windows Desktop (0) | 2007/09/11 |
| How to capture Windows Desktop to Bitmap (0) | 2007/09/11 |
| Cut a rectangle from an Image to Clipboard (0) | 2007/09/11 |
| Convert TColor to Hex & Hex to TColor (0) | 2007/09/11 |
| Convert a BMP to a JPG (0) | 2007/09/11 |
| Reading a directory content (0) | 2007/09/10 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/28 23:38
moneyideas
-
Subject different money making ideas
2010/01/29 07:59
moneyideas
-
Subject different money making ideas
2010/01/31 16:39
moneyideas
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;
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;
Another posts included in "Delphi"
| How to Convert Pixels to Millimeters (0) | 2007/09/11 |
| How to convert an ICO to a BMP (0) | 2007/09/11 |
| How to draw rotated text (0) | 2007/09/11 |
| Cut a rectangle from an Image to Clipboard (0) | 2007/09/11 |
| Convert TColor to Hex & Hex to TColor (0) | 2007/09/11 |
| Convert a BMP to a JPG (0) | 2007/09/11 |
| Reading a directory content (0) | 2007/09/10 |
| Path shortener: c:\AB\C...DE\F.ghi (0) | 2007/09/10 |
Trackback : Cannot send a trackbact to this post.
-
Subject different money making ideas
2010/01/25 08:59
moneyideas
-
Subject different money making ideas
2010/01/28 22:17
moneyideas
-
Subject different money making ideas
2010/01/29 06:38
moneyideas
-
Subject different money making ideas
2010/01/31 16:39
moneyideas

Prev

Rss Feed