![]() |
Print Preview Prebuilt Sample |
Post Reply ![]() |
Author | |
CyberSky ![]() Groupie ![]() Joined: 15 February 2010 Status: Offline Points: 15 |
![]() ![]() ![]() ![]() ![]() Posted: 31 March 2010 at 12:54am |
I've noticed that in my software clicking the Close button in the upper-right corner of the window while in print preview closes the entire application rather than just closing pring preview. I checked the Codejock sample and don't understand what I'm seeing. If I run the prebuilt ToolkitPro.PrintPreview sample that comes with the AllSamples.zip available here, then the print preview fills the entire window. Clicking the Close button (X) does the same thing as clicking the Close Preview button on the print preview toolbar.However, if I build the PrintPreview sample that's in the Toolkit Pro sample folder, and then run it, it behaves differently. The print preview doesn't fill the entire window (the menu bar is still visible), and clicking the Close button (X) closes the entire application rather than closing just the print preview.
I'm talking about the latest version 13.3.1, and am using VS2008 on Windows 7 64-bit.
I've noticed that a basic MFC program also behaves the same way: the Close button closes the entire application rather than just print preview.
Anybody else notice this? Anybody know why the prebuilt sample works one way and the one I built (not changing any options) works a different way?
Thanks for any comments!
|
|
![]() |
|
CyberSky ![]() Groupie ![]() Joined: 15 February 2010 Status: Offline Points: 15 |
![]() ![]() ![]() ![]() ![]() |
Okay, I figured out how to fix this to get the behavior I want. If you look at the code for CPrintPreviewState: struct CPrintPreviewState // Print Preview context/state you can see there's a function that's supposed to get called when you close print preview. This is _AfxPreviewCloseProc(). I think it should be called if you click Close Preview on the toolbar or the application's Close button. However, it apparently is only called if you click Close Preview. If you click Close, the application closes instead. When the main frame's OnSetPreviewMode() is called you can save the preview state: void CMainFrame::OnSetPreviewMode(BOOL bPreview, CPrintPreviewState* pState) m_pPrintPreviewState = pState;
... // Show or hide the command bars, docking panes, etc. and then in OnClose() call the preview close procedure rather than the normal code to close the application: void CMainFrame::OnClose() }
else { // Save the current state of the main window, command bars, etc. ... CFrameWnd::OnClose(); Now when the program is in print preview mode, clicking Close will close print preview rather than closing the entire application. I hope somebody finds this useful. |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |