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 910759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:05:35+00:00 2026-05-15T17:05:35+00:00

I am using GDI+ to take window snapshot, the code is: CComBSTR bstrfname (fname);

  • 0

I am using GDI+ to take window snapshot, the code is:

CComBSTR bstrfname (fname); 

HDC hdc = CreateCompatibleDC (hDC); 
HBITMAP hbmp = CreateCompatibleBitmap (hDC, CFG_WIDTH, CFG_HEIGHT); 
HBITMAP hbmp0 = (HBITMAP)SelectObject (hdc, hbmp); 
BitBlt (hdc, 0, 0, CFG_WIDTH, CFG_HEIGHT, hDC, 0, 0, SRCCOPY); 

Gdiplus::Bitmap *bmp = new Gdiplus::Bitmap (hbmp, NULL); 
CLSID encoderClsid; GetEncoderClsid (L"image/png", &encoderClsid); 
bmp->Save (bstrfname, &encoderClsid, NULL); 
delete bmp; 

SelectObject (hdc, hbmp0); 
DeleteObject (hbmp); 
DeleteDC (hdc); 

where hDC is set before with:

hWnd=CreateWindowEx(...); hDC=GetDC(hWnd); 

this works perfectly for small windows, but once I try windows bigger
than screen.

i.e. taskbar is getting saved too. what gives?

  • 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-05-15T17:05:35+00:00Added an answer on May 15, 2026 at 5:05 pm

    This is normal, a screen-shot like this gives you exactly what you are looking at on your monitor. Including the taskbar. You will need to restrict the area you capture to the bounds of the window you want to capture. Use GetWindowRect() and adjust the size of the bitmap and the arguments you pass to BitBlt() accordingly.

    PrintWindow can only work if the target window implements the WM_PRINT and WM_PRINTCLIENT message. Easy to implement but often overlooked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a library that draw on to given HDC using GDI+ apis. I
I noticed using task manager that the following code has a GDI leak in
I'm currently doing some tests using Cairo to replace some existing GDI/GDI+ code in
I'm painting this object in C# using GDI and I need to have precise
Someone can give me short explanation how to create bitmap runtime using GDI/GDI+ and
I'm developing a graph control in WPF. I have previously developed it using GDI
im trying to create ball animation using gdi but i can't get it working.
ok im trying to create cursor using gdi. i can't even find tutorial how
I'm making a Win32 application with OpenGL in the main window (not using GLUT).
It seems that .NET can't open JP2 (Jpeg 2000) files using the GDI library.

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.