Re: Grabbing desktop image under a window
Got rid of the flicker while I was experimenting. It's not a fix, it
actually brings up a problem.
Add this method
BOOL CMagnifyDlg::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}
And change GetImage().. All I did with change image was to get rid of the
SetLayeredWindowAttributes calls. I guess it didn't need to be hidden.
Which brings up a problem. My code will not copy any layered windows that
are on the desktop into the bitmap. For some reason bitblting the desktop
will not include any layered windows. So if you run two instances of your
program and move one over the other it will be like the one below is not
even there! I'm going to search on that a little to see why.
void CMagnifyDlg::GetImage()
{
CRect Rect;
GetClientRect(&Rect);
ClientToScreen(&Rect);
m_Bmp.DeleteObject();
CDC *pDC = GetDesktopWindow()->GetDC();
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
m_Bmp.CreateCompatibleBitmap(pDC,Rect.Width(),Rect.Height());
int Saved = MemDC.SaveDC();
MemDC.SelectObject(&m_Bmp);
MemDC.BitBlt(0,0,Rect.Width(),Rect.Height(),pDC,Rect.left,Rect.top,SRCCOPY);
MemDC.RestoreDC(Saved);
GetDesktopWindow()->ReleaseDC(pDC);
Invalidate();
}
AliR.
"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
news:hbhHh.1477$uo3.1472@newssvr14.news.prodigy.net...
I fogot to paste the OnMove handler. :)
I'm glad you liked it.
AliR.
"MrAsm" <mrasm@usa.com> wrote in message
news:se7ru2ha04bp4l4g0udtf5fart62s0v7vt@4ax.com...
On Tue, 06 Mar 2007 16:13:01 GMT, "AliR \(VC++ MVP\)"
<AliR@online.nospam> wrote:
I did this using layered windows, it works pretty good, the only thing
that
needs work is the flickering of the border. (NOTE: this will only work
for
WinXP and above.)
Hi Alir: your code is great!
Thank you very much.
I added also the OnMove() handler and called GetImage() from it. It
does exactly what I would like to do!
But Yes, the problem is the border flickering...
MrAsm