-
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?
Thanks,
Kendal
-
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.
-
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.
[code]
#include "Doc.h"
/////////////////
// Picture view is a typical scroll view.
//
class CPictureView : public CScrollView {
public:
virtual ~CPictureView();
CPictureDoc* GetDocument() { return (CPictureDoc*)m_pDocument; }
protected:
BOOL m_rcImage; // rect to display image in
UINT m_iHowScale; // how to scale image
BOOL _printing;
CPictureView();
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);
DECLARE_DYNCREATE(CPictureView)
DECLARE_MESSAGE_MAP()
};
Thanks again,
Kendal
-
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....
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"),
lpszResource);
else
TRACE(traceAppMsg, 0, "ERROR: Cannot find dialog template with IDD 0x%04X.\n",
LOWORD((DWORD_PTR)lpszResource));
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.
Thanks,
Kendal
-
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:
Code:
// Use AfxFindResourceHandle to find resource in chain of extension DLLs
#ifndef _AFXDLL
#define AfxFindResourceHandle(lpszResource, lpszType) AfxGetResourceHandle()
#else
HINSTANCE AFXAPI AfxFindResourceHandle(LPCTSTR lpszName, LPCTSTR lpszType);
#endif
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,
Kendal