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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:41:46+00:00 2026-05-26T23:41:46+00:00

I apologize upfront; I’m new to c and I really don’t know what I’m

  • 0

I apologize upfront; I’m new to c and I really don’t know what I’m doing.

I am trying to capture and display a screen shot using Windows 7 and c. I know it sounds dumb, eventually I will need each of these functions in different programs, the one that captures the screen will send the image to the one that displays it but for now I am just trying to get them both to work in one program. Here is the code I’ve put together so far:

     #include <windows.h>

bool ScreenCapture(int x, int y, int width, int height){
// get a DC compat. w/ the screen
HDC hDc = CreateCompatibleDC(0);

// make a bmp in memory to store the capture in
HBITMAP hBmp = CreateCompatibleBitmap(GetDC(0), width, height);

// join em up
SelectObject(hDc, hBmp);

// copy from the screen to my bitmap
BitBlt(hDc, 0, 0, width, height, GetDC(0), x, y, SRCCOPY);

HDC myhDc = GetDC(hBitmap, sizeof(BITMAP), (LPSTR)&Bitmap);

BitBlt(myhDc, 0, 0, width, height, hDc, x, y, SRCCOPY);

//Display bitmap
DrawBitmap(myhDC,0,0,hBmp,SRCCOPY);

//GetDC(hBitmap, sizeof(BITMAP), (LPSTR)&Bitmap);

// free the bitmap memory
DeleteObject(hBmp);

return 0;
}

int main(){
ScreenCapture(500, 200, 300, 300);
system("pause");
}

I just haven’t been able to find any way to display the HBITMAP. How do I display the HBITMAP?

Update: I added DrawBitmap but it isn’t working… I am getting the following output and am not sure how to process it:

‘win_screenshot.exe’: Loaded ‘C:\Users\mbrooker\Documents\Visual Studio 2010\Projects\win_screenshot\Debug\win_screenshot.exe’, Symbols loaded.
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\ntdll.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\kernel32.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\KernelBase.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\user32.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\gdi32.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\lpk.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\usp10.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcrt.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\advapi32.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\sechost.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\rpcrt4.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\sspicli.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\cryptbase.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\msvcr100d.dll’, Symbols loaded.
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\imm32.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\msctf.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘C:\Windows\SysWOW64\apphelp.dll’, Cannot find or open the PDB file
‘win_screenshot.exe’: Loaded ‘ImageAtBase0x4ab60000’, Loading disabled by Include/Exclude setting.
‘win_screenshot.exe’: Unloaded ‘ImageAtBase0x4ab60000’
The program ‘[1480] win_screenshot.exe: Native’ has exited with code 0 (0x0).

  • 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-26T23:41:47+00:00Added an answer on May 26, 2026 at 11:41 pm

    Displaying a HBITMAP would involve blitting it (e.g. via BitBlt) into another DC. In a way similar to what you are already doing, just to another DC, which might be for example window’s DC, see GetDC.

    MSDN provides you with sample code: Scaling an Image, see DrawBitmap function.

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

Sidebar

Related Questions

I apologize in advance if my question is not clear, because I don't know
I'm new and apologize upfront. I've searched for sample code and tutorials on the
I apologize upfront for my lack of jquery knowledge. In this website I am
I am a novice programmer and apologize upfront for the complicated question. I am
Apologize if i am wrong, i am new to metro apps i need multiple
i apologize in advance for not being very precise, as a i dont know
Apologize because for the moment I don't have the environment to experiment and sort
I'm new to programming and apologize up front if I misuse terminology. In a
I apologize but I am new to programming and I'm having difficulty coding a
So I'm trying to setup a multiple choice quiz via Python. I'm fairly new

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.