Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:27:06+00:00 2026-06-09T06:27:06+00:00

I have an application that has drawn a grid using CDC (it has text,

  • 0

I have an application that has drawn a grid using CDC (it has text, rectangle, and bitmaps). I want to take a screenshot of that finished grid when it is saved and use that screenshot as a “preview” for the file.

How can I take a screenshot of my application and save it?

Thank you,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:27:07+00:00Added an answer on June 9, 2026 at 6:27 am

    Ultimately I ended up doing it this way because I wanted to capture even the hidden parts of the window (since the content extends beyond the screen and requires scrolling):

    CDC* WindowToCaptureDC = AfxGetMainWnd()->GetWindowDC();
    CDC CaptureDC;
    CDC MemDC;
    MemDC.CreateCompatibleDC(WindowToCaptureDC);
    CaptureDC.CreateCompatibleDC(WindowToCaptureDC);
    
    CBitmap CaptureBmp;
    CBitmap ResizeBmp;
    int pWidth = grid.tableWidth + grid.marginLeft*2;
    int pHeight = grid.tableHeight + grid.marginBottom; 
    
    CaptureBmp.CreateCompatibleBitmap( WindowToCaptureDC, pWidth, pHeight);
    CaptureDC.SelectObject(&CaptureBmp);
    
    CBrush brush(RGB(255, 255, 255));
    CaptureDC.SelectObject(&brush);
    CaptureDC.Rectangle(0, 0, pWidth, pHeight);
    

    ///Drew items into CaptureDC like I did for OnDraw HERE///

    double width = //desired width;
    double height = //desired width;
    
        //maintain aspect ratio
    if(pWidth!=width || pHeight!=height)
    {
        double w = width/pWidth;
        double h = height/pHeight;
        if(w < h)
            height = height*w;
        else
            width = width*h;
    }
    
    ResizeBmp.CreateCompatibleBitmap(WindowToCaptureDC, width, height);
    MemDC.SelectObject(&ResizeBmp);
    
    MemDC.StretchBlt(0, 0, width, height, &CaptureDC, 0, 0, pWidth, pHeight, SRCCOPY);
    
    CImage TempImageObj;
    TempImageObj.Attach((HBITMAP)ResizeBmp.Detach());
    CString filePath = _T("LOCATION\\image.bmp");
    TempImageObj.Save(filePath);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has 2 beans with the same name, but which
We have an application that has a database full of polygons (currently stored as
I have a application that has an activity that shows message logs. The thing
I have an application that has two localization options at the moment through .resx
I have an application that has two threads. The first one (the main thread)
i have an application that has a dependancy on gdiplus. i need the application
I have an application that has a list of buttons and has customized tooltips.
I have an application that has a .sql file in it. The sql file
We have an application that has a WCF service (*.svc) running on IIS7 and
I have an application that has a UILabel displaying the current date and time,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.