Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - OnSetPreviewMode bug in VC2005
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

OnSetPreviewMode bug in VC2005

 Post Reply Post Reply
Author
Message
JonN View Drop Down
Newbie
Newbie
Avatar

Joined: 11 January 2004
Location: United Kingdom
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote JonN Quote  Post ReplyReply Direct Link To This Post Topic: OnSetPreviewMode bug in VC2005
    Posted: 27 June 2006 at 9:07am

I've just located a possible problem in the print preview sample for VC2005. Updating one of my programs from VC6 to VC2005, I discovered that the behaviour of OnSetPreviewMode has been altered slightly by Microsoft. 

The print preview MDI code sample (and my project) no longer hide command bars, docking panes or tab bars when print preview is selected.  This seems to be due to the fact that OnSetPreviewMode in CMainFrame is no longer called by the framework.  Searching through the code reveals that instead of the framework calling AfxGetMainWnd() to locate the parent frame, it now calls GetParentFrame() which of course finds the current active CMDIChildWnd.
 
As a workaround, I've added the following function to my CChildFrame class,

void CChildFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState)

{

GetParentFrame()->OnSetPreviewMode(bPreview, pState);

CMDIChildWnd::OnSetPreviewMode(bPreview, pState);

}

This ensures that the parent CMainFrame class gets called.  In addition the call to CMDIFrameWnd::OnSetPreviewMode(...) in CMainFrame::OnSetPreviewMode(...) should be removed, otherwise the program asserts.

I'm sure there is a more elgant solution to this problem, but for now this works. Wink
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.