mIRC Homepage
Posted By: Gon_ How does mIRC do /drawsave ? - 26/01/03 06:01 PM
I wondering this because mirc can do /drawsave very fast on hidden windows. Using normal screenshot methods, it's not possible to save images of invisible windows, as there is no Paint messages to it (so there is no image for you to save).

Im wondering if anyone has any insight on how mIRC can seemingly take shots of any window it likes visible or not?
Posted By: vcv Re: How does mIRC do /drawsave ? - 27/01/03 04:26 PM
If you know the handle to a window, visible or not..you CAN take a snapshot of it... or rather, what is in the client area. i assume /drawsave uses the BitBlt API
Posted By: Necroman Re: How does mIRC do /drawsave ? - 27/01/03 04:43 PM
No, you cannot. BitBlt only copies what's on the screen. If the window is hidden (or overlapped by another window), you will get nothing.

But that's not a problem for mIRC as it draws its graphics on the hidden memory DC (CreateCompatibleDC(), CreateCompatibleBitmap(), etc.), blitting it onto the screen when necessary. Therefore, saving the contents of the window becomes trivial.
Posted By: vcv Re: How does mIRC do /drawsave ? - 27/01/03 04:57 PM
BitBlt only copies what is on screen?

Ok then.. tell me this. If you create an off-screen DC (CreateCompatibleDC, CreateCompatibleBitmap as you said), how do you copy what is on that DC to something on screen? What's that? Speak up! Yes.. it's BitBlt.

However, you are right in the aspect that you cannot BitBlt something that is off-screen from a window.. which is an on-screen DC.

However, if a DC was created sing CreateCompatibleDC, and you know the handle to it, BitBlt works just great.
Posted By: Necroman Re: How does mIRC do /drawsave ? - 28/01/03 07:21 AM
Quote:
"If you know the handle to a window, visible or not..you CAN take a snapshot of it... or rather, what is in the client area"

Knowing the handle does not guarantee that you can take a shapshot of it, or what is in the client area, and BitBlt won't help you. That's all I meant.

As for what function Khaled uses to copy information from a memory DC - we don't know, and it doesn't matter. He could use StretchBlt as well.
Posted By: Gon_ Re: How does mIRC do /drawsave ? - 28/01/03 08:09 AM
Thanks for the answers. I was interested in the method used so that I can add a drawsave like command to a DLL (The ability to save any window given a HWND would be cool). I realize now this is not possible. I have read there are some more complex methods, by playing with the window messages, but I don't want to do that.
Posted By: vcv Re: How does mIRC do /drawsave ? - 28/01/03 02:37 PM
Actually it is possible if you try hard enough.
Posted By: Gon_ Re: How does mIRC do /drawsave ? - 28/01/03 04:51 PM
I said, I know there are complex methods of doing it. However, there is no easy way of taking a 'snapshot' given a HWND, as you suggested. That is the kind of solution I was looking for. After reading the article i mentioned, and Necroman's posts, I realise that no such solution exists.

The article i mentioned in my post was written by the author of what I believe to be a well respected book on Windows Graphics Programming I'm sure if there was another method he would of mentioned it.
Posted By: MegaZeroX Re: How does mIRC do /drawsave ? - 02/02/03 04:42 AM
I admit that I know very little about the subject matter, but isn't it possible that mIRC simply keeps a log of all of the draw routines that have been used on it and basically reproduces those to create a bitmap file?

Again, I know very little about the subject matter so this might've been the first thing you guys thought of *shrugs*
Posted By: RG_ Re: How does mIRC do /drawsave ? - 02/02/03 11:50 AM
This would be slow.
gdi.dll is full of functions that could do that so there is no reason to use an other way.
Posted By: Gon_ Re: How does mIRC do /drawsave ? - 05/02/03 10:54 AM
mIRC draws on canvas (DC) in memory , and copies this to the @window canvas. This is how /drawsave doesn't have a problem with hidden windows, it merely saves the contents of it's memory DC.

© mIRC Discussion Forums