CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    14

    Print in print preview

    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.


  2. #2

    Re: Print in print preview

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured