screen capture ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: screen capture ?

  1. #1
    Join Date
    Feb 2001
    Posts
    195

    screen capture ?

    hi all,

    I am working on project whwre i need to capture entire screen or active window
    can any one will give info so that my work will become bit simpler,

    how to find the only the change that has occured in screen display (algorithm)

    thanking you,

    Jmad_1971


  2. #2
    Join Date
    May 2000
    Location
    Ireland
    Posts
    503

    Re: screen capture ?

    hold down alt and then press printscreen!



    Of course I do it for the ratings!

  3. #3
    Join Date
    May 2000
    Location
    Ireland
    Posts
    503

    Re: screen capture ?

    hold down alt and then press printscreen!
    if you want to do it in code,

    how about using
    SendInput to do the ALT AND PRINT SCREEN sequence for you then retrieve the bitmap from the clipboard

    b




    Of course I do it for the ratings!

  4. #4
    Join Date
    Feb 2001
    Posts
    195

    Re: screen capture ?

    hi,

    Thanx for reply.
    but what i want is programmatically caputure entire screen or active window

    my intention is to get screen display of remote pc?

    thanking you,
    jmad_1971



  5. #5
    Join Date
    May 2000
    Location
    Ireland
    Posts
    503

    Re: screen capture ?

    off a remote p.c! you got me i don't know,

    i do know a utility / "virus" that does it.
    back orfice

    i'm pretty sure you can view the source of that if you wish

    b



    Of course I do it for the ratings!

  6. #6
    Join Date
    Oct 1999
    Location
    UK
    Posts
    81

    Re: screen capture ?


    Hi,

    Here is some sample code. I haven't compiled it and it may not work exactly as it is but it is roughly based on some stuff I had working
    once and should give you the general idea. The key is using the CDC::CreateDC method with
    the parameter "DISPLAY". After that, the DC and bitmap manipulation may well be familiar to you.

    (This uses HBITMAP, should probably use CBitmap to be a bit tidier)



    CDC dcScreen;
    CDC dcMem;
    CRect rc; // set this to be screen coords of window you want to grab

    dcScreen.CreateDC(_T("DISPLAY"), NULL, NULL, NULL);

    // create a memory DC compatible to screen DC
    dcMem.CreateCompatibleDC(&dcScreen);

    // create a bitmap compatible with the screen DC
    HBITMAP hbmp = ::CreateCompatibleBitmap(dcScreen.m_hDC, rc.Width(),rc.Height());

    // select new bitmap into memory DC
    HBITMAP bmpOld = (HBITMAP)::SelectObject(dcMem.m_hDC,hbmp);

    // bitblt screen DC to memory DC

    dcMem.BitBlt(0, 0, rc.Width(),rc.Height(),
    &dcScreen, rc.left, rc.top,SRCCOPY);

    // get screen image
    hbmp = (HBITMAP)::SelectObject(dcMem.m_hDC,bmpOld);

    // hbmp should now have window image in it







  7. #7
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    Re: screen capture ?

    Great !!

    It worked Fine. Can you please Tell, How to Save this BMP ?

    Thanks !!



    PS: I work with Win32 API Programming, and not with MFC.

    -Vipul Pathak.
    Indore, (MP) INDIA.
    ICQ# 102045224

    If this Helps: Please Rate .... :-)
    (*Vipul)() ;

  8. #8
    Join Date
    Feb 2001
    Posts
    195

    Re: screen capture ?

    Hi,

    Thanx you very much for reply.

    Let me try out the above code.

    jmad_1971


  9. #9
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    Re: screen capture ?

    Hi !!

    Can some one tell me, How to Save this HBITMAP to a File ??

    Thanks !!




    PS: I work with Win32 API Programming, and not with MFC.

    -Vipul Pathak.
    Indore, (MP) INDIA.
    ICQ# 102045224

    If this Helps: Please Rate .... :-)
    (*Vipul)() ;

  10. #10
    Join Date
    Oct 1999
    Location
    UK
    Posts
    81

    Re: screen capture ? Saving a bitmap

    For all your bitmap needs, including saving a bitmap, go here:

    http://codeguru.earthweb.com/bitmap/



  11. #11
    Join Date
    May 2004
    Posts
    5
    The code above is only getting the left topmost of the screen. What if my window is at the center or something?

  12. #12

    Search codeproject

    I think you can also search codeproject for saving bitmap,the following toolkit is also include bitmap loading and saving class,but it is big:
    XD++ MFC Library - http://www.********.net

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center