Screenshot

J

Joachim Mohr

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
{Höhe 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;
 
V

Victor Bazarov

Joachim said:
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
{Höhe und Breite testen}

// Höhe 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;

}
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;

}
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);

}
FreeMem(lpPal, sizeof(TLOGPALETTE) +
(255 * sizeof(TPALETTEENTRY)));

GlobalFree(lpPal);

}
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);

}

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
 
S

Sohail Somani

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.

Aren't you supposed to charge first?
 
J

Johannes Bauer

Victor said:
if (Width <= 0 or

Is there any reason why C++ introduces "and", "or" and "not" keywords
instead of the beautful &&, || and ! ones?

Greetings,
Johannes
 
V

Victor Bazarov

Johannes said:
Is there any reason why C++ introduces "and", "or" and "not" keywords
instead of the beautful &&, || and ! ones?

Not "instead", "along". And the answer is, convenience, I guess.

V
 
E

Erik Wikström

Is there any reason why C++ introduces "and", "or" and "not" keywords
instead of the beautful &&, || and ! ones?

You can use || if you want, I believe that Victor used or simply to make
the code more similar to the original.
 
J

Jim Langston

Erik Wikström said:
You can use || if you want, I believe that Victor used or simply to make
the code more similar to the original.

Yes, that was my feeling too. That and would be more familiar to someone
used to Pascal than &&. You can use either in C++.
 
D

Default User

Victor said:
Not sure what you mean.

I think he meant, "why post your rates after you've given the answer."
Naturally, your initial one was a free intro, and the "tweaks" are what
will cost.



Brian
 
V

Victor Bazarov

Default said:
I think he meant, "why post your rates after you've given the answer."
Naturally, your initial one was a free intro, and the "tweaks" are
what will cost.

Yes, that's how I intended it. Imagine if we charged for every answer
we give here... What's that saying, "if I had a nickel every time I
heard that"?

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top