Thread: Print Preview

  1. #1
    Registered User
    Join Date
    Feb 2003

    Print Preview

    Hello again everyone,

    Another quick question. I build a program in debug mode using MFC.dll as shared and my print preview works fine. If I build the program as a release using standard windows libraries(since the program will be running on machines running windows 9x), I get an assertion error. I don't know why it would be because I am using standard windows libraries because the print function works building that way. Any ideas?


  2. #2
    train spotter
    Join Date
    Aug 2001
    near a computer
    Check that the functions you used are compatible with later versions of MS OS's.

    ie InitCommonControlsEx() needs WIN98

    Else narrow it down for us a bit by posting the code that causes the problem.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Feb 2003
    I am using XP and when I build a release version with the 'use of MFC ' project property set to standard windows library, the print option works just fine. The print preview gives me an assertion error. The systems this program will run on should be 98 and later. I don't know why the release will not run on XP right now. The .cpp code that controls the print and print preview commands is attached to this thread. The .h file is in this thread because I could not attach two files. Let me know what you think.

    #include "Doc.h"

    // Picture view is a typical scroll view.
    class CPictureView : public CScrollView {
    virtual ~CPictureView();
    CPictureDoc* GetDocument() { return (CPictureDoc*)m_pDocument; }

    BOOL m_rcImage; // rect to display image in
    UINT m_iHowScale; // how to scale image
    BOOL _printing;

    void GetImageRect(CRect& rc);
    void SetScrollSizes();
    void PrintingAdjustment(CSize& sz);

    virtual void OnDraw(CDC* pDC); // overridden to draw this view
    virtual void OnInitialUpdate(); // called first time after construct

    //////////////////////Virtual Print Functions
    virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
    virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
    virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

    // command/message handlers
    afx_msg void OnViewScale(UINT nID);
    afx_msg void OnUpdateViewScale(CCmdUI* pCmdUI);
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    afx_msg void OnSize(UINT nType, int cx, int cy);


    Thanks again,

  4. #4
    Registered User
    Join Date
    Feb 2003
    Did I forget to attach the cpp file? I'm sorry. I will attach it to this message. Also, I THINK that I may have tracked down where the problem might be occuring, but I cannot figure out why. Look in the following code....

    BOOL AFXAPI _AfxCheckDialogTemplate(LPCTSTR lpszResource, BOOL bInvisibleChild)
    	ASSERT(lpszResource != NULL);
    	HINSTANCE hInst = AfxFindResourceHandle(lpszResource, RT_DIALOG);
    	HRSRC hResource = ::FindResource(hInst, lpszResource, RT_DIALOG);
    	if (hResource == NULL)
    		if (DWORD_PTR(lpszResource) > 0xffff)
    			TRACE(traceAppMsg, 0, _T("ERROR: Cannot find dialog template named '%s'.\n"),
    			TRACE(traceAppMsg, 0, "ERROR: Cannot find dialog template with IDD 0x%04X.\n",
    		return FALSE;
    whenever the code hits the HRSRC hResource, it returns a null value. The only reason that could be is because of the hInst value. When I try to step into the AfxFindResourceHandle function, I get a message that "There is no source code available in the current location". The AfxFindResourceHandle function is located in dllinit.cpp which is located in the mfc/src folder within .NET. The folder is being accessed because the program steps into other .cpp files in the same folder. Why would it not step into the AfxFindResourceHandle function????? Any ideas.


  5. #5
    Registered User
    Join Date
    Feb 2003

    Found It

    I found the problem.......Just to let everybody know.
    The resources preprocessor definition had _AFXDLL in its values list. I don't know exactly what this is supposed to do in general but I did trace the AfxFindResourceHandle function header down to the AFXWIN.H file and within that file it has the following declaration:

    // Use AfxFindResourceHandle to find resource in chain of extension DLLs
    #ifndef _AFXDLL
    #define AfxFindResourceHandle(lpszResource, lpszType) AfxGetResourceHandle()
    HINSTANCE AFXAPI AfxFindResourceHandle(LPCTSTR lpszName, LPCTSTR lpszType);
    I guess that when the program is not using MFC as a shared DLL it has to DEFINE AfxFindResourceHandle??? Generally speaking....What is _AFXDLL supposed to represent as a preprocess definition?????

    Thanks everyone,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merging linked lists
    By scwizzo in forum C++ Programming
    Replies: 15
    Last Post: 09-14-2008, 05:07 PM
  2. Print Preview problem
    By MarkookraM in forum Windows Programming
    Replies: 4
    Last Post: 09-24-2006, 10:13 AM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  5. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM