|
-
June 30th, 2005, 08:37 AM
#1
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.
-
June 30th, 2005, 08:57 AM
#2
Re: BUG at Print ?!
 Originally Posted by bujcat
In this moment the application fails...
Fails? What exactly is happening?
-
June 30th, 2005, 08:58 AM
#3
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 
-
June 30th, 2005, 09:05 AM
#4
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.
-
June 30th, 2005, 09:06 AM
#5
Re: BUG at Print ?!
I haven't override the function OnFilePrintPreview.
-
June 30th, 2005, 09:14 AM
#6
Re: BUG at Print ?!
 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?
-
June 30th, 2005, 09:20 AM
#7
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...
-
June 30th, 2005, 09:36 AM
#8
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.
-
June 30th, 2005, 09:42 AM
#9
Re: BUG at Print ?!
If I make an SDI application with a view of type CView it works very well.
Please help me...
-
June 30th, 2005, 09:47 AM
#10
Re: BUG at Print ?!
 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.
-
June 30th, 2005, 10:09 AM
#11
Re: BUG at Print ?!
I shoul edit some code for that? Do you know an example?
-
June 30th, 2005, 11:22 AM
#12
-
June 30th, 2005, 11:28 AM
#13
Re: BUG at Print ?!
 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.
-
June 30th, 2005, 12:08 PM
#14
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.
-
June 30th, 2005, 12:25 PM
#15
Re: BUG at Print ?!
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|