Screenshot
Hi!
I'm a programmer in Delphi (and not good in English).
But a friend asked me for a proceure in C++
for a part of then Screen.
In Delphi is the proceure: show button.
I'm seraching for the aequivalent in C++.
THx Joachim
- - - - Procedure in Delphi - - -
function ScreenShot(x, y ,Width, Height: integer; bm: TBitMap):boolean;
var
dc: HDC;
lpPal : PLOGPALETTE;
begin
{HFhe und Breite testen}
result := false;
if ((Width <= 0) OR
(Height <= 0)) then begin
result := true;
exit;
end;
bm.Width := Width;
bm.Height := Height;
{ScreenDC holen}
dc := GetDc(0);
if (dc = 0) then begin
result := true;
exit;
end;
if (GetDeviceCaps(dc, RASTERCAPS) AND
RC_PALETTE = RC_PALETTE) then begin
GetMem(lpPal, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)));
FillChar(lpPal^, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)), #0);
lpPal^.palVersion := $300;
lpPal^.palNumEntries :=GetSystemPaletteEntries(dc,
0, 256, lpPal^.palPalEntry);
if (lpPal^.PalNumEntries <> 0) then begin
bm.Palette := CreatePalette(lpPal^);
end;
FreeMem(lpPal, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)));
end;
BitBlt(bm.Canvas.Handle, 0, 0, Width, Height, Dc,
x, y, SRCCOPY);
ReleaseDc(0, dc);
end;
--
Joachim Mohr TLbingen
http://www.joachimmohr.de/neu.html