Print Preview on Main frame in MDI Application
-
Hi All, I am working on VC2008's MDI application with Ribbon bar and have to provide print preview. Now, However VC2008 do have print preview, but the client requires it to look it like the VC6.0's Print preview capturing the entire main frame along with some certain buttons, all like VC6.0. Can some body please help me on it
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi All, I am working on VC2008's MDI application with Ribbon bar and have to provide print preview. Now, However VC2008 do have print preview, but the client requires it to look it like the VC6.0's Print preview capturing the entire main frame along with some certain buttons, all like VC6.0. Can some body please help me on it
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
I'm not sure if it'll do what you want, but try this: Find OnFilePrintPreview in your CView-derived class and replace its code with this:
void CYourViewDerivedClass::OnFilePrintPreview()
{
// AFXPrintPreview(this);// ASSERT_VALID(pView);
CPrintPreviewState \*pState= new CPrintPreviewState; if (!DoPrintPreview(IDD\_AFXBAR\_RES\_PRINT\_PREVIEW, this, RUNTIME\_CLASS(CPreviewView), pState)) { TRACE0("Error: OnFilePrintPreview failed.\\n"); AfxMessageBox(AFX\_IDP\_COMMAND\_FAILURE); delete pState; // preview failed to initialize, delete State now }
}
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
I'm not sure if it'll do what you want, but try this: Find OnFilePrintPreview in your CView-derived class and replace its code with this:
void CYourViewDerivedClass::OnFilePrintPreview()
{
// AFXPrintPreview(this);// ASSERT_VALID(pView);
CPrintPreviewState \*pState= new CPrintPreviewState; if (!DoPrintPreview(IDD\_AFXBAR\_RES\_PRINT\_PREVIEW, this, RUNTIME\_CLASS(CPreviewView), pState)) { TRACE0("Error: OnFilePrintPreview failed.\\n"); AfxMessageBox(AFX\_IDP\_COMMAND\_FAILURE); delete pState; // preview failed to initialize, delete State now }
}
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
Hi sashoalm, First thanks for replying... I already know the way how to prepare print preview. But i guess i was not clear enough with my requirement. My requirement is to show the preview capturing the entire main frame including all Menues, Panes, Views etc in VS 2008, how VS 6.0 does. In VS2008, the preview comes like a view only and menues etc are remain enabled.. Please suggess something else may be that will help... Thanks
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi sashoalm, First thanks for replying... I already know the way how to prepare print preview. But i guess i was not clear enough with my requirement. My requirement is to show the preview capturing the entire main frame including all Menues, Panes, Views etc in VS 2008, how VS 6.0 does. In VS2008, the preview comes like a view only and menues etc are remain enabled.. Please suggess something else may be that will help... Thanks
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
OK, CMainFrame should have CMainFrame::OnFilePrintPreview method, try to place the code I posted in CMainFrame::OnFilePrintPreview instead and tell me what happened.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
OK, CMainFrame should have CMainFrame::OnFilePrintPreview method, try to place the code I posted in CMainFrame::OnFilePrintPreview instead and tell me what happened.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
Hi, Thanks for quick reply.
sashoalm wrote:
try to place the code I posted in CMainFrame::OnFilePrintPreview
There is an issue in doing as you are saying but there is no such function "DoPrintPreview" in class CMDIFrameWndEx from which the CmainFrame Class is derived.. However, i already have tried:
CView *pView = GetActiveFrame()->GetActiveView();
if(pView == NULL)
{
return;
}
CPrintPreviewState* pState = new CPrintPreviewState;if (!pView->DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, pView,
RUNTIME_CLASS(CPreviewView), pState))
{
delete pState; // Preview failed to initialize, delete State now.
pState = NULL;
}But it prepares the preview in the same document only and not capturing the frame. And this not what i wanted :( Please suggess something else.
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi, Thanks for quick reply.
sashoalm wrote:
try to place the code I posted in CMainFrame::OnFilePrintPreview
There is an issue in doing as you are saying but there is no such function "DoPrintPreview" in class CMDIFrameWndEx from which the CmainFrame Class is derived.. However, i already have tried:
CView *pView = GetActiveFrame()->GetActiveView();
if(pView == NULL)
{
return;
}
CPrintPreviewState* pState = new CPrintPreviewState;if (!pView->DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, pView,
RUNTIME_CLASS(CPreviewView), pState))
{
delete pState; // Preview failed to initialize, delete State now.
pState = NULL;
}But it prepares the preview in the same document only and not capturing the frame. And this not what i wanted :( Please suggess something else.
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
Hi Sashoalm,
sashoalm wrote:
What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.
It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count.. Like in VC 6.0, i didn't needed to do any thing like that and the compiler was doing this for me, i want something like that. Thanks
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi Sashoalm,
sashoalm wrote:
What about minimizing the ribbon? Try minimizing the ribbon before print preview and see if you like it.
It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count.. Like in VC 6.0, i didn't needed to do any thing like that and the compiler was doing this for me, i want something like that. Thanks
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
Harsh Shankar wrote:
It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count
What do you mean by that? You right-click on the ribbon bar and there's "Minimize the ribbon" *by default* in every MFC9 program. Why didn't you use that? Just do it and see how it looks. Not programatically - as a user - click on "Minimize the ribbon".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
Harsh Shankar wrote:
It is not practically possible and good to hide all the ribbons, views and panes on Preview and restore them OnEndPreview since the are many in count
What do you mean by that? You right-click on the ribbon bar and there's "Minimize the ribbon" *by default* in every MFC9 program. Why didn't you use that? Just do it and see how it looks. Not programatically - as a user - click on "Minimize the ribbon".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
Hi sashoalam, So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible. Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so. i think must have understood my problem.
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
-
Hi sashoalam, So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible. Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so. i think must have understood my problem.
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
Harsh Shankar wrote:
we didn't have to do all those things by us and it was MFC's responsbility to do so
Why are you telling this to me? I'm not the author of MFC. You should send this to the guys at Microsoft ;P
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
Hi sashoalam, So do you think i should minimize all the Ribbons by some explicite call. But don't you think, making calls for hiding all the views, menues, tabs, Panes etc and maintaining its previous states is not really a good idea if you may have about 10 Ribbon-tabs, about 10-20 Panes and uncountable Views are possible. Event on remembering the 6.0 days, you'll notice that we didn't have to do all those things by us and it was MFC's responsbility to do so. i think must have understood my problem.
HARSH Programmers are in a race with the Universe to create bigger and better idiot-proof programs, while the Universe is trying to create bigger and better idiots. So far the Universe is winning.
I just want to clarify that I think the preview mode has just been changed in MFC 9.0 and probably there is no easy way to make it look the old way. If you don't like my suggestions then you're free not to follow them.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal