- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'd like to be able to capture my screen image at the click of a button, create a bitmap, and display it using Paint - in other words, automate the Alt/Print-screen function. I thought I had found the right function for this in SaveImage, but this doesn't work in a Win 32 application. Please can somebidy tell me how to do this.
With many thanks in advance.
Mike
With many thanks in advance.
Mike
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's more complex than that -- this and this MSDN articles explain how and contain sample code.
With wrappers fromXFT Lite library it should be way easier. Briefly:
- Get the window's DC using GetDC (client area) or GetWindowDC (entire window area)
- Fill in hDC member of a X_DC structure.
- Call XSetViewport to set the viewport to appropriate coordinates (xDC,0,0,width,height)
- Call XGetBitmap to capture the bitmap.
- Call XSaveBitmap to save it to disk (the code is actually derived from that MSDN article).
- Don't forget to call ReleaseDC for taken DC.
- You can use ShellExecute API to launch the registered application for .bmp's.
Jugoslav
With wrappers fromXFT Lite library it should be way easier. Briefly:
- Get the window's DC using GetDC (client area) or GetWindowDC (entire window area)
- Fill in hDC member of a X_DC structure.
- Call XSetViewport to set the viewport to appropriate coordinates (xDC,0,0,width,height)
- Call XGetBitmap to capture the bitmap.
- Call XSaveBitmap to save it to disk (the code is actually derived from that MSDN article).
- Don't forget to call ReleaseDC for taken DC.
- You can use ShellExecute API to launch the registered application for .bmp's.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is a module which does what you want.
This code is part of a much larger program and
references some wrapper functions (ShowModalDialog, EditBoxGetText) which are not included, but whose functionality is obvious. The entire screen is captured in a memory bitmap, which may be saved to a BMP file, which in turn can be loaded into MSPaint or any other program.
This code is part of a much larger program and
references some wrapper functions (ShowModalDialog, EditBoxGetText) which are not included, but whose functionality is obvious. The entire screen is captured in a memory bitmap, which may be saved to a BMP file, which in turn can be loaded into MSPaint or any other program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your help so far, Jugoslav. I have downloaded your XFTLite routines. Unfortunately I am so new to this that I have no idea how to use them - I do not know how to create or use a library in CVF, nor can I find any help on the subject. I would love to be able to use and learn from your impressive set of routines - please could you point the way.
With many thanks
Mike
With many thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Lite version is just modules contained in .f90 files, which you simply insert into your project as needed. "Library" was used as a general term, in sense "set of routines appointed to the same task".
Sorry, I can't offer more at the moment than to point you to the XFT documentation. I've uploaded a newer version of sources and docs few days ago, so you may want to check it out. There are also two new samples, although dedicated to drawing to a window on a Win32 project.
I posted some XFT samples on the Forum as well here and there, so you may want to do the search for e.g. "XMemoryDC".
Basically, you need to get a handle of a device context (canvas) hDC, using some of Win32 APIs, depending on your need, such as GetDC, GetWindowDC, PrintDlg, etc. and fill in xDC%hDC member. (Also, you can create a canvas in memory using XMemoryDC.) From then on, just draw onto xDC using XFTGDI routines.
You may also check out this old thread (based on pure Win32 code).
HTH
Jugoslav
P.S. Feel free to write me an e-mail if you need help, but have in mind that I'm on a vacation until Sep 1.
Sorry, I can't offer more at the moment than to point you to the XFT documentation. I've uploaded a newer version of sources and docs few days ago, so you may want to check it out. There are also two new samples, although dedicated to drawing to a window on a Win32 project.
I posted some XFT samples on the Forum as well here and there, so you may want to do the search for e.g. "XMemoryDC".
Basically, you need to get a handle of a device context (canvas) hDC, using some of Win32 APIs, depending on your need, such as GetDC, GetWindowDC, PrintDlg, etc. and fill in xDC%hDC member. (Also, you can create a canvas in memory using XMemoryDC.) From then on, just draw onto xDC using XFTGDI routines.
You may also check out this old thread (based on pure Win32 code).
HTH
Jugoslav
P.S. Feel free to write me an e-mail if you need help, but have in mind that I'm on a vacation until Sep 1.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page