Re: Screenshot
Joachim Mohr wrote:
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
bool ScreenShot(int x, int y, int Width, int Height,
TBitMap& bm)
{
dc: HDC;
lpPal : PLOGPALETTE;
begin
{HFhe und Breite testen}
// HFhe und Breite testen
result := false;
bool result = false;
if ((Width <= 0) OR
if (Width <= 0 or
(Height <= 0)) then begin
Height <= 0) {
result := true;
exit;
return true;
end;
}
bm.Width := Width;
bm.Height := Height;
bm.Width = Width;
bm.Height = Height;
{ScreenDC holen}
// ScreenDC holen
dc := GetDc(0);
HDC dc = GetDC(0);
if (dc = 0) then begin
if (dc == 0) {
result := true;
exit;
return true;
end;
}
if (GetDeviceCaps(dc, RASTERCAPS) AND
if (GetDeviceCaps(dc, RASTERCAPS) and
RC_PALETTE = RC_PALETTE) then begin
RC_PALETTE == RC_PALETTE) { // WHAT??? A==A?
GetMem(lpPal, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)));
FillChar(lpPal^, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)), #0);
lpPal = GlobalAlloc(sizeof(TLOGPALETTE) + 255 *
sizeof(TPALETTEENTRY), GMEM);
(or something like that, ask in a Windows newsgroup)
lpPal^.palVersion := $300;
lpPal->palVersion = 0x300;
lpPal^.palNumEntries :=GetSystemPaletteEntries(dc,
0, 256, lpPal^.palPalEntry);
lpPal->palNumEntries = GetSystemPaletteEntries(dc, 0, 256,
lpPal->palPalEntry);
if (lpPal^.PalNumEntries <> 0) then begin
if (lpPal->PalNumEntries != 0) {
bm.Palette := CreatePalette(lpPal^);
bm.Palette = CreatePalette(lpPal);
end;
}
FreeMem(lpPal, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)));
GlobalFree(lpPal);
end;
}
BitBlt(bm.Canvas.Handle, 0, 0, Width, Height, Dc,
x, y, SRCCOPY);
BitBlt(bm.Canvas.Handle, 0, 0, Width, Height, dc, x, y, SRCCOPY);
ReleaseDc(0, dc);
ReleaseDC(dc, 0);
end;
}
I am sure it won't work the first time, you'll need to tweak it.
I charge $200/hr, although my availability is limited.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask