Print Page | Close Window

OnSetPreviewMode bug in VC2005

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=4498
Printed Date: 10 November 2025 at 5:52pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: OnSetPreviewMode bug in VC2005
Posted By: JonN
Subject: OnSetPreviewMode bug in VC2005
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net