Reputation: 4935
In my app the user double-clicks on a table row to open a dialog window. The problem is that the window is instantly displayed - I want to make the window appear to 'jump out' of the table row (in the same way that windows 'jump out' from the task bar). To do this I need to draw the dialog window to a memory device context - how can I do this without first drawing it to the screen?
Thanks
------------------ Edit ----------------------
@bubbafat: Thanks - yes I will need to use CreateCompatibleDC, then set the size of the memory DC to the size of the dialog window. But then I need to draw a 'picture' of the window to the memory device pixels. This will then allow me to draw each frame of the 'pop-up' animation - ie:
Upvotes: 0
Views: 1495
Reputation: 3423
If you're trying to draw the window into a memory DC, consider sending it the WM_PRINT message. Assuming your window procedure doesn't do anything especially strange in the normal case, it should render everything into your DC. The animation can be taken from there.
Upvotes: 1
Reputation: 281835
The DrawAnimatedRects function is what does that "jumping out" for the taskbar - there's no need to render the window animation yourself.
Edit: Except that doesn't work on Vista. Here's some equivalent code:
// DrawAnimatedRects(wnd->GetSafeHwnd(), IDANI_CAPTION, animateFrom, &rect);
const DWORD MILLIs = 500;
DWORD startTime = GetTickCount();
DWORD now = startTime;
CRect offset(rect.left - animateFrom->left, rect.top - animateFrom->top,
rect.right - animateFrom->right, rect.bottom - animateFrom->bottom);
wnd->Invalidate();
while (now - MILLIs < startTime)
{
int fraction100 = (int) (((now - startTime) * 100) / MILLIs);
CRect step(animateFrom->left + (fraction100 * offset.left) / 100,
animateFrom->top + (fraction100 * offset.top) / 100,
animateFrom->right + (fraction100 * offset.right) / 100,
animateFrom->bottom + (fraction100 * offset.bottom) / 100);
wnd->SetWindowPos(0, step.left, step.top,
step.right - step.left, step.bottom - step.top,
SWP_NOZORDER);
wnd->ShowWindow(SW_SHOWNORMAL);
Sleep(5);
now = GetTickCount();
}
Upvotes: 1
Reputation: 4036
It sounds like your question is "how do I create a memory device context that is compatible with my screen so that I can draw to it?" In that case the answer is to use CreateCompatibleDC. If that is not your question then please provide additional information so that it is clearer where exactly in the process you are having problems.
Upvotes: 0