CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Screen Capture into Clipboard?

    Hi,
    I can't seem to capture my desktop screen and copy it into the clipboard.
    When I look at the clipboard the image is totally garbled (black & blue stripes).
    Can someone please point out to me what I'm doing wrong or show me
    a better way of doing this? I did the following:

    <ccode>
    HBITMAP hBitmap;
    OpenClipboard(hwin); // hwin is my window handle
    HDC hDCSrc = GetDC(NULL); // get entire window device context
    hBitmap = CreateCompatibleBitmap((HDC) hDCSrc, 640, 480);
    SetClipboardData(CF_BITMAP, hBitmap);
    ReleaseDC(NULL, hDCSrc);
    CloseClipboard();
    </ccode>



  2. #2
    Guest

    Re: Screen Capture into Clipboard?

    It appears you may have a type conversion problem.
    Check ---> hBitmap = CreateCompatibleBitmap((HDC) hDCSrc, 640, 480);
    (what type does this function return?)


  3. #3
    Guest

    Re: Screen Capture into Clipboard?


    > Check ---> hBitmap = CreateCompatibleBitmap((HDC) hDCSrc, 640, 480);
    > (what type does this function return?)
    It returns an HBITMAP which is what hBitmap is. But the next line:
    SetClipboardData(CF_BITMAP, hBitmap) --> the 2nd param is expected to be of HANDLE type.
    I pass in an HBITMAP type but if I understand the documentation correctly, this should be ok...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured