|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case ID_TEST:
ShowOpenedWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam )
{
char str[64];
char fullstr[128];
if (IsWindowVisible(hwnd))
{
GetWindowText(hwnd,str,64);
wsprintf(fullstr,"Windiw [Handle] : %d [Caption] : %s",hwnd,str);
iYPos += 20;
TextOut(GetDC(HWND(lParam)),10,iYPos,fullstr,strlen(fullstr));
}
return TRUE;
}
void ShowOpenedWindow(HWND hWnd)
{
iYPos = 10; //Global Variable
HWND lnDesktop;
lnDesktop = GetDesktopWindow();
EnumWindows(EnumWindowsProc, (long)hWnd);
}
|
|
|
|
|
I have a resource leaking report....from Numega software
MSDN say must call ::ReleaseDC() after calling ::GetDC()
CDC::Attach() doesn't call ::ReleaseDC()
and CDC destructor does:
CDC::~CDC()
{
if (m_hDC != NULL)
::DeleteDC(Detach());
}
|
|
|
|
|
how to capture a menu on the menubar?
benben
|
|
|
|
|
have you ever testet this on a multi monitor system?
It's possible that you capture from the wrong monitor!
But how to make a multi-monitor-save capture routine?
|
|
|
|
|
Anyone know how I could caputure a DOS screen programmatically?
I have found I can intercept the clipboard paste when the users presses PrintScr but this only works for lowres VGA DOS screens. I need to capture proprietry DOS video formats and haven't got a clue!
--
The Obliterator
|
|
|
|
|
As far as I know this technique works on any window you have visible. Note that you can always Alt+Enter and get a window version of the screen, and what I'd do in this case is create a little dialog-based app that had exactly one button (and was consequently very, very small on the screen), labelled "Capture". When "Capture" is clicked, the mouse is captured until its LBUTTONDOWN event is seen. At that point, WindowFromPoint is called to find the window the mouse is over. You then pass the window handle to my function. This should capture the contents of the window.
|
|
|
|
|
Saldy not Unfortunately due to the proprietry video mode the DOS software uses Windows is unable to render the program as a windowed DOS screen using Ctrl-Enter. I guess for the same reason this is why the Prt-Scr button does not work as it does for normal DOS programs.
Unfortuneatly my knowledge of DOS video formats is nil. I presume somehow it would be possible to get a pointer to the screen image buffer and read this directly but I wouldn't even know where to start.
Thanks for your advice anyway though.
--
The Obliterator
|
|
|
|
|
Sounds like one of those programs that deserves to die (it won't run under NT or XP, presumably; if it is doing what you seem to suggest, which is *not* "proprietary" unless it is wedded to a specific non-VESA implementation of a specific card--otherwise it would be stock VGA or SVGA), then the application is doomed anyway. However, in this case you should be able to just go for a pointer to the hardware screen image (I suspect this needs DirectDraw or something like that to make it possible), but that's outside what I know. However, you should still be able to get a window handle to the entire screen and grab it that way. Actually, I was not aware that it was even possible to run stock SVGA apps under Win9x.
If you were running under straight MS-DOS, there were a lot of documented techniques for screen capture which may still be around; they were TSR programs. While these probably can't coexist with Windows, you could always boot in pure MS-DOS mode.
|
|
|
|
|
I agree it is definitely one of those programs that deserves to die! I hate it!
Perhaps I misuse the term "proprietary"... to be honest I'm not really sure what it creates, but I know it is very choosy as to which graphics cards it will and won't work with and none of the screen grabbing software I have tried seems capable of grabbing it
Sadly DirectDraw is out of my knowledge also at this time. I tried getting a window handle to the entire screen but I simply get a scrambled image.
I am in the process of rewriting the entire software program in windows, I just wanted to provide some enhanced functionality for some of our existing customer base.
Thanks for your suggestions anyhow.
--
The Obliterator
|
|
|
|
|
This is some good code, but what I'd like to know is how to grab the contents of a screen that have been covered by other windows / lower in the z-order.
If the window I'm grabbing is burried, the contents of the window on top are captured in the size of the window I want.
Any ideas please?
|
|
|
|
|
i don't think you can do this. the contents of window you are trying to capture don't really exist until they're drawn - and windows aren't drawn in back of other windows - they're only drawn on top of.
if you screen capture a winodw that's been partially overdrawn on by another window, you'll get the overdrawn stuff, too.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
This is true, but this technique does work for capturing what is actually displayed on the screen. The evidence is the hundreds of screen snapshots in Win32 Programming, all but a couple of which were created using this actual function. A few were done before I created it by taking a snapshot and editing away everything but the control I wanted, but this was clearly going to be a losing idea for more than a few images. So I wrote the function. The whole point is that a screen snapshot is *supposed* to show what is drawn in the window.
|
|
|
|
|
This should work
Findwindow("window caption")
getwindowDC()
bitblt from required window DC to u r DC
|
|
|
|
|
Of course, FindWindow only works if you already know the caption; if you already know the caption, you probably don't need to FindWindow. And it doesn't help if the window is overlapped with something else.
Also, the problem of GetCursorPos is that it tells you where the cursor is NOW, not where it was when you wanted to see it, so the use of GetCursorPos is essentially pointless unless you do something else to determine where the cursor is. For example, you would have to capture the mouse, and as it moved over other windows, you would have to call that window's OnSetCursor method by sending WM_SETCURSOR to the window, and suppressing your own OnSetCursor handler. Then when the mouse was clicked, saving the cursor and the position.
|
|
|
|
|
Well, this is unlikely to work.
FindWindow requires that you actually know the window caption, which is generally considered unreliable.
getWindowDC will get a DC for the window, and if the window is covered by something else, it will simply return the bits currently in the window, such as the bits of whatever window is covering it.
joe
|
|
|
|
|
Check this out, http://www.fengyuan.com/article/wmprint.html. It uses WM_PRINT. But I'm also having problem using it. Just to see if any look at it before.
|
|
|
|
|
I've been trying to do a similar thing, I want to capture an application, but it may not be in focus, so I get the handle to the app but using
::FindWindow(NULL, "Window Title");
Add attach this to a CWnd, I can then call wnd->ShowWindow(SW_SHOWNOACTIVATE) which will restore it if minimised, and then call
wnd->BringWindowToTop(); which brings it to the top, and thus causes it to be redrawn.
I'm having a few problems with this, but the idea is right.
Anyone know a better way?
|
|
|
|
|
|
How one can render metafile image from dialog control?
Like List Conrol, for instance.
|
|
|
|
|
This is in general a hard problem. While some controls honor WM_PRINT, not all controls do. And there is some question about what it means to "print" a control, anyway. I'd just open a metafile and draw to it.
|
|
|
|
|
Is today a day where I'm extremely thick?
What about using the Print Screen key on the keyboard?
(copies the full screen area in clipboard)
What about using Alt+Print Screen?
(copies the active window in clipboard)
What about the shareware program "Hardcopy Pro" (www.desksoft.com)?
(can even copy mouse pointers, tooltips and context menus)
|
|
|
|
|
This code lets you do it yourself in your own program.
You could also modify:
wnd->GetParent()->OpenClipboard();
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, bm.m_hObject);
CloseClipboard();
and make it save to a file instead.
Cheers,
Peter Pearson
|
|
|
|
|
>>>>make it save to a file instead.
How do you save image from clipbord to file?
|
|
|
|
|
Talking about screen capture programs, I use ScreenHunter. (www.wisdom-soft.com). No need to beat around the bush.
Jeff Gretzky
|
|
|
|