Capture The Screen

Help making simple screenshots.

Page 1 of 1

5 Replies - 2009 Views - Last Post: 02 June 2010 - 07:52 AM Rate Topic: -----

#1 Terifire  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-May 10

Capture The Screen

Posted 01 June 2010 - 12:29 PM

Hi,

I'm a beginning programmer, and as one of my first windows application, I came up with the idea to write an application that creates a bitmap from the entire screen, then saves it as a .bmp file on the harddrive when you press a button the the GUI. I'm just not really sure how to do this.

The compiler/programming environment I'm using is Visual Studio C++ 2008 express, and I've started this project as a windows forms application.

So far I've found out I should use the GDI win32 API, and a function called BitBlt, but I'm just not really sure where to go from there. I have included gdiplus.h and gdiplus.lib.

I would really appreciate it if someone could point me in the right direction, because I can not figure out how to capture the screen.

Is This A Good Question/Topic? 0
  • +

Replies To: Capture The Screen

#2 RedSon  Icon User is offline

  • D.I.C Head

Reputation: 56
  • View blog
  • Posts: 179
  • Joined: 01-June 10

Re: Capture The Screen

Posted 01 June 2010 - 12:45 PM

The following example code is from an application that captures an image of the entire desktop, scales it down to the current window size and then saves it to a file.

http://msdn.microsof...28VS.85%29.aspx

MSDN is your friend!
Was This Post Helpful? 1
  • +
  • -

#3 Terifire  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-May 10

Re: Capture The Screen

Posted 01 June 2010 - 01:06 PM

View PostRedSon, on 01 June 2010 - 11:45 AM, said:

The following example code is from an application that captures an image of the entire desktop, scales it down to the current window size and then saves it to a file.

http://msdn.microsof...28VS.85%29.aspx

MSDN is your friend!


I've tried that, not of that works for some reason.

Getting lots of errors about unresolved tokens and unresolved external symbols, and I have no idea what it means.

1>Screenshot.obj : error LNK2028: unresolved token (0A000011) "extern "C" int __stdcall ReleaseDC(struct HWND__ *,struct HDC__ *)" (?ReleaseDC@@$$J18YGHPAUHWND__@@PAUHDC__@@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A000012) "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A000018) "extern "C" int __stdcall GetDIBits(struct HDC__ *,struct HBITMAP__ *,unsigned int,unsigned int,void *,struct tagBITMAPINFO *,unsigned int)" (?GetDIBits@@$$J228YGHPAUHDC__@@PAUHBITMAP__@@IIPAXPAUtagBITMAPINFO@@I@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A00001B) "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject@@$$J18YGPAXPAUHDC__@@PAX@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A00001C) "extern "C" struct HBITMAP__ * __stdcall CreateCompatibleBitmap(struct HDC__ *,int,int)" (?CreateCompatibleBitmap@@$$J212YGPAUHBITMAP__@@PAUHDC__@@HH@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A00001D) "extern "C" int __stdcall SetStretchBltMode(struct HDC__ *,int)" (?SetStretchBltMode@@$$J18YGHPAUHDC__@@H@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A00001E) "extern "C" int __stdcall GetClientRect(struct HWND__ *,struct tagRECT *)" (?GetClientRect@@$$J18YGHPAUHWND__@@PAUtagRECT@@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A00001F) "extern "C" struct HDC__ * __stdcall CreateCompatibleDC(struct HDC__ *)" (?CreateCompatibleDC@@$$J14YGPAUHDC__@@PAU1@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A000020) "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC@@$$J14YGPAUHDC__@@PAUHWND__@@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A000282) "extern "C" int __stdcall GetObjectW(void *,int,void *)" (?GetObjectW@@$$J212YGHPAXH0@Z) referenced in function "extern "C" int __clrcall GetObject(void *,int,void *)" (?GetObject@@$$J0YMHPAXH0@Z)
1>Screenshot.obj : error LNK2028: unresolved token (0A0002F4) "void __clrcall DoScreenShot(void)" (?DoScreenShot@@$$FYMXXZ) referenced in function "private: void __clrcall Screenshot::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Screenshot@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "void __clrcall DoScreenShot(void)" (?DoScreenShot@@$$FYMXXZ) referenced in function "private: void __clrcall Screenshot::Form1::button1_Click(class System::Object ^,class System::EventArgs ^)" (?button1_Click@Form1@Screenshot@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetObjectW(void *,int,void *)" (?GetObjectW@@$$J212YGHPAXH0@Z) referenced in function "extern "C" int __clrcall GetObject(void *,int,void *)" (?GetObject@@$$J0YMHPAXH0@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall ReleaseDC(struct HWND__ *,struct HDC__ *)" (?ReleaseDC@@$$J18YGHPAUHWND__@@PAUHDC__@@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall DeleteObject(void *)" (?DeleteObject@@$$J14YGHPAX@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetDIBits(struct HDC__ *,struct HBITMAP__ *,unsigned int,unsigned int,void *,struct tagBITMAPINFO *,unsigned int)" (?GetDIBits@@$$J228YGHPAUHDC__@@PAUHBITMAP__@@IIPAXPAUtagBITMAPINFO@@I@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" void * __stdcall SelectObject(struct HDC__ *,void *)" (?SelectObject@@$$J18YGPAXPAUHDC__@@PAX@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" struct HBITMAP__ * __stdcall CreateCompatibleBitmap(struct HDC__ *,int,int)" (?CreateCompatibleBitmap@@$$J212YGPAUHBITMAP__@@PAUHDC__@@HH@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall SetStretchBltMode(struct HDC__ *,int)" (?SetStretchBltMode@@$$J18YGHPAUHDC__@@H@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" int __stdcall GetClientRect(struct HWND__ *,struct tagRECT *)" (?GetClientRect@@$$J18YGHPAUHWND__@@PAUtagRECT@@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall CreateCompatibleDC(struct HDC__ *)" (?CreateCompatibleDC@@$$J14YGPAUHDC__@@PAU1@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)
1>Screenshot.obj : error LNK2019: unresolved external symbol "extern "C" struct HDC__ * __stdcall GetDC(struct HWND__ *)" (?GetDC@@$$J14YGPAUHDC__@@PAUHWND__@@@Z) referenced in function "int __clrcall CaptureAnImage(struct HWND__ *)" (?CaptureAnImage@@$$FYMHPAUHWND__@@@Z)




Also I'm not quite sure how to do that inside a form, would it be the same?

This post has been edited by Terifire: 01 June 2010 - 01:17 PM

Was This Post Helpful? 0
  • +
  • -

#4 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1394
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

Re: Capture The Screen

Posted 01 June 2010 - 01:17 PM

Quote

Getting lots of errors about unresolved tokens and unresolved external symbols, and I have no idea what it means.
Then, clearly, the next step in your programming efforts is to Google and understand what the error message is saying. As a programmer, when you encounter something beyond your knowledge, you clearly should take steps to learn the material.
Was This Post Helpful? 2
  • +
  • -

#5 Terifire  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 31-May 10

Re: Capture The Screen

Posted 01 June 2010 - 02:09 PM

View PostOler1s, on 01 June 2010 - 12:17 PM, said:

Quote

Getting lots of errors about unresolved tokens and unresolved external symbols, and I have no idea what it means.
Then, clearly, the next step in your programming efforts is to Google and understand what the error message is saying. As a programmer, when you encounter something beyond your knowledge, you clearly should take steps to learn the material.



Thank you very much. I know it's something I should figure out myself, and I found out it was something to do with the libraries I forgot to use, I was just not sure wich ones.

It compiles now, so that's good. Not quite sure what to do now, but if any other problems come up, or I need any help I'll post the questions here.
Was This Post Helpful? 0
  • +
  • -

#6 RedSon  Icon User is offline

  • D.I.C Head

Reputation: 56
  • View blog
  • Posts: 179
  • Joined: 01-June 10

Re: Capture The Screen

Posted 02 June 2010 - 07:52 AM

It compiles but doesn't link?

The problems you are having are due to your build environment. I hope you didnt just copy over that entire code example that I linked to without first understanding what it did. If you are going to build that code standalone and then use it as a library you need to make sure that library is referenced in your other project.

You really should take some time to understand where the work is actually being done in that sample and then use the 3-4 worker methods that are the real meat of the sample code in your own code.

Understand what the example does before making more copy-pasta.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1