Re: Print Preview Behavior in an MFC app
"Damir Valiulin" <DamirValiulin@discussions.microsoft.com> wrote in message
news:388C6E23-DDB6-4271-B2AC-76B0ACA0AD41@microsoft.com...
Anthony,
I'm using VS2008 and also found this quite stupid. Whoever made the
decision
to switch back print preview window to be embedded in Child Frame
obviously
never written any real applicaion beyond Hello World. The issue you
mention
with toolbars and main menu being active is exactly the reason you do want
that preview frame to cover the whole main window!
I'd also be interested in knowing some elegant solution. I quickly tried
to
override some CView and CPriviewView code, but didn't explore this in
detail
because it looks like you'd have to rewrite most of that stuff - not
something I have the time for currently.
I found a partial old solution on CodeGuru, and followed up a lead from one
of the commenters
see:
<http://www.codeguru.com/cpp/w-d/doc_view/printing/comments.php/c3263/?thread=41430>
Now, what I ended up doing was in my CMDIChildDerived class I added a member
m_bPrintPreviewFrameHack.
and added this change of implmentation for is frame wnd.
BOOL CMDIChildDerived::IsFrameWnd() const
{
return m_bPrintPreviewFrameHack ? FALSE : CMDIChildWnd::IsFrameWnd();
}
Then in my view class, I handle OnFilePrintPreview, where I get my parent
(the CMDIChildDerived class), and set it's hack flag, and then call the
CView::OnFilePrintPreview implementation.
My first try was to immediately set the flag back as the commenter suggests,
but that caused an assertion failure.
So, I decided to try overriding CView::OnEndPrintPreview, and setting it
back there, after calling the default.
The net effect is that while my program is in preview mode, I claim my
window isn't a frame wnd.
Obviously this will break if for whatever reason my code were to call
GetParentFrame inside print preview, but I don't do this in my code.
Maybe this will work for you too.
Anthony Wieser
Wieser Software Ltd
It seems Microsoft has been flip-flopping on whether the preview should
be
in the frame window or the child window in an MFC app. As a result, in
VS2005, its back in the child window, where in VC6 it was in the frame.
Unfortunately, that leaves all my toolbars active in print preview mode.
Any suggestions on how to disable the actions I don't want, or how to get
back to the VC6 behavior?