CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: BUG at Print ?!

  1. #1
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    BUG at Print ?!

    Hi

    I have a SDI application with a CListView. I have a menu option which call the function OnFilePrintPreview(). In this moment the application fails...

    Code:
    void CVisionCARView::TiparesteAcordImprumut(void)
    {
    	AfxMessageBox("Tipareste");
    
    	OnFilePrintPreview();
    }
    I have use this code before and it works fine. Since then I change my version of Visual C++.

    It posible to be a bug?


    I'm using now Visual C++ 2003 Standard.

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: BUG at Print ?!

    Quote Originally Posted by bujcat
    In this moment the application fails...
    Fails? What exactly is happening?

  3. #3
    Join Date
    Nov 2002
    Location
    Washington, D.C.
    Posts
    264

    Re: BUG at Print ?!

    Might need a little more info. How does it fail? Have you stepped through in debug? Have you tried overriding the default OnFilePrintPreview in your view class?

    sulu
    Yay 100+ rep! Thnx all for Rating my Posts and deeming them worthy

  4. #4
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    The message is:

    Debug Assertion Failed!
    Program: ...
    File: bardlg.cpp
    Line: 44


    And in OUTPUT window I Have:

    ERROR: Cannot find dialog template with IDD 0x7803.
    Unhandled exception at 0x005c4afa in VisionCAR.exe: User breakpoint.

  5. #5
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    I haven't override the function OnFilePrintPreview.

  6. #6
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: BUG at Print ?!

    Quote Originally Posted by bujcat
    The message is:

    Debug Assertion Failed!
    Program: ...
    File: bardlg.cpp
    Line: 44
    So an assertion failed. And - have you looked at line 44 of bardlg.cpp to see which assertion failed?

  7. #7
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    This is the code where it fais(bardlg.cpp)

    Code:
    #ifdef _DEBUG
    	// dialog template must exist and be invisible with WS_CHILD set
    	if (!_AfxCheckDialogTemplate(lpszTemplateName, TRUE))
    	{
    line 44:		ASSERT(FALSE);          // invalid dialog template name
    		PostNcDestroy();        // cleanup if Create fails too soon
    		return FALSE;
    	}
    #endif //_DEBUG


    I try the same code in Visual C++ 2002 and I have the same problem. I think that I'm doing something wrong but I don't understand what...

  8. #8
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    Please make this simple test and tell me if it working at you.

    Make a SDI application with a view of type CListView.

  9. #9
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    If I make an SDI application with a view of type CView it works very well.

    Please help me...

  10. #10
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: BUG at Print ?!

    Quote Originally Posted by bujcat
    This is the code where it fais(bardlg.cpp)
    Well, it tells you why it fails: A dialog resource template (probably the one used for the print preview dialog bar) could not be found - they are located in afxprint.rc.

    The problem is that the class wizard only adds afxprint.rc to your project if you choose "Printing and Print Preview" as a feature when you generate the project - and if you choose a view type where you usually implement your own printing code (like CView or CScrollView). Printing and print preview is not automatically supported for control-based views like CListView.

  11. #11
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    I shoul edit some code for that? Do you know an example?

  12. #12
    Join Date
    Dec 2004
    Location
    Brasov
    Posts
    267

    Re: BUG at Print ?!

    anybody?

  13. #13
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: BUG at Print ?!

    Quote Originally Posted by bujcat
    I shoul edit some code for that? Do you know an example?
    The easiest way is to create a new project and select CView as the view type - and add your CControlView later. However, you will still need to implement the printing code yourself.

  14. #14
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: BUG at Print ?!

    Check your applications .rc file and that it has this at he end:

    Code:
    #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
    #ifdef _WIN32
    LANGUAGE 9, 1
    #pragma code_page(1252)
    #endif //_WIN32
    #include "res\YourApplicationName.rc2"  // non-Microsoft Visual C++ edited resources
    #include "afxres.rc"         // Standard components
    #include "afxprint.rc"       // printing/print preview resources
    #endif
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  15. #15
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815

    Re: BUG at Print ?!

    Quote Originally Posted by Roger Allen
    Check your applications .rc file and that it has this at he #include "afxprint.rc" // printing/print preview resources
    Yes - but that alone won't help: You still need to implement OnPreparePrinting() and OnPrint(), (and possibly also OnBeginPrinting() and OnEndPrinting()) in the view class, and call at least DoPreparePrinting() in the OnPreparePrinting() implementation - or the call to OnFilePrintPreview() will assert at another point.

Page 1 of 2 12 LastLast

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