Screenshot

Discussion in 'C++' started by Joachim Mohr, Nov 27, 2007.

  1. Joachim Mohr

    Joachim Mohr Guest

    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;


    --
    Joachim Mohr Tübingen
    http://www.joachimmohr.de/neu.html
     
    Joachim Mohr, Nov 27, 2007
    #1
    1. Advertising

  2. 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
    > {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;

    > 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
     
    Victor Bazarov, Nov 27, 2007
    #2
    1. Advertising

  3. On Tue, 27 Nov 2007 12:42:40 -0500, Victor Bazarov wrote:

    > 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?

    --
    Sohail Somani
    http://uint32t.blogspot.com
     
    Sohail Somani, Nov 27, 2007
    #3
  4. Sohail Somani wrote:
    > On Tue, 27 Nov 2007 12:42:40 -0500, Victor Bazarov wrote:
    >
    >> 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?


    Not sure what you mean.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 27, 2007
    #4
  5. On Tue, 27 Nov 2007 13:21:55 -0500, Victor Bazarov wrote:

    > Sohail Somani wrote:
    >> On Tue, 27 Nov 2007 12:42:40 -0500, Victor Bazarov wrote:
    >>
    >>> 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?

    >
    > Not sure what you mean.
    >
    > V


    Me either.

    --
    Sohail Somani
    http://uint32t.blogspot.com
     
    Sohail Somani, Nov 27, 2007
    #5
  6. Sohail Somani wrote:
    > On Tue, 27 Nov 2007 13:21:55 -0500, Victor Bazarov wrote:
    >
    >> Sohail Somani wrote:
    >>> On Tue, 27 Nov 2007 12:42:40 -0500, Victor Bazarov wrote:
    >>>
    >>>> 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?

    >>
    >> Not sure what you mean.
    >>
    >> V

    >
    > Me either.


    Then why did you post if you're unsure what you mean?

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 27, 2007
    #6
  7. Victor Bazarov schrieb:

    > if (Width <= 0 or


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

    Greetings,
    Johannes

    --
    "Viele der Theorien der Mathematiker sind falsch und klar
    Gotteslästerlich. Ich vermute, dass diese falschen Theorien genau
    deshalb so geliebt werden." -- Prophet und Visionär Hans Joss aka
    HJP in de.sci.mathematik <4740ad67$0$3811$>
     
    Johannes Bauer, Nov 27, 2007
    #7
  8. Johannes Bauer wrote:
    > Victor Bazarov schrieb:
    >
    >> if (Width <= 0 or

    >
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 27, 2007
    #8
  9. On 2007-11-27 21:20, Johannes Bauer wrote:
    > Victor Bazarov schrieb:
    >
    >> if (Width <= 0 or

    >
    > 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.

    --
    Erik Wikström
     
    Erik Wikström, Nov 27, 2007
    #9
  10. Joachim Mohr

    Jim Langston Guest

    "Erik Wikström" <> wrote in message
    news:Xe%2j.924$...
    > On 2007-11-27 21:20, Johannes Bauer wrote:
    >> Victor Bazarov schrieb:
    >>
    >>> if (Width <= 0 or

    >>
    >> 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.


    Yes, that was my feeling too. That and would be more familiar to someone
    used to Pascal than &&. You can use either in C++.
     
    Jim Langston, Nov 27, 2007
    #10
  11. Joachim Mohr

    Default User Guest

    Victor Bazarov wrote:

    > Sohail Somani wrote:
    > > On Tue, 27 Nov 2007 12:42:40 -0500, Victor Bazarov wrote:
    > >
    > > > 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?

    >
    > 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
     
    Default User, Nov 27, 2007
    #11
  12. Default User wrote:
    > Victor Bazarov wrote:
    >
    >> Sohail Somani wrote:
    >>> On Tue, 27 Nov 2007 12:42:40 -0500, Victor Bazarov wrote:
    >>>
    >>>> 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?

    >>
    >> 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.


    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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 27, 2007
    #12
  13. Joachim Mohr

    Joachim Mohr Guest

    Joachim Mohr, Nov 28, 2007
    #13
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron

    screenshot

    Aaron, Oct 5, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    597
    Scott
    Oct 6, 2004
  2. Paul Aspinall

    Click to see full size screenshot

    Paul Aspinall, Mar 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    313
    Brock Allen
    Mar 20, 2005
  3. antoine c.

    java applet screenshot

    antoine c., Aug 12, 2004, in forum: Java
    Replies:
    2
    Views:
    8,598
    Andrew Thompson
    Aug 13, 2004
  4. Luigi Donatello Asero

    Re: Please criticize my website.: with screenshot

    Luigi Donatello Asero, Oct 4, 2005, in forum: HTML
    Replies:
    1
    Views:
    330
    dorayme
    Oct 4, 2005
  5. Replies:
    4
    Views:
    620
Loading...

Share This Page