Amol Gokhale
April 5th, 1999, 06:18 AM
I want to disable PRINT button in Standard CView::OnFilePrintPreview call??
If someonw knows the soln pl. let me know ASAP as its very urgent
thanx in advance
Amol.
LALeonard
April 7th, 1999, 06:18 PM
This worked in VC5, but not in VC6 - it has to do with the fact that the CMainFrame now owns the print preview window instead of the CChildFrame. I haven't gotten around to fixing it yet, but this should get you started. If you get it working for VC6, post the fix! Thanks... Oh yeah, you would use AFX_ID_PREVIEW_PRINT instead of AFX_ID_PREVIEW_NEXT...
// We must not allow the user to go to the next page before this page is
// finished printing, becuase that would mean the the m_nLastItemPrinted
// member would not have a valid value in it. (There must be an easier
// way to do this, but I can't find it.)
void CBrowseLogView::PrintDisableNextPageButton()
{
VALIDATE;
// Get the MDI Child window.
CChildFrame* pMDIChildFrame = dynamic_cast<CChildFrame*> (GetParentFrame());
ASSERT_VALID(pMDIChildFrame);
// Get the first child of the MDI child.
CWnd* pDialog = dynamic_cast<CWnd*> (pMDIChildFrame->GetWindow(GW_CHILD));
ASSERT_VALID(pDialog);
CWnd* pNextPage = NULL;
// Iterate the MDI Child window's children, and see if *those*
// children contain the button.
while (pDialog) {
// Does this child have the button?
pNextPage = pDialog->GetDlgItem(AFX_ID_PREVIEW_NEXT);
ASSERT_NULL_OR_POINTER(pNextPage, CWnd);
// Found the button, so we're done.
if (pNextPage) {
break;
}
else {
// This child doesn't have the button; try the next child.
pDialog = dynamic_cast<CWnd*> (pDialog->GetWindow(GW_HWNDNEXT));
ASSERT_NULL_OR_POINTER(pDialog, CWnd);
}
}
// We better have found the button in Print Preview mode (but not,
// of course, in Print mode); disable the button.
ASSERT_NULL_OR_POINTER(pNextPage, CWnd);
if (pNextPage) {
pNextPage->EnableWindow(false);
}
}
LA Leonard - Definitive Solutions, Inc.