Thomas Stockbruegger
asked on
Need some help with fonts and printing
Hello...I need your help, again.
my printing will crash...I have enclosed the complete call stack.
The user clicks on this button
OnBnClickedButton_Drucken( )
and I am calling Drucken_weiss() to start printing.
Can you help me to find out what the error means.
500 points.
Best regards,
Thomas
still learing this difficult printing thing
Stop here:
BOOL CGdiObject::Attach(HGDIOBJ hObject)
{
-----> ASSERT(m_hObject == NULL); // only attach once, detach on destroy if (hObject == NULL)
return FALSE;
CHandleMap* pMap = afxMapHGDIOBJ(TRUE); // create map if not exist
ASSERT(pMap != NULL);
pMap->SetPermanent(m_hObje ct = hObject, this);
return TRUE;
}
Constructor...Destructor
IMPLEMENT_DYNAMIC(CAuftrag sHistory_L ieferschei n_Dialog, CDialog)
CAuftragsHistory_Liefersch ein_Dialog ::CAuftrag sHistory_L ieferschei n_Dialog(C Wnd* pParent /*=NULL*/)
: CDialog(CAuftragsHistory_L ieferschei n_Dialog:: IDD, pParent)
, m_strLieferscheinNr(_T("") )
, m_piAdoRecordBinding(NULL)
, m_strConnection(_T(""))
, m_strCmdText(_T(""))
, mb_Kennzahl_first_show_up( false)
{
m_fontUeberschrift=NULL;
m_fontBold =NULL;
m_fontSmall=NULL;
m_hDevMode=NULL;
m_hDevNames=NULL;
}
CAuftragsHistory_Liefersch ein_Dialog ::~CAuftra gsHistory_ Liefersche in_Dialog( )
{
delete m_fontUeberschrift;
delete m_fontBold;
delete m_fontSmall;
}
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::OnBeginP rinting(CD C* pDC, CPrintInfo* pInfo)
{
//Druckbereich in 0,1mm
pDC->SetMapMode(MM_LOMETRI C);
//------------------------ ---------- ----
pInfo->SetMaxPage(1);
//------------------------ ---------- ----
//--------------- Neue Schrift erstellen ------------------
if(m_fontUeberschrift==NUL L)
{
m_fontUeberschrift->Create Font(-40,
0,
0,
0,
600,
0,
0,
0,
DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS,
CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial");
}
//------------------------ ---------- ---------- ---------- ----
}
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::OnPrint( CDC* pDC, CPrintInfo* pInfo)
{
//Druckbereich in 0,1mm
pDC->SetMapMode(MM_LOMETRI C);
//obwohl dies schon in OnBeginPrinting steht
//ist es immer eine gute Idee es nochmal zuschreiben
//str_Datum_druck = aktuelle Datum
CFont* pOldFont = pDC->SelectObject(m_fontUe berschrift );
//--------------- Tag - Datum - KW -------------------
pDC->TextOut(100,-50,"Vers uch");
pDC->TextOut(350,-50,"Vers uch");
pDC->TextOut(600,-50,"Wilh elm Stockbrügger OHG");
//-------------------- Abmessung ---------------------
pDC->SelectObject(pOldFont );
here comes later the delivery notice "Lieferschein"
//------------- Letzte Seite ermitteln ------------
UINT nEndPage = pInfo->m_nCurPage;
if(nEndPage==pInfo->GetMax Page())
{
// pDC->SelectObject(pOldFont );
// pDC->TextOut(100,-600,"Let zte Seite");
}
//------------------------ ---------- ---------- -----
//------------- Erste Seite ermitteln ------------
UINT nStartPage = pInfo->m_nCurPage;
if(nStartPage==pInfo->GetM inPage())
{
// pDC->SelectObject(pOldFont );
// pDC->TextOut(100,-600,"Ers te Seite");
}
//------------------------ ---------- ---------- -----
}
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::OnEndPri nting(CDC* pDC, CPrintInfo* pInfo)
{
delete m_fontUeberschrift;
}
//######################## ########## ########## ########## ########## ########## ########## ###
bool CAuftragsHistory_Liefersch ein_Dialog ::GetPrint erDevice(L PTSTR pszPrinterName, HGLOBAL* phDevNames, HGLOBAL* phDevMode)
{
// if NULL is passed, then assume we are setting app object's
// devmode and devnames
if (phDevMode == NULL || phDevNames == NULL)
{
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-1error");
return FALSE;
}
// Open printer
HANDLE hPrinter;
if (OpenPrinter(pszPrinterNam e, &hPrinter, NULL) == FALSE)
{
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-2error");
return FALSE;
}
// obtain PRINTER_INFO_2 structure and close printer
DWORD dwBytesReturned, dwBytesNeeded;
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)GlobalAll oc(GPTR,
dwBytesNeeded);
if (GetPrinter(hPrinter, 2, (LPBYTE)p2, dwBytesNeeded,&dwBytesRetu rned) == 0)
{
GlobalFree(p2);
ClosePrinter(hPrinter);
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-3error");
return FALSE;
}
ClosePrinter(hPrinter);
// Allocate a global handle for DEVMODE
HGLOBAL hDevMode = GlobalAlloc(GHND, sizeof(*p2->pDevMode) + p2->pDevMode->dmDriverExtr a);
ASSERT(hDevMode);
DEVMODE* pDevMode = (DEVMODE*)GlobalLock(hDevM ode);
ASSERT(pDevMode);
// copy DEVMODE data from PRINTER_INFO_2::pDevMode
memcpy(pDevMode, p2->pDevMode, sizeof(*p2->pDevMode) + p2->pDevMode->dmDriverExtr a);
GlobalUnlock(hDevMode);
// Compute size of DEVNAMES structure from PRINTER_INFO_2's data
DWORD drvNameLen = lstrlen(p2->pDriverName)+1 ; // driver name
DWORD ptrNameLen = lstrlen(p2->pPrinterName)+ 1; // printer name
DWORD porNameLen = lstrlen(p2->pPortName)+1; // port name
// Allocate a global handle big enough to hold DEVNAMES.
HGLOBAL hDevNames = GlobalAlloc(GHND, sizeof(DEVNAMES) +(drvNameLen + ptrNameLen + porNameLen)*sizeof(TCHAR)) ;
ASSERT(hDevNames);
DEVNAMES* pDevNames = (DEVNAMES*)GlobalLock(hDev Names);
ASSERT(pDevNames);
// Copy the DEVNAMES information from PRINTER_INFO_2
// tcOffset = TCHAR Offset into structure
int tcOffset = sizeof(DEVNAMES)/sizeof(TC HAR);
ASSERT(sizeof(DEVNAMES) == tcOffset*sizeof(TCHAR));
pDevNames->wDriverOffset = tcOffset;
memcpy((LPTSTR)pDevNames + tcOffset, p2->pDriverName,drvNameLen *sizeof(TC HAR));
tcOffset += drvNameLen;
pDevNames->wDeviceOffset = tcOffset;
memcpy((LPTSTR)pDevNames + tcOffset, p2->pPrinterName,ptrNameLe n*sizeof(T CHAR));
tcOffset += ptrNameLen;
pDevNames->wOutputOffset = tcOffset;
memcpy((LPTSTR)pDevNames + tcOffset, p2->pPortName,porNameLen*s izeof(TCHA R));
pDevNames->wDefault = 0;
GlobalUnlock(hDevNames);
GlobalFree(p2); // free PRINTER_INFO_2
// set the new hDevMode and hDevNames
*phDevMode = hDevMode;
*phDevNames = hDevNames;
return TRUE;
}
//######################## ########## ########## ########## ########## ########## ########## ###
HANDLE CAuftragsHistory_Liefersch ein_Dialog ::CopyHand le(HANDLE h)
{
// Return a handle to a copy of the data
// that the passed handle was for.
if (!h) return NULL;
BYTE* lpCopy;
BYTE* lp;
HANDLE hCopy;
DWORD dwLen = GlobalSize(h);
if (hCopy = GlobalAlloc(GHND, dwLen))
{
lpCopy = (BYTE*)GlobalLock(hCopy);
lp = (BYTE*)GlobalLock(h);
CopyMemory(lpCopy,lp,dwLen );
GlobalUnlock(hCopy);
GlobalUnlock(h);
}
return hCopy;
}
//######################## ########## ########## ########## ########## ########## ########## ###
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::Drucken_ weiss(void )
{
// if (GetPrinterDevice(_T("EPSO N LQ-680Pro Port 2 Wiegekarte"), &hDevNames, &hDevMode))
// HANDLE hDevMode; m_hDevMode;
// HANDLE hDevNames; m_hDevNames;
m_hDevMode=m_hDevNames=NUL L;
if (GetPrinterDevice(_T("\\\\ DSERVER\\B rother HL-7050 series"), &m_hDevNames, &m_hDevMode)) // See KB article Q166129
// if (GetPrinterDevice(_T("Powe rPDF 2005"), &hDevNames, &hDevMode)) // See KB article Q166129
{
AfxGetApp()->SelectPrinter (m_hDevNam es, m_hDevMode);
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS |PD_USEDEV MODECOPIES ANDCOLLATE , this);
//------------------------ --- Papier Auswahl DEVMODE -------------------------- --------
if(AfxGetApp()->GetPrinter DeviceDefa ults(&dlgP rint.m_pd) )
{
LPDEVMODE dev=dlgPrint.GetDevMode();
GlobalUnlock(dev);
// hier kann man alle Atribute von DEVMODE angeben (siehe Microsoft DEVMODE Blätter)
// dev->dmOrientation=DMORIEN T_LANDSCAP E; //Querformat
//dev->dmOrientation=DMORI ENT_PORTRA IT; //Hochformat
// dev->dmPaperSize=DMPAPER_A 4;
// dev->dmCopies=1;
// dev->dmDefaultSource=0;
// dev->dmPaperSize=DMPAPER_A 5;
// dev->dmPaperLength=1020;
// dev->dmPaperWidth=1480;
// dev->dmDefaultSource=DMBIN _TRACTOR;
dev->dmOrientation=DMORIEN T_PORTRAIT ;
dev->dmPaperSize=DMPAPER_A 4;
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW IDTH|DM_OR IENTATION| DM_DEFAULT SOURCE;
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------ ---------- ---------- ---------- ---------- ---------- -------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//======================== ========== ========== ========== ========== ========== ========== ========== =
// if(dlgPrint.DoModal()==IDO K) //Ohne CPrintDialogBox
// {
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames);
m_hDevMode = CopyHandle(dlgPrint.m_pd.h DevMode); // Save new copies.
m_hDevNames = CopyHandle(dlgPrint.m_pd.h DevNames); // Save new copies.
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC() ;
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr interDC()) ;
dc.m_bPrinting=TRUE;
//------------------------ ---------- --
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------ ---------- -
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0 ,0,dc.GetD eviceCaps( HORZRES), dc.GetDeviceCaps(VERTRES)) ;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnBeginPrinting(&dc,&pInfo ); // call prepare
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
//======================== ========== ========== ========== ========== ========== ====
for(UINT page=pInfo.GetMinPage();pa ge<=pInfo. GetMaxPage () &&bPrintingOK ; page++)
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
bPrintingOK=(dc.EndPage()> 0);
}
//======================== ========== ========== ========== ========== ========== ====
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnEndPrinting(&dc,&pInfo); // call your clean up
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
dc.DeleteDC();
//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h DevMode);
GlobalFree(dlgPrint.m_pd.h DevNames);
}
//xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxx
}
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::OnBnClic kedButton_ Drucken()
{
int iLieferscheinNr=atoi(m_str Liefersche inNr);//Me mberVariab le
Sleep(1000);
//===============
Drucken_weiss();
Sleep(1000);
if(iLieferscheinNr<200000) MessageBox(" Drucke Lieferschein " +m_strLieferscheinNr);
if(iLieferscheinNr>200000) MessageBox(" Drucke Warenbegleitschein " +m_strLieferscheinNr);
//######################## ########## ########## ########## ########## ########## ########## ###
my printing will crash...I have enclosed the complete call stack.
The user clicks on this button
OnBnClickedButton_Drucken(
and I am calling Drucken_weiss() to start printing.
Can you help me to find out what the error means.
500 points.
Best regards,
Thomas
still learing this difficult printing thing
>my call stack
mfc71d.dll!CGdiObject::Attach(void * hObject=0x770a068f) Zeile 1102 + 0x3 C++
mfc71d.dll!CFont::CreateFontA(int nHeight=-40, int nWidth=0, int nEscapement=0, int nOrientation=0, int nWeight=600, unsigned char bItalic=0, unsigned char bUnderline=0, unsigned char cStrikeOut=0, unsigned char nCharSet=' ', unsigned char nOutPrecision=' ', unsigned char nClipPrecision=' ', unsigned char nQuality=0, unsigned char nPitchAndFamily=0, const char * lpszFacename=0x0066a080) Zeile 166 + 0x4f C++
Stockbruegger.exe!CAuftragsHistory_Lieferschein_Dialog::OnBeginPrinting(CDC * pDC=0x0012e914, CPrintInfo * pInfo=0x0012e898) Zeile 2052 C++
Stockbruegger.exe!CAuftragsHistory_Lieferschein_Dialog::Drucken_weiss() Zeile 1978 C++
Stockbruegger.exe!CAuftragsHistory_Lieferschein_Dialog::OnBnClickedButton_Drucken() Zeile 1647 C++
mfc71d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x00fb9b90, unsigned int nID=1029, int nCode=0, void (void)* pfn=0x004ccea0, void * pExtra=0x00000000, unsigned int nSig=53, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 89 C++
mfc71d.dll!CCmdTarget::OnCmdMsg(unsigned int nID=1029, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 396 + 0x27 C++
mfc71d.dll!CDialog::OnCmdMsg(unsigned int nID=1029, int nCode=0, void * pExtra=0x00000000, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 88 + 0x18 C++
mfc71d.dll!CWnd::OnCommand(unsigned int wParam=1029, long lParam=1246560) Zeile 2550 C++
mfc71d.dll!CWnd::OnWndMsg(unsigned int message=273, unsigned int wParam=1029, long lParam=1246560, long * pResult=0x0012ed74) Zeile 1759 + 0x1c C++
mfc71d.dll!CWnd::WindowProc(unsigned int message=273, unsigned int wParam=1029, long lParam=1246560) Zeile 1745 + 0x1e C++
mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x00fb9b90, HWND__ * hWnd=0x00190582, unsigned int nMsg=273, unsigned int wParam=1029, long lParam=1246560) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x00190582, unsigned int nMsg=273, unsigned int wParam=1029, long lParam=1246560) Zeile 389 C++
mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x00190582, unsigned int nMsg=273, unsigned int wParam=1029, long lParam=1246560) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e06382()
USER32.DLL!77e07361()
USER32.DLL!77e209ef()
USER32.DLL!77e1c1de()
USER32.DLL!77e186f0()
mfc71d.dll!CWnd::OnWndMsg(unsigned int message=514, unsigned int wParam=0, long lParam=655378, long * pResult=0x00fbabe0) Zeile 1880 C++
mfc71d.dll!CWnd::WindowProc(unsigned int message=514, unsigned int wParam=0, long lParam=655378) Zeile 1746 + 0x1a C++
mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x00fbabe0, HWND__ * hWnd=0x00130560, unsigned int nMsg=514, unsigned int wParam=0, long lParam=655378) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x00130560, unsigned int nMsg=514, unsigned int wParam=0, long lParam=655378) Zeile 389 C++
mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x00130560, unsigned int nMsg=514, unsigned int wParam=0, long lParam=655378) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e04605()
NTDLL.DLL!77891baf()
USER32.DLL!77e0a7f2()
USER32.DLL!77e1ecf3()
USER32.DLL!77e1f46b()
mfc71d.dll!CWnd::IsDialogMessageA(tagMSG * lpMsg=0x00136a48) Zeile 200 C++
mfc71d.dll!CWnd::PreTranslateInput(tagMSG * lpMsg=0x00136a48) Zeile 4512 C++
mfc71d.dll!CDialog::PreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 83 C++
mfc71d.dll!CWnd::WalkPreTranslateTree(HWND__ * hWndStop=0x007404ba, tagMSG * pMsg=0x00136a48) Zeile 3129 + 0x12 C++
mfc71d.dll!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 238 + 0x12 C++
mfc71d.dll!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 795 + 0x9 C++
mfc71d.dll!AfxPreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 257 + 0xf C++
mfc71d.dll!AfxInternalPumpMessage() Zeile 183 + 0x18 C++
mfc71d.dll!CWinThread::PumpMessage() Zeile 916 C++
mfc71d.dll!AfxPumpMessage() Zeile 195 + 0xb C++
mfc71d.dll!CWnd::RunModalLoop(unsigned long dwFlags=4) Zeile 4566 + 0x5 C++
mfc71d.dll!CDialog::DoModal() Zeile 527 + 0xc C++
Stockbruegger.exe!CLieferscheine_Dialog::OnNMClickList1(tagNMHDR * pNMHDR=0x0012f85c, long * pResult=0x0012f63c) Zeile 3658 + 0x1a C++
mfc71d.dll!_AfxDispatchCmdMsg(CCmdTarget * pTarget=0x00fb8c38, unsigned int nID=1000, int nCode=65534, void (void)* pfn=0x004cd6bb, void * pExtra=0x0012f540, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 119 C++
mfc71d.dll!CCmdTarget::OnCmdMsg(unsigned int nID=1000, int nCode=65534, void * pExtra=0x0012f540, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 396 + 0x27 C++
mfc71d.dll!CDialog::OnCmdMsg(unsigned int nID=1000, int nCode=5177342, void * pExtra=0x0012f540, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 88 + 0x18 C++
mfc71d.dll!CWnd::OnNotify(unsigned int __formal=1000, long lParam=1243228, long * pResult=0x0012f63c) Zeile 2576 C++
mfc71d.dll!CWnd::OnWndMsg(unsigned int message=78, unsigned int wParam=1000, long lParam=1243228, long * pResult=0x0012f670) Zeile 1771 + 0x28 C++
mfc71d.dll!CWnd::WindowProc(unsigned int message=78, unsigned int wParam=1000, long lParam=1243228) Zeile 1745 + 0x1e C++
mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x00fb8c38, HWND__ * hWnd=0x0010051a, unsigned int nMsg=78, unsigned int wParam=1000, long lParam=1243228) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x0010051a, unsigned int nMsg=78, unsigned int wParam=1000, long lParam=1243228) Zeile 389 C++
mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x0010051a, unsigned int nMsg=78, unsigned int wParam=1000, long lParam=1243228) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e06382()
USER32.DLL!77e07361()
comctl32.dll!71715c1d()
USER32.DLL!77e04750()
comctl32.dll!71738e84()
comctl32.dll!71737085()
comctl32.dll!717388c5()
comctl32.dll!71738b08()
comctl32.dll!717171c3()
mfc71d.dll!AfxUnlockGlobals(int nLockType=7) Zeile 112 C++
mfc71d.dll!CWnd::OnWndMsg(unsigned int message=2082666204, unsigned int wParam=513, long lParam=1, long * pResult=0x007301ce) Zeile 1880 C++
0012faec()
mfc71d.dll!AfxCallWndProc(CWnd * pWnd=0x00fb8cac, HWND__ * hWnd=0x0019054c, unsigned int nMsg=513, unsigned int wParam=1, long lParam=7537102) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x0019054c, unsigned int nMsg=513, unsigned int wParam=1, long lParam=7537102) Zeile 389 C++
mfc71d.dll!AfxWndProcBase(HWND__ * hWnd=0x0019054c, unsigned int nMsg=513, unsigned int wParam=1, long lParam=7537102) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e04605()
USER32.DLL!77e19fd5()
USER32.DLL!77e1e0a6()
USER32.DLL!77e0a7f2()
USER32.DLL!77e1ecf3()
USER32.DLL!77e1f46b()
mfc71d.dll!CWnd::IsDialogMessageA(tagMSG * lpMsg=0x00136a48) Zeile 200 C++
mfc71d.dll!CWnd::PreTranslateInput(tagMSG * lpMsg=0x00136a48) Zeile 4512 C++
mfc71d.dll!CDialog::PreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 83 C++
Stockbruegger.exe!CLieferscheine_Dialog::PreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 3592 C++
mfc71d.dll!CWnd::WalkPreTranslateTree(HWND__ * hWndStop=0x007404ba, tagMSG * pMsg=0x00136a48) Zeile 3129 + 0x12 C++
mfc71d.dll!AfxInternalPreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 238 + 0x12 C++
mfc71d.dll!CWinThread::PreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 795 + 0x9 C++
mfc71d.dll!AfxPreTranslateMessage(tagMSG * pMsg=0x00136a48) Zeile 257 + 0xf C++
mfc71d.dll!AfxInternalPumpMessage() Zeile 183 + 0x18 C++
mfc71d.dll!CWinThread::PumpMessage() Zeile 916 C++
mfc71d.dll!CWinThread::Run() Zeile 637 + 0xb C++
mfc71d.dll!CWinApp::Run() Zeile 701 C++
mfc71d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00133952, int nCmdShow=1) Zeile 49 + 0xb C++
Stockbruegger.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00133952, int nCmdShow=1) Zeile 25 C++
Stockbruegger.exe!WinMainCRTStartup() Zeile 390 + 0x39 C
KERNEL32.DLL!77e989d5()
Stop here:
BOOL CGdiObject::Attach(HGDIOBJ
{
-----> ASSERT(m_hObject == NULL); // only attach once, detach on destroy if (hObject == NULL)
return FALSE;
CHandleMap* pMap = afxMapHGDIOBJ(TRUE); // create map if not exist
ASSERT(pMap != NULL);
pMap->SetPermanent(m_hObje
return TRUE;
}
Constructor...Destructor
IMPLEMENT_DYNAMIC(CAuftrag
CAuftragsHistory_Liefersch
: CDialog(CAuftragsHistory_L
, m_strLieferscheinNr(_T("")
, m_piAdoRecordBinding(NULL)
, m_strConnection(_T(""))
, m_strCmdText(_T(""))
, mb_Kennzahl_first_show_up(
{
m_fontUeberschrift=NULL;
m_fontBold =NULL;
m_fontSmall=NULL;
m_hDevMode=NULL;
m_hDevNames=NULL;
}
CAuftragsHistory_Liefersch
{
delete m_fontUeberschrift;
delete m_fontBold;
delete m_fontSmall;
}
//########################
void CAuftragsHistory_Liefersch
{
//Druckbereich in 0,1mm
pDC->SetMapMode(MM_LOMETRI
//------------------------
pInfo->SetMaxPage(1);
//------------------------
//--------------- Neue Schrift erstellen ------------------
if(m_fontUeberschrift==NUL
{
m_fontUeberschrift->Create
0,
0,
0,
600,
0,
0,
0,
DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS,
CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial");
}
//------------------------
}
//########################
void CAuftragsHistory_Liefersch
{
//Druckbereich in 0,1mm
pDC->SetMapMode(MM_LOMETRI
//obwohl dies schon in OnBeginPrinting steht
//ist es immer eine gute Idee es nochmal zuschreiben
//str_Datum_druck = aktuelle Datum
CFont* pOldFont = pDC->SelectObject(m_fontUe
//--------------- Tag - Datum - KW -------------------
pDC->TextOut(100,-50,"Vers
pDC->TextOut(350,-50,"Vers
pDC->TextOut(600,-50,"Wilh
//-------------------- Abmessung ---------------------
pDC->SelectObject(pOldFont
here comes later the delivery notice "Lieferschein"
//------------- Letzte Seite ermitteln ------------
UINT nEndPage = pInfo->m_nCurPage;
if(nEndPage==pInfo->GetMax
{
// pDC->SelectObject(pOldFont
// pDC->TextOut(100,-600,"Let
}
//------------------------
//------------- Erste Seite ermitteln ------------
UINT nStartPage = pInfo->m_nCurPage;
if(nStartPage==pInfo->GetM
{
// pDC->SelectObject(pOldFont
// pDC->TextOut(100,-600,"Ers
}
//------------------------
}
//########################
void CAuftragsHistory_Liefersch
{
delete m_fontUeberschrift;
}
//########################
bool CAuftragsHistory_Liefersch
{
// if NULL is passed, then assume we are setting app object's
// devmode and devnames
if (phDevMode == NULL || phDevNames == NULL)
{
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-1error");
return FALSE;
}
// Open printer
HANDLE hPrinter;
if (OpenPrinter(pszPrinterNam
{
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-2error");
return FALSE;
}
// obtain PRINTER_INFO_2 structure and close printer
DWORD dwBytesReturned, dwBytesNeeded;
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)GlobalAll
dwBytesNeeded);
if (GetPrinter(hPrinter, 2, (LPBYTE)p2, dwBytesNeeded,&dwBytesRetu
{
GlobalFree(p2);
ClosePrinter(hPrinter);
MessageBox("EPSON LQ-680Pro Port 2 Wiegekarte-3error");
return FALSE;
}
ClosePrinter(hPrinter);
// Allocate a global handle for DEVMODE
HGLOBAL hDevMode = GlobalAlloc(GHND, sizeof(*p2->pDevMode) + p2->pDevMode->dmDriverExtr
ASSERT(hDevMode);
DEVMODE* pDevMode = (DEVMODE*)GlobalLock(hDevM
ASSERT(pDevMode);
// copy DEVMODE data from PRINTER_INFO_2::pDevMode
memcpy(pDevMode, p2->pDevMode, sizeof(*p2->pDevMode) + p2->pDevMode->dmDriverExtr
GlobalUnlock(hDevMode);
// Compute size of DEVNAMES structure from PRINTER_INFO_2's data
DWORD drvNameLen = lstrlen(p2->pDriverName)+1
DWORD ptrNameLen = lstrlen(p2->pPrinterName)+
DWORD porNameLen = lstrlen(p2->pPortName)+1; // port name
// Allocate a global handle big enough to hold DEVNAMES.
HGLOBAL hDevNames = GlobalAlloc(GHND, sizeof(DEVNAMES) +(drvNameLen + ptrNameLen + porNameLen)*sizeof(TCHAR))
ASSERT(hDevNames);
DEVNAMES* pDevNames = (DEVNAMES*)GlobalLock(hDev
ASSERT(pDevNames);
// Copy the DEVNAMES information from PRINTER_INFO_2
// tcOffset = TCHAR Offset into structure
int tcOffset = sizeof(DEVNAMES)/sizeof(TC
ASSERT(sizeof(DEVNAMES) == tcOffset*sizeof(TCHAR));
pDevNames->wDriverOffset = tcOffset;
memcpy((LPTSTR)pDevNames + tcOffset, p2->pDriverName,drvNameLen
tcOffset += drvNameLen;
pDevNames->wDeviceOffset = tcOffset;
memcpy((LPTSTR)pDevNames + tcOffset, p2->pPrinterName,ptrNameLe
tcOffset += ptrNameLen;
pDevNames->wOutputOffset = tcOffset;
memcpy((LPTSTR)pDevNames + tcOffset, p2->pPortName,porNameLen*s
pDevNames->wDefault = 0;
GlobalUnlock(hDevNames);
GlobalFree(p2); // free PRINTER_INFO_2
// set the new hDevMode and hDevNames
*phDevMode = hDevMode;
*phDevNames = hDevNames;
return TRUE;
}
//########################
HANDLE CAuftragsHistory_Liefersch
{
// Return a handle to a copy of the data
// that the passed handle was for.
if (!h) return NULL;
BYTE* lpCopy;
BYTE* lp;
HANDLE hCopy;
DWORD dwLen = GlobalSize(h);
if (hCopy = GlobalAlloc(GHND, dwLen))
{
lpCopy = (BYTE*)GlobalLock(hCopy);
lp = (BYTE*)GlobalLock(h);
CopyMemory(lpCopy,lp,dwLen
GlobalUnlock(hCopy);
GlobalUnlock(h);
}
return hCopy;
}
//########################
//########################
void CAuftragsHistory_Liefersch
{
// if (GetPrinterDevice(_T("EPSO
// HANDLE hDevMode; m_hDevMode;
// HANDLE hDevNames; m_hDevNames;
m_hDevMode=m_hDevNames=NUL
if (GetPrinterDevice(_T("\\\\
// if (GetPrinterDevice(_T("Powe
{
AfxGetApp()->SelectPrinter
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS
//------------------------
if(AfxGetApp()->GetPrinter
{
LPDEVMODE dev=dlgPrint.GetDevMode();
GlobalUnlock(dev);
// hier kann man alle Atribute von DEVMODE angeben (siehe Microsoft DEVMODE Blätter)
// dev->dmOrientation=DMORIEN
//dev->dmOrientation=DMORI
// dev->dmPaperSize=DMPAPER_A
// dev->dmCopies=1;
// dev->dmDefaultSource=0;
// dev->dmPaperSize=DMPAPER_A
// dev->dmPaperLength=1020;
// dev->dmPaperWidth=1480;
// dev->dmDefaultSource=DMBIN
dev->dmOrientation=DMORIEN
dev->dmPaperSize=DMPAPER_A
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//========================
// if(dlgPrint.DoModal()==IDO
// {
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames);
m_hDevMode = CopyHandle(dlgPrint.m_pd.h
m_hDevNames = CopyHandle(dlgPrint.m_pd.h
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC()
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr
dc.m_bPrinting=TRUE;
//------------------------
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0
//~~~~~~~~~~~~~~~~~~~~~~~~
OnBeginPrinting(&dc,&pInfo
//~~~~~~~~~~~~~~~~~~~~~~~~
//========================
for(UINT page=pInfo.GetMinPage();pa
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~
bPrintingOK=(dc.EndPage()>
}
//========================
//~~~~~~~~~~~~~~~~~~~~~~~~
OnEndPrinting(&dc,&pInfo);
//~~~~~~~~~~~~~~~~~~~~~~~~
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
dc.DeleteDC();
//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h
GlobalFree(dlgPrint.m_pd.h
}
//xxxxxxxxxxxxxxxxxxxxxxxx
}
//########################
void CAuftragsHistory_Liefersch
{
int iLieferscheinNr=atoi(m_str
Sleep(1000);
//===============
Drucken_weiss();
Sleep(1000);
if(iLieferscheinNr<200000)
if(iLieferscheinNr>200000)
//########################
ASKER
Hi Zoppo, your are right.
I changed that.
But I still got a crash...not allways but very often.
I even erased all font and all printing in OnPrint(CDC* pDC, CPrintInfo* pInfo)
so I only get a white paper....now it stop again here:
Call Stack:
KERNEL32DLL!77eaf870()
I don´t know why...please help, thanks Thomas
I changed that.
But I still got a crash...not allways but very often.
I even erased all font and all printing in OnPrint(CDC* pDC, CPrintInfo* pInfo)
so I only get a white paper....now it stop again here:
Call Stack:
KERNEL32DLL!77eaf870()
I don´t know why...please help, thanks Thomas
ASKER
sorry...I was wrong....if I clean out everything for a white page and
clean out OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
so no new font....it runs until now wiht no crash....so I gues like Sara it comes from the font
please help, thanks....I would like to get this to work
clean out OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
so no new font....it runs until now wiht no crash....so I gues like Sara it comes from the font
please help, thanks....I would like to get this to work
Hm - hard to say, that's a lot of code. Could you tell where (in which function/line) in your code the crash happens?
BTW: I think the code as it is above (including the modification from my previous comment) will crash when the printing functionality is called more than once within the lifetime of the dialog since with 'OnEndPrinting' the font is deleted but not set to NULL so the 'OnBeginPrinting' won't create a new CFont instance, instead it uses the now invalid pointer. Change 'OnEndPrinting' to look like this:
void CAuftragsHistory_Liefersch ein_Dialog ::OnEndPri nting(CDC* pDC, CPrintInfo* pInfo)
{
delete m_fontUeberschrift;
m_fontUeberschrift = NULL;
}
ZOPPO
BTW: I think the code as it is above (including the modification from my previous comment) will crash when the printing functionality is called more than once within the lifetime of the dialog since with 'OnEndPrinting' the font is deleted but not set to NULL so the 'OnBeginPrinting' won't create a new CFont instance, instead it uses the now invalid pointer. Change 'OnEndPrinting' to look like this:
void CAuftragsHistory_Liefersch
{
delete m_fontUeberschrift;
m_fontUeberschrift = NULL;
}
ZOPPO
ASKER
void CAuftragsHistory_Liefersch ein_Dialog ::OnEndPri nting(CDC* pDC, CPrintInfo* pInfo)
{
delete m_fontUeberschrift;
m_fontUeberschrift = NULL;
}
sorry I forgot...I did this allready
{
delete m_fontUeberschrift;
m_fontUeberschrift = NULL;
}
sorry I forgot...I did this allready
ok - then if it still crashs please tell where exactly in your code it crashs ...
ASKER
Hello Zoppo,
there is no stop at my code.
I try to load some hardcopy that I made...but I thing the internet site will not work....loading a image....
from loading:An unexpected error occurred. Please try again later.
So I got the following window:
Unbehandelte Ausnahme bei 0x77eae566 in Stockbruegger.exe....
Zugriffsverletzung-Lesepos ition 0x0017fb54
and a second
für die aktuelle Position ist kein Quellcode verfügbar
and in dissasembly anzeigen
77EAE566 mov al,byte ptr [ebx]
there is no stop at my code.
I try to load some hardcopy that I made...but I thing the internet site will not work....loading a image....
from loading:An unexpected error occurred. Please try again later.
So I got the following window:
Unbehandelte Ausnahme bei 0x77eae566 in Stockbruegger.exe....
Zugriffsverletzung-Lesepos
and a second
für die aktuelle Position ist kein Quellcode verfügbar
and in dissasembly anzeigen
77EAE566 mov al,byte ptr [ebx]
But is there maybe any function (from your code) call shown in the call stack below the current position?
One more problem I found is in this code:
Try this instead:
ZOPPO
One more problem I found is in this code:
LPDEVMODE dev=dlgPrint.GetDevMode();
GlobalUnlock(dev);
...
dev->dmOrientation=DMORIENT_PORTRAIT;
dev->dmPaperSize=DMPAPER_A4;
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERWIDTH|DM_ORIENTATION|DM_DEFAULTSOURCE;
The 'GlobalUnlock' is called to early - you must not access any data via 'dev' after you unlocked it.Try this instead:
LPDEVMODE dev=dlgPrint.GetDevMode();
...
dev->dmOrientation=DMORIENT_PORTRAIT;
dev->dmPaperSize=DMPAPER_A4;
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERWIDTH|DM_ORIENTATION|DM_DEFAULTSOURCE;
GlobalUnlock(dev);
ZOPPO
you should differ between a crash like the one you had when using the pointer m_fontUeberschrift without doing a 'new CFont' before, and an ASSERT in one of windows functions.
the assertion in Attach function only happens when you create the same font a multiple time. in my opinion you should it create only once and never delete the pointer and never delete the object (resource) before destructing the view.
Sara
the assertion in Attach function only happens when you create the same font a multiple time. in my opinion you should it create only once and never delete the pointer and never delete the object (resource) before destructing the view.
Sara
the exception you had is a crash and most probably a pointer error. if using member pointers you always need to initialize them with NULL in the constructor. also any local pointer should be initialized. and whenever you make a delete, initialize the pointer to NULL again. that is a must for member pointers.
Sara
Sara
ASKER
I changed that....same result
But is there maybe any function (from your code) call shown in the call stack below the current position?
Stockbruegger.exe!CAuftrag sHistory_L ieferschei n_Dialog:: OnBeginPri nting(CDC * pDC=0x0012e914, CPrintInfo * pInfo=0x0012e898) Zeile 2052 C++
Stockbruegger.exe!CAuftrag sHistory_L ieferschei n_Dialog:: Drucken_we iss() Zeile 1978 C++
StockbruStockbruegger.exe! CLiefersch eine_Dialo g::OnNMCli ckList1(ta gNMHDR * pNMHDR=0x0012f85c, long * pResult=0x0012f63c) Zeile 3658 + 0x1a C++
egger.exe!CAuftragsHistory _Liefersch ein_Dialog ::OnBnClic kedButton_ Drucken() Zeile 1647 C++
Stockbruegger.exe!CLiefers cheine_Dia log::PreTr anslateMes sage(tagMS G * pMsg=0x00136a48) Zeile 3592 C++
Stockbruegger.exe!WinMain( HINSTANCE_ _ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00133952, int nCmdShow=1) Zeile 25 C++
Stockbruegger.exe!WinMainC RTStartup( ) Zeile 390 + 0x39 C
OnBnClickedButton_Drucken( ) will call Drucken_weis();
did you mean that?
But is there maybe any function (from your code) call shown in the call stack below the current position?
Stockbruegger.exe!CAuftrag
Stockbruegger.exe!CAuftrag
StockbruStockbruegger.exe!
egger.exe!CAuftragsHistory
Stockbruegger.exe!CLiefers
Stockbruegger.exe!WinMain(
Stockbruegger.exe!WinMainC
OnBnClickedButton_Drucken(
did you mean that?
ok - please when crash happened double-click the first line in the call stack where your code is mentioned, so here:
Stockbruegger.exe!CAuftrag sHistory_L ieferschei n_Dialog:: OnBeginPri nting
Then the debugger should jump to the place in your code which leads to the crash ... please post this function and add a hint where exactly the debugger jumped to.
Stockbruegger.exe!CAuftrag
Then the debugger should jump to the place in your code which leads to the crash ... please post this function and add a hint where exactly the debugger jumped to.
ASKER
sorry Zoppo....that was the call stack before the font error.
now I have no line to click = only Call Stack:
KERNEL32DLL!77eaf870()
now I have no line to click = only Call Stack:
KERNEL32DLL!77eaf870()
Hm - that's not good - are you sure the debugger hasn't accidentally switched to another thread? Open threads-window (Debug->Windows->Threads) and check that the 'Main Thread' is the current thread.
Without knowing which function really leads to the stack it's quite difficult - IMO you first should try to step through your code with the debugger to find if your code is crashing anywhere or if the crash happens after your code has run completeley. In the latter case it may be that something in your code somehow disturb something which later on leads to a crash.
Without knowing which function really leads to the stack it's quite difficult - IMO you first should try to step through your code with the debugger to find if your code is crashing anywhere or if the crash happens after your code has run completeley. In the latter case it may be that something in your code somehow disturb something which later on leads to a crash.
ASKER
Dear Zoppo,
I will try this tomorrow...Schönen Abend. Best regards Thomas
I will try this tomorrow...Schönen Abend. Best regards Thomas
ASKER
Could you post the complete stack too?
ASKER
KERNEL32.DLL!77e9bcb1()
KERNEL32.DLL!77e9bcb1()
oledb32.dll!1f891ff6()
oledb32.dll!1f895892()
oledb32.dll!1f895869()
oledb32.dll!1f89554a()
msvcr71d.dll!_CxxThrowExce ption(void * pExceptionObject=0x0012dd9 4, const _s__ThrowInfo * pThrowInfo=0x006b023c) + 0x39 C++
Stockbruegger.exe!_com_rai se_error(H RESULT hr=-2146825267, IErrorInfo * perrinfo=0x02ff8ff0) Zeile 19 C++
Stockbruegger.exe!_com_iss ue_errorex (HRESULT hr=-2146825267, IUnknown * punk=0x01d20f60, const _GUID & riid={...}) Zeile 67 C++
> Stockbruegger.exe!ADOCG::R ecordset15 ::MoveFirs t() Zeile 1531 C++ Stockbruegger.exe!CAuftrag sHistory_L ieferschei n_Dialog:: Rechnung(A TL::CStrin gT<char,St rTraitMFC_ DLL<char,A TL::ChTrai tsCRT<char > > > str_RechnungsNR={...}, ATL::CStringT<char,StrTrai tMFC_DLL<c har,ATL::C hTraitsCRT <char> > > str_Typ={...}, ATL::CStringT<char,StrTrai tMFC_DLL<c har,ATL::C hTraitsCRT <char> > > str_Guete={...}, int Zeile=1, double AuftragNr=0.00000000000000 000) Zeile 1451 C++
Stockbruegger.exe!CAuftrag sHistory_L ieferschei n_Dialog:: Liefersche in_Lesen() Zeile 923 C++
Stockbruegger.exe!CAuftrag sHistory_L ieferschei n_Dialog:: OnTimer(un signed int nIDEvent=1) Zeile 1589 C++
mfc71d.dll!CWnd::OnWndMsg( unsigned int message=275, unsigned int wParam=1, long lParam=0, long * pResult=0x0012f0ec) Zeile 2027 C++
mfc71d.dll!CWnd::WindowPro c(unsigned int message=275, unsigned int wParam=1, long lParam=0) Zeile 1745 + 0x1e C++
mfc71d.dll!AfxCallWndProc( CWnd * pWnd=0x00fb9b40, HWND__ * hWnd=0x0006046e, unsigned int nMsg=275, unsigned int wParam=1, long lParam=0) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND __ * hWnd=0x0006046e, unsigned int nMsg=275, unsigned int wParam=1, long lParam=0) Zeile 389 C++
mfc71d.dll!AfxWndProcBase( HWND__ * hWnd=0x0006046e, unsigned int nMsg=275, unsigned int wParam=1, long lParam=0) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e04605()
mfc71d.dll!CWnd::AttachCon trolSite(C HandleMap * pMap=0x00fb6088) Zeile 445 + 0x16 C++
mfc71d.dll!CWnd::FromHandl e(HWND__ * hWnd=0x000704f2) Zeile 311 C++
mfc71d.dll!CWnd::GetTopLev elParent() Zeile 2623 C++
00000001()
USER32.DLL!77e05b77()
mfc71d.dll!AfxInternalPump Message() Zeile 188 C++
mfc71d.dll!CWinThread::Pum pMessage() Zeile 916 C++
mfc71d.dll!AfxPumpMessage( ) Zeile 195 + 0xb C++
mfc71d.dll!CWnd::RunModalL oop(unsign ed long dwFlags=4) Zeile 4566 + 0x5 C++
mfc71d.dll!CDialog::DoModa l() Zeile 527 + 0xc C++
Stockbruegger.exe!CLiefers cheine_Dia log::OnNMC lickList1( tagNMHDR * pNMHDR=0x0012f85c, long * pResult=0x0012f63c) Zeile 3658 + 0x1a C++
mfc71d.dll!_AfxDispatchCmd Msg(CCmdTa rget * pTarget=0x00fb8be8, unsigned int nID=1000, int nCode=65534, void (void)* pfn=0x004cd6bb, void * pExtra=0x0012f540, unsigned int nSig=57, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 119 C++
mfc71d.dll!CCmdTarget::OnC mdMsg(unsi gned int nID=1000, int nCode=65534, void * pExtra=0x0012f540, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 396 + 0x27 C++
mfc71d.dll!CDialog::OnCmdM sg(unsigne d int nID=1000, int nCode=5177342, void * pExtra=0x0012f540, AFX_CMDHANDLERINFO * pHandlerInfo=0x00000000) Zeile 88 + 0x18 C++
mfc71d.dll!CWnd::OnNotify( unsigned int __formal=1000, long lParam=1243228, long * pResult=0x0012f63c) Zeile 2576 C++
mfc71d.dll!CWnd::OnWndMsg( unsigned int message=78, unsigned int wParam=1000, long lParam=1243228, long * pResult=0x0012f670) Zeile 1771 + 0x28 C++
mfc71d.dll!CWnd::WindowPro c(unsigned int message=78, unsigned int wParam=1000, long lParam=1243228) Zeile 1745 + 0x1e C++
mfc71d.dll!AfxCallWndProc( CWnd * pWnd=0x00fb8be8, HWND__ * hWnd=0x000504e6, unsigned int nMsg=78, unsigned int wParam=1000, long lParam=1243228) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND __ * hWnd=0x000504e6, unsigned int nMsg=78, unsigned int wParam=1000, long lParam=1243228) Zeile 389 C++
mfc71d.dll!AfxWndProcBase( HWND__ * hWnd=0x000504e6, unsigned int nMsg=78, unsigned int wParam=1000, long lParam=1243228) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e06382()
USER32.DLL!77e07361()
comctl32.dll!71715c1d()
NTDLL.DLL!77891baf()
comctl32.dll!71738e84()
comctl32.dll!71737085()
comctl32.dll!717388c5()
comctl32.dll!71738b08()
comctl32.dll!717171c3()
mfc71d.dll!AfxUnlockGlobal s(int nLockType=7) Zeile 112 C++
mfc71d.dll!CWnd::OnWndMsg( unsigned int message=2082666204, unsigned int wParam=513, long lParam=1, long * pResult=0x003f01ca) Zeile 1816 C++
0012faec()
mfc71d.dll!AfxCallWndProc( CWnd * pWnd=0x00fb8c5c, HWND__ * hWnd=0x000404e4, unsigned int nMsg=513, unsigned int wParam=1, long lParam=4129226) Zeile 241 + 0x1a C++
mfc71d.dll!AfxWndProc(HWND __ * hWnd=0x000404e4, unsigned int nMsg=513, unsigned int wParam=1, long lParam=4129226) Zeile 389 C++
mfc71d.dll!AfxWndProcBase( HWND__ * hWnd=0x000404e4, unsigned int nMsg=513, unsigned int wParam=1, long lParam=4129226) Zeile 209 + 0x15 C++
USER32.DLL!77e2a454()
USER32.DLL!77e04605()
USER32.DLL!77e07361()
USER32.DLL!77e0a7f2()
USER32.DLL!77e1ecf3()
USER32.DLL!77e1f46b()
mfc71d.dll!CWnd::IsDialogM essageA(ta gMSG * lpMsg=0x00136a48) Zeile 200 C++
mfc71d.dll!CWnd::PreTransl ateInput(t agMSG * lpMsg=0x00136a48) Zeile 4512 C++
mfc71d.dll!CDialog::PreTra nslateMess age(tagMSG * pMsg=0x00136a48) Zeile 83 C++
Stockbruegger.exe!CLiefers cheine_Dia log::PreTr anslateMes sage(tagMS G * pMsg=0x00136a48) Zeile 3592 C++
mfc71d.dll!CWnd::WalkPreTr anslateTre e(HWND__ * hWndStop=0x000704f2, tagMSG * pMsg=0x00136a48) Zeile 3129 + 0x12 C++
mfc71d.dll!AfxInternalPreT ranslateMe ssage(tagM SG * pMsg=0x00136a48) Zeile 238 + 0x12 C++
mfc71d.dll!CWinThread::Pre TranslateM essage(tag MSG * pMsg=0x00136a48) Zeile 795 + 0x9 C++
mfc71d.dll!AfxPreTranslate Message(ta gMSG * pMsg=0x00136a48) Zeile 257 + 0xf C++
mfc71d.dll!AfxInternalPump Message() Zeile 183 + 0x18 C++
mfc71d.dll!CWinThread::Pum pMessage() Zeile 916 C++
mfc71d.dll!CWinThread::Run () Zeile 637 + 0xb C++
mfc71d.dll!CWinApp::Run() Zeile 701 C++
mfc71d.dll!AfxWinMain(HINS TANCE__ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00133952, int nCmdShow=1) Zeile 49 + 0xb C++
Stockbruegger.exe!WinMain( HINSTANCE_ _ * hInstance=0x00400000, HINSTANCE__ * hPrevInstance=0x00000000, char * lpCmdLine=0x00133952, int nCmdShow=1) Zeile 25 C++
Stockbruegger.exe!WinMainC RTStartup( ) Zeile 390 + 0x39 C
KERNEL32.DLL!77e989d5()
inline HRESULT Recordset15::MoveFirst ( ) {
HRESULT _hr = raw_MoveFirst();
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr; <----------- green arrow here}
Hi Zoppo,
I am sorry...it is not my day.
Now.. I got an error when I call my window (the window where I print with)
I don´t know what is so wrong…can you help, thank you.
I tried again...and now I can print about 20 white pages....I go back between the windows and print print...
Suddenly the error comes with no call stack only=KERNEL32DLL!77eaf870( )
Please be so kind to help, thank you
1.BMP
KERNEL32.DLL!77e9bcb1()
oledb32.dll!1f891ff6()
oledb32.dll!1f895892()
oledb32.dll!1f895869()
oledb32.dll!1f89554a()
msvcr71d.dll!_CxxThrowExce
Stockbruegger.exe!_com_rai
Stockbruegger.exe!_com_iss
> Stockbruegger.exe!ADOCG::R
Stockbruegger.exe!CAuftrag
Stockbruegger.exe!CAuftrag
mfc71d.dll!CWnd::OnWndMsg(
mfc71d.dll!CWnd::WindowPro
mfc71d.dll!AfxCallWndProc(
mfc71d.dll!AfxWndProc(HWND
mfc71d.dll!AfxWndProcBase(
USER32.DLL!77e2a454()
USER32.DLL!77e04605()
mfc71d.dll!CWnd::AttachCon
mfc71d.dll!CWnd::FromHandl
mfc71d.dll!CWnd::GetTopLev
00000001()
USER32.DLL!77e05b77()
mfc71d.dll!AfxInternalPump
mfc71d.dll!CWinThread::Pum
mfc71d.dll!AfxPumpMessage(
mfc71d.dll!CWnd::RunModalL
mfc71d.dll!CDialog::DoModa
Stockbruegger.exe!CLiefers
mfc71d.dll!_AfxDispatchCmd
mfc71d.dll!CCmdTarget::OnC
mfc71d.dll!CDialog::OnCmdM
mfc71d.dll!CWnd::OnNotify(
mfc71d.dll!CWnd::OnWndMsg(
mfc71d.dll!CWnd::WindowPro
mfc71d.dll!AfxCallWndProc(
mfc71d.dll!AfxWndProc(HWND
mfc71d.dll!AfxWndProcBase(
USER32.DLL!77e2a454()
USER32.DLL!77e06382()
USER32.DLL!77e07361()
comctl32.dll!71715c1d()
NTDLL.DLL!77891baf()
comctl32.dll!71738e84()
comctl32.dll!71737085()
comctl32.dll!717388c5()
comctl32.dll!71738b08()
comctl32.dll!717171c3()
mfc71d.dll!AfxUnlockGlobal
mfc71d.dll!CWnd::OnWndMsg(
0012faec()
mfc71d.dll!AfxCallWndProc(
mfc71d.dll!AfxWndProc(HWND
mfc71d.dll!AfxWndProcBase(
USER32.DLL!77e2a454()
USER32.DLL!77e04605()
USER32.DLL!77e07361()
USER32.DLL!77e0a7f2()
USER32.DLL!77e1ecf3()
USER32.DLL!77e1f46b()
mfc71d.dll!CWnd::IsDialogM
mfc71d.dll!CWnd::PreTransl
mfc71d.dll!CDialog::PreTra
Stockbruegger.exe!CLiefers
mfc71d.dll!CWnd::WalkPreTr
mfc71d.dll!AfxInternalPreT
mfc71d.dll!CWinThread::Pre
mfc71d.dll!AfxPreTranslate
mfc71d.dll!AfxInternalPump
mfc71d.dll!CWinThread::Pum
mfc71d.dll!CWinThread::Run
mfc71d.dll!CWinApp::Run() Zeile 701 C++
mfc71d.dll!AfxWinMain(HINS
Stockbruegger.exe!WinMain(
Stockbruegger.exe!WinMainC
KERNEL32.DLL!77e989d5()
inline HRESULT Recordset15::MoveFirst ( ) {
HRESULT _hr = raw_MoveFirst();
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr; <----------- green arrow here}
Hi Zoppo,
I am sorry...it is not my day.
Now.. I got an error when I call my window (the window where I print with)
I don´t know what is so wrong…can you help, thank you.
I tried again...and now I can print about 20 white pages....I go back between the windows and print print...
Suddenly the error comes with no call stack only=KERNEL32DLL!77eaf870(
Please be so kind to help, thank you
1.BMP
it is a com error when accessing the database in function:
Stockbruegger.exe!ADOCG::R ecordset15 ::MoveFirs t() Zeile 1531
it looks like as you did get an error when connecting to db or loading a recordset but ignored the error and tried to move within the recordset (== result of your query) nevertheless.
can you post the source where you access the database?
Sara
Stockbruegger.exe!ADOCG::R
it looks like as you did get an error when connecting to db or loading a recordset but ignored the error and tried to move within the recordset (== result of your query) nevertheless.
can you post the source where you access the database?
Sara
when you suddenly encounter strange errors which occur only sometimes and at different locations, it mostly is cause you worked on corrupted memory somehow. such corruption often happened when using uninitialized pointers or use pointers after delete or access arrays beyond array bounds.
so it is important to initialize each pointer (array) you were using. always allocate memory to a pointer with new before use but also check that it is NULL before assigning a new pointer value. after delete, set the pointer to NULL such that you directly see when your code was using the pointer again.
Sara
so it is important to initialize each pointer (array) you were using. always allocate memory to a pointer with new before use but also check that it is NULL before assigning a new pointer value. after delete, set the pointer to NULL such that you directly see when your code was using the pointer again.
Sara
when the exception code is 0xc00000005 access violation, it is for 99 percent of all cases a pointer error, such that using a NULL pointer or pointer after delete.
unfortunately the default of exception handling by the debugger is to first throw the exception and hope it will be caught by a try-catch-block somewhere. if there is no such handling the debugger finally breaks in some kernel function. for debugging purposes it is in my opinion always better when the debugger breaks immediately when an invalid pointer was detected. you can force the debugger to do so by going to menu Debug - Exceptions ... - Win32 Exceptions (your local version of visual studio should have Debug - Ausnahmen ... - Win32 Exceptions) and check the box right of c000005 - Access violation. that will cause the debugger to break earlier next time when the exception happened such that the call stack might show the code where the error occured.
same you could do for the com error which is in section C++ Exceptions though i think the com error wasn't the reason for the crash but happened only because the memory already was corrupted.
Sara
unfortunately the default of exception handling by the debugger is to first throw the exception and hope it will be caught by a try-catch-block somewhere. if there is no such handling the debugger finally breaks in some kernel function. for debugging purposes it is in my opinion always better when the debugger breaks immediately when an invalid pointer was detected. you can force the debugger to do so by going to menu Debug - Exceptions ... - Win32 Exceptions (your local version of visual studio should have Debug - Ausnahmen ... - Win32 Exceptions) and check the box right of c000005 - Access violation. that will cause the debugger to break earlier next time when the exception happened such that the call stack might show the code where the error occured.
same you could do for the com error which is in section C++ Exceptions though i think the com error wasn't the reason for the crash but happened only because the memory already was corrupted.
Sara
ASKER
ASKER
ASKER
Sara, I had just some breakdowns....but nothing in call stack only
KERNEL32DLL!77eaf870()
KERNEL32DLL!77eaf870()
ASKER
Where come the error from?
The crash only happens after printing....even a white page....
So is the pointer error etc. only from the printing code? Or could that be that only after my printing code
the program crash down even the pointer error comes from any other places in my code?
I did printing before like this (with a Dialogbox) and so far I had no error like this
Could that be that this comes from GetPrinterDevice?
The crash only happens after printing....even a white page....
So is the pointer error etc. only from the printing code? Or could that be that only after my printing code
the program crash down even the pointer error comes from any other places in my code?
I did printing before like this (with a Dialogbox) and so far I had no error like this
Could that be that this comes from GetPrinterDevice?
in win32-exceptions you need to select the 0xc000005 access violation before checking the radio box "wenn die Asunahme ausgeloest wird ... In den Debugger springen".
please post your current code regarding printing.
Sara
please post your current code regarding printing.
Sara
ASKER
This is a printing with Dialogbox from a other dialog with no error....but I would like to print without a printerdialog box and to print 3 copies = 3 tray white red green.....so I guess I have to use GetPrinterDevice
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS |PD_USEDEV MODECOPIES ANDCOLLATE ,this);
//-------------- Eigenschaftenbutton PrintDialog disable -----------
dlgPrint.m_pd.Flags |= PD_ENABLEPRINTHOOK;
dlgPrint.m_pd.lpfnPrintHoo k = PrintHookProc3;
//------------------------ ---------- ---------- ---------- ---------- -
if(dlgPrint.DoModal()==IDO K)
{
CDC dc;
dc.Attach(dlgPrint.GetPrin terDC());
dc.m_bPrinting=TRUE;
//------------------------ -- DEVMODE -------------------------- ---------- ---
LPDEVMODE dev=dlgPrint.GetDevMode();
GlobalUnlock(dev);
// if(m_bDruckenListe==false) dev->dmOrientation=DMORIEN T_PORTRAIT ; //Hochformat
//if(m_bDruckenListe==true ) dev->dmOrientation=DMORIEN T_LANDSCAP E; //Querformat
dev->dmOrientation=DMORIEN T_LANDSCAP E; //Querformat
dev->dmPaperSize=DMPAPER_A 4;
// dev->dmPaperSize=DMPAPER_A 5;
// dev->dmPaperLength=1020;
// dev->dmPaperWidth=1480;
dev->dmCopies=dlgPrint.Get Copies();
dev->dmDefaultSource=DMBIN _AUTO;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW IDTH|DM_OR IENTATION| DM_DEFAULT SOURCE;
// dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW IDTH|DM_OR IENTATION| DM_DEFAULT SOURCE|
// DM_SCALE|DM_COPIES|DM_PRIN TQUALITY|D M_POSITION ;
dc.ResetDC(dev);
//GlobalUnlock(dev);
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------ ---------- ---------- ---------- ---------- ---------
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------ ---------- -
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0 ,0,dc.GetD eviceCaps( HORZRES), dc.GetDeviceCaps(VERTRES)) ;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnBeginPrinting(&dc,&pInfo ); // call prepare
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
//======================== ========== ========== ========== ========== ========== ====
for(UINT page=pInfo.GetMinPage();pa ge<=pInfo. GetMaxPage () &&bPrintingOK ; page++)
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
bPrintingOK=(dc.EndPage()> 0);
}
//======================== ========== ========== ========== ========== ========== ====
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnEndPrinting(&dc,&pInfo); // call your clean up
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
dc.DeleteDC();
}
}
//######################## ########## ########## ########## ########## ########## ########## ########
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS
//-------------- Eigenschaftenbutton PrintDialog disable -----------
dlgPrint.m_pd.Flags |= PD_ENABLEPRINTHOOK;
dlgPrint.m_pd.lpfnPrintHoo
//------------------------
if(dlgPrint.DoModal()==IDO
{
CDC dc;
dc.Attach(dlgPrint.GetPrin
dc.m_bPrinting=TRUE;
//------------------------
LPDEVMODE dev=dlgPrint.GetDevMode();
GlobalUnlock(dev);
// if(m_bDruckenListe==false)
//if(m_bDruckenListe==true
dev->dmOrientation=DMORIEN
dev->dmPaperSize=DMPAPER_A
// dev->dmPaperSize=DMPAPER_A
// dev->dmPaperLength=1020;
// dev->dmPaperWidth=1480;
dev->dmCopies=dlgPrint.Get
dev->dmDefaultSource=DMBIN
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW
// dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW
// DM_SCALE|DM_COPIES|DM_PRIN
dc.ResetDC(dev);
//GlobalUnlock(dev);
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0
//~~~~~~~~~~~~~~~~~~~~~~~~
OnBeginPrinting(&dc,&pInfo
//~~~~~~~~~~~~~~~~~~~~~~~~
//========================
for(UINT page=pInfo.GetMinPage();pa
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~
bPrintingOK=(dc.EndPage()>
}
//========================
//~~~~~~~~~~~~~~~~~~~~~~~~
OnEndPrinting(&dc,&pInfo);
//~~~~~~~~~~~~~~~~~~~~~~~~
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
dc.DeleteDC();
}
}
//########################
ASKER
in win32-exceptions you need to select the 0xc000005 access violation before checking the radio box "wenn die Asunahme ausgeloest wird ... In den Debugger springen".
I did this...but the only thing I get in call stack is
KERNEL32DLL!77eaf870()
I did this...but the only thing I get in call stack is
KERNEL32DLL!77eaf870()
Hm - in the screenshot with the threads you can see the function where it happens (CLieferscheine_Dialog::On Print). It's strange that debugger doesn't show this function in the call stack too.
In the last code you posted you again have the 'GlobalUnlock(dev);' in the wrong place before accessing 'dev' members.
In the last code you posted you again have the 'GlobalUnlock(dev);' in the wrong place before accessing 'dev' members.
ASKER
I guess this is important!!!!!!!
To all, one thing I found out :From OnBnClickedButton_Drucken( ) I will call Drucken_weiss();
To start the printing
When I put a breakbpoint to the Sleep(1000); behind Drucken_weiss();
And the crash happened it breaks somewhere in Drucken_weiss(); because there is not stop at my breakpoint
I put a breakpoint here: GlobalFree(dlgPrint.m_pd.h DevNames); in Drucken_weiss();
And it stops here after that it breaks and goes not back to OnBnClickedButton_Drucken( )----Sleep (1000)
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::OnBnClic kedButton_ Drucken()
int iLieferscheinNr=atoi(m_str Liefersche inNr);//Me mberVariab le
Sleep(1000);
//===============
Drucken_weiss();
Sleep(1000); //breakpoint here}
if(iLieferscheinNr<200000) MessageBox(" Drucke Lieferschein " +m_strLieferscheinNr);
if(iLieferscheinNr>200000) MessageBox(" Drucke Warenbegleitschein " +m_strLieferscheinNr);
//===============
//######################## ########## ########## ########## ########## ########## ########## ###
void CAuftragsHistory_Liefersch ein_Dialog ::Drucken_ weiss(void )
{
m_hDevMode=m_hDevNames=NUL L; //<-----------
if (GetPrinterDevice(_T("\\\\ DSERVER\\B rother HL-7050 series"), &m_hDevNames, &m_hDevMode))
{
AfxGetApp()->SelectPrinter (m_hDevNam es, m_hDevMode);
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS |PD_USEDEV MODECOPIES ANDCOLLATE , this);
//------------------------ --- Papier Auswahl DEVMODE -------------------------- --------
if(AfxGetApp()->GetPrinter DeviceDefa ults(&dlgP rint.m_pd) )
{
LPDEVMODE dev=dlgPrint.GetDevMode();
dev->dmOrientation=DMORIEN T_PORTRAIT ;
dev->dmPaperSize=DMPAPER_A 4;
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW IDTH|DM_OR IENTATION| DM_DEFAULT SOURCE;
GlobalUnlock(dev);
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------ ---------- ---------- ---------- ---------- ---------- -------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//======================== ========== ========== ========== ========== ========== ========== ========== =
// if(dlgPrint.DoModal()==IDO K) //Ohne CPrintDialogBox
// {
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames);
m_hDevMode = CopyHandle(dlgPrint.m_pd.h DevMode); // Save new copies.
m_hDevNames = CopyHandle(dlgPrint.m_pd.h DevNames); // Save new copies.
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC() ;
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr interDC()) ;
dc.m_bPrinting=TRUE;
//------------------------ ---------- --
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------ ---------- -
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0 ,0,dc.GetD eviceCaps( HORZRES), dc.GetDeviceCaps(VERTRES)) ;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnBeginPrinting(&dc,&pInfo ); // call prepare
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
//======================== ========== ========== ========== ========== ========== ====
for(UINT page=pInfo.GetMinPage();pa ge<=pInfo. GetMaxPage () &&bPrintingOK ; page++)
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
bPrintingOK=(dc.EndPage()> 0);
}
//======================== ========== ========== ========== ========== ========== ====
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
OnEndPrinting(&dc,&pInfo); // call your clean up
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
dc.DeleteDC();
//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h DevMode);
GlobalFree(dlgPrint.m_pd.h DevNames); breakpoint here
}
//xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxx
}
//######################## ########## ########## ########## ########## ########## ########## ###
To all, one thing I found out :From OnBnClickedButton_Drucken(
To start the printing
When I put a breakbpoint to the Sleep(1000); behind Drucken_weiss();
And the crash happened it breaks somewhere in Drucken_weiss(); because there is not stop at my breakpoint
I put a breakpoint here: GlobalFree(dlgPrint.m_pd.h
And it stops here after that it breaks and goes not back to OnBnClickedButton_Drucken(
//########################
void CAuftragsHistory_Liefersch
int iLieferscheinNr=atoi(m_str
Sleep(1000);
//===============
Drucken_weiss();
Sleep(1000); //breakpoint here}
if(iLieferscheinNr<200000)
if(iLieferscheinNr>200000)
//===============
//########################
void CAuftragsHistory_Liefersch
{
m_hDevMode=m_hDevNames=NUL
if (GetPrinterDevice(_T("\\\\
{
AfxGetApp()->SelectPrinter
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS
//------------------------
if(AfxGetApp()->GetPrinter
{
LPDEVMODE dev=dlgPrint.GetDevMode();
dev->dmOrientation=DMORIEN
dev->dmPaperSize=DMPAPER_A
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW
GlobalUnlock(dev);
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//========================
// if(dlgPrint.DoModal()==IDO
// {
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames);
m_hDevMode = CopyHandle(dlgPrint.m_pd.h
m_hDevNames = CopyHandle(dlgPrint.m_pd.h
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC()
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr
dc.m_bPrinting=TRUE;
//------------------------
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0
//~~~~~~~~~~~~~~~~~~~~~~~~
OnBeginPrinting(&dc,&pInfo
//~~~~~~~~~~~~~~~~~~~~~~~~
//========================
for(UINT page=pInfo.GetMinPage();pa
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~
bPrintingOK=(dc.EndPage()>
}
//========================
//~~~~~~~~~~~~~~~~~~~~~~~~
OnEndPrinting(&dc,&pInfo);
//~~~~~~~~~~~~~~~~~~~~~~~~
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
dc.DeleteDC();
//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h
GlobalFree(dlgPrint.m_pd.h
}
//xxxxxxxxxxxxxxxxxxxxxxxx
}
//########################
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Is this okay????
protected:
virtual void DoDataExchange(CDataExchan
DECLARE_MESSAGE_MAP()
HANDLE m_hDevMode;
HANDLE m_hDevNames;
IMPLEMENT_DYNAMIC(CAuftrag
CAuftragsHistory_Liefersch
: CDialog(CAuftragsHistory_L
, m_strLieferscheinNr(_T("")
, m_piAdoRecordBinding(NULL)
, m_strConnection(_T(""))
, m_strCmdText(_T(""))
, mb_Kennzahl_first_show_up(
{
m_hDevMode=NULL;
m_hDevNames=NULL;}
void CAuftragsHistory_Liefersch
{
if (GetPrinterDevice(_T("\\\\
{
AfxGetApp()->SelectPrinter
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS
//------------------------
if(AfxGetApp()->GetPrinter
{
LPDEVMODE dev=dlgPrint.GetDevMode();
dev->dmOrientation=DMORIEN
dev->dmPaperSize=DMPAPER_A
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW
GlobalUnlock(dev);
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//========================
// if(dlgPrint.DoModal()==IDO
// {
m_hDevMode = CopyHandle(dlgPrint.m_pd.h
m_hDevNames = CopyHandle(dlgPrint.m_pd.h
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC()
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr
dc.m_bPrinting=TRUE;
//------------------------
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------
BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0
//~~~~~~~~~~~~~~~~~~~~~~~~
OnBeginPrinting(&dc,&pInfo
//~~~~~~~~~~~~~~~~~~~~~~~~
//========================
for(UINT page=pInfo.GetMinPage();pa
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~
OnPrint(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~
bPrintingOK=(dc.EndPage()>
}
//========================
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~
OnEndPrinting(&dc,&pInfo);
//~~~~~~~~~~~~~~~~~~~~~~~~
dc.DeleteDC();//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h
GlobalFree(dlgPrint.m_pd.h
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames); }
//xxxxxxxxxxxxxxxxxxxxxxxx
}
//########################
IMO that looks ok - does it still crash? If so, did you try to watch resources in TaskManage?
ASKER
IMO that looks ok - does it still crash? If so, did you try to watch resources in TaskManage?
I printed about 20 white pages with nothing on
so far no error....I will try many many more tomorrow...vielen Dank
Schönen Feierabend, Thomas
I printed about 20 white pages with nothing on
so far no error....I will try many many more tomorrow...vielen Dank
Schönen Feierabend, Thomas
ok, that's fine - let's hope :o)
i think we are back at the point where you would need to generally overwork the printing concept. your Drucken_weiss function doesn't fit to the mfc way of printing.
as told in a previous question mfc doesn't do the whole printing in one handler function what would freeze the screen while printing cause no more messages could be processed. instead you only give an impact for printing and the mfc framework would call your printing functions like OnPreparePrinting, OnBeginPrinting, OnPrint, OnEndPrinting. for example the framework would call the OnPrint for each page separatly what would give the program a chance to process other messages between the different calls such that the program keeps responsive.
the Drucken_weiss function calls the OnBeginPrinting and the OnPrint itself, what could lead to unexpected behavior and also could be responsible for the crash (though i can't spot the wrong statement which actually causes the problems).
some of your code is indeed strange because of the wrong architecture. for example the members m_hDevMode and m_hDevNames which your current code actually doesn't need. you need members if you have to save variables beyond on single call of a member function. that would be if mfc calls OnPreparePrinting (where you should instantiate the printer device) and then you would need that device in the other OnPrint... functions.
Or the calls of StartDoc and EndDoc. those were supposed to start and end the printing process controlled by the mfc framework. in your current code those calls only could make things worse cause they would start and end functionality that not really was required as you do control the printing yourself.
Did you try to debug your code as suggested? aside of the architecture thing i am still thinking that your code uses a wrong pointer somehow and debugging is the way to find those errors.
Sara
as told in a previous question mfc doesn't do the whole printing in one handler function what would freeze the screen while printing cause no more messages could be processed. instead you only give an impact for printing and the mfc framework would call your printing functions like OnPreparePrinting, OnBeginPrinting, OnPrint, OnEndPrinting. for example the framework would call the OnPrint for each page separatly what would give the program a chance to process other messages between the different calls such that the program keeps responsive.
the Drucken_weiss function calls the OnBeginPrinting and the OnPrint itself, what could lead to unexpected behavior and also could be responsible for the crash (though i can't spot the wrong statement which actually causes the problems).
some of your code is indeed strange because of the wrong architecture. for example the members m_hDevMode and m_hDevNames which your current code actually doesn't need. you need members if you have to save variables beyond on single call of a member function. that would be if mfc calls OnPreparePrinting (where you should instantiate the printer device) and then you would need that device in the other OnPrint... functions.
Or the calls of StartDoc and EndDoc. those were supposed to start and end the printing process controlled by the mfc framework. in your current code those calls only could make things worse cause they would start and end functionality that not really was required as you do control the printing yourself.
Did you try to debug your code as suggested? aside of the architecture thing i am still thinking that your code uses a wrong pointer somehow and debugging is the way to find those errors.
Sara
ASKER
that would be if mfc calls OnPreparePrinting (where you should instantiate the printer device) and then you would need that device in the other OnPrint... functions.
Or the calls of StartDoc and EndDoc. those were supposed to start and end the printing process controlled by the mfc framework. in your current code those calls only could make things worse cause they would start and end functionality that not really was required as you do control the printing yourself.
Sara...could you help with a code sample...how should I do this...sorry printing is not my thing...I am happy if it works.
i think we are back at the point where you would need to generally overwork the printing concept that would take to long for me and is to difficult....I am happy that I even can print...I hope you understand....I do this coding beside my normal work at our office...and sometimes it is very stressy.
Or the calls of StartDoc and EndDoc. those were supposed to start and end the printing process controlled by the mfc framework. in your current code those calls only could make things worse cause they would start and end functionality that not really was required as you do control the printing yourself.
Sara...could you help with a code sample...how should I do this...sorry printing is not my thing...I am happy if it works.
i think we are back at the point where you would need to generally overwork the printing concept that would take to long for me and is to difficult....I am happy that I even can print...I hope you understand....I do this coding beside my normal work at our office...and sometimes it is very stressy.
it is not so difficult. you normally would use a sample project from mfc samples and copy paste the functions. then replace the individual code as retrieving the data or print all three copies.
the main problem with your current code is that it calls framework functions whitout the right context. for example your overload of the OnPreparePrinting of mfc should call DoPreparePrinting and return . then the framework would call OnBeginPrinting.
if you want to go on with your current code i would rename all the printing functions such there is no mismatch. for example call the print function Print and not OnPrint. then drop all calls where you don't have own sourcecode, like the calls to StartDoc and EndDoc and probably the OnBeginPrinting. those function calls caan't help you with your current approach but only make things worse. forget all the member variables which only make sense if the printing was done with multiple calls from framework.
Sara
the main problem with your current code is that it calls framework functions whitout the right context. for example your overload of the OnPreparePrinting of mfc should call DoPreparePrinting and return . then the framework would call OnBeginPrinting.
if you want to go on with your current code i would rename all the printing functions such there is no mismatch. for example call the print function Print and not OnPrint. then drop all calls where you don't have own sourcecode, like the calls to StartDoc and EndDoc and probably the OnBeginPrinting. those function calls caan't help you with your current approach but only make things worse. forget all the member variables which only make sense if the printing was done with multiple calls from framework.
Sara
ASKER
Sara...something like this?
if you want to go on with your current code i would rename all the printing functions such there is no mismatch.for example call the print function Print and not OnPrint. then drop all calls where you don't have own sourcecode, like the calls to StartDoc and EndDoc and probably the OnBeginPrinting
void CAuftragsHistory_Liefersch ein_Dialog ::Drucken_ weiss(void )
{
if (GetPrinterDevice(_T("\\\\ DSERVER\\B rother HL-7050 series"), &m_hDevNames, &m_hDevMode)) //
{
AfxGetApp()->SelectPrinter (m_hDevNam es, m_hDevMode);
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS |PD_USEDEV MODECOPIES ANDCOLLATE , this);
//------------------------ --- Papier Auswahl DEVMODE -------------------------- --------
if(AfxGetApp()->GetPrinter DeviceDefa ults(&dlgP rint.m_pd) )
{
LPDEVMODE dev=dlgPrint.GetDevMode();
dev->dmOrientation=DMORIEN T_PORTRAIT ;
dev->dmPaperSize=DMPAPER_A 4;
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW IDTH|DM_OR IENTATION| DM_DEFAULT SOURCE;
GlobalUnlock(dev);
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------ ---------- ---------- ---------- ---------- ---------- -------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//======================== ========== ========== ========== ========== ========== ==
// if(dlgPrint.DoModal()==IDO K) //Ohne CPrintDialogBox
// {
m_hDevMode = CopyHandle(dlgPrint.m_pd.h DevMode); // Save new copies.
m_hDevNames = CopyHandle(dlgPrint.m_pd.h DevNames); // Save new copies.
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC() ;
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr interDC()) ;
dc.m_bPrinting=TRUE;
//------------------------ ---------- --
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------ ---------- -
without this //Rem BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0 ,0,dc.GetD eviceCaps( HORZRES), dc.GetDeviceCaps(VERTRES)) ;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
without this // Rem OnBeginPrinting(&dc,&pInfo ); // call prepare
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
//======================== ========== ========== ========== =====
for(UINT page=pInfo.GetMinPage();pa ge<=pInfo. GetMaxPage () &&bPrintingOK ; page++)
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
On_MY_Print(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
bPrintingOK=(dc.EndPage()> 0);
}
//======================== ========== ========== =
without this
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
On_MY_EndPrinting(&dc,&pIn fo); // call your clean up
//~~~~~~~~~~~~~~~~~~~~~~~~ ~
dc.DeleteDC();//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h DevMode);
GlobalFree(dlgPrint.m_pd.h DevNames);
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames); }
//xxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxxxxxxxx xxxx
}
if you want to go on with your current code i would rename all the printing functions such there is no mismatch.for example call the print function Print and not OnPrint. then drop all calls where you don't have own sourcecode, like the calls to StartDoc and EndDoc and probably the OnBeginPrinting
void CAuftragsHistory_Liefersch
{
if (GetPrinterDevice(_T("\\\\
{
AfxGetApp()->SelectPrinter
CPrintDialog dlgPrint(FALSE,PD_PAGENUMS
//------------------------
if(AfxGetApp()->GetPrinter
{
LPDEVMODE dev=dlgPrint.GetDevMode();
dev->dmOrientation=DMORIEN
dev->dmPaperSize=DMPAPER_A
dev->dmCopies=1;
dev->dmDefaultSource=0;
//Wichtig !!!dmFields setzen
dev->dmFields |=DM_PAPERLENGTH|DM_PAPERW
GlobalUnlock(dev);
}
dlgPrint.m_pd.Flags &= ~PD_RETURNDC; // Reset flag set by constructor.
//------------------------
// Force the CPrintDialog to use our device mode & name.
dlgPrint.m_pd.hDevMode = CopyHandle(m_hDevMode);
dlgPrint.m_pd.hDevNames = CopyHandle(m_hDevNames);
//========================
// if(dlgPrint.DoModal()==IDO
// {
m_hDevMode = CopyHandle(dlgPrint.m_pd.h
m_hDevNames = CopyHandle(dlgPrint.m_pd.h
CDC dc;
HDC hDCPrint = dlgPrint.CreatePrinterDC()
//------------------
dc.Attach(hDCPrint);
//------------------
//dc.Attach(dlgPrint.GetPr
dc.m_bPrinting=TRUE;
//------------------------
DOCINFO Print;
memset( &Print, 0, sizeof(DOCINFO) );
Print.cbSize = sizeof (DOCINFO);
Print.lpszDocName = "Drucken im Dialog";
Print.lpszOutput = (LPTSTR) NULL;
Print.lpszDatatype = (LPTSTR) NULL;
Print.fwType = 0;
//------------------------
without this //Rem BOOL bPrintingOK = dc.StartDoc(&Print);
CPrintInfo pInfo;
pInfo.m_rectDraw.SetRect(0
//~~~~~~~~~~~~~~~~~~~~~~~~
without this // Rem OnBeginPrinting(&dc,&pInfo
//~~~~~~~~~~~~~~~~~~~~~~~~
//========================
for(UINT page=pInfo.GetMinPage();pa
{
//begin a new page
dc.StartPage();
pInfo.m_nCurPage=page;
//~~~~~~~~~~~~~~~~~~~~~~~~
On_MY_Print(&dc,&pInfo); // call Print your Page
//~~~~~~~~~~~~~~~~~~~~~~~~
bPrintingOK=(dc.EndPage()>
}
//========================
without this
if(bPrintingOK)
{
dc.EndDoc();
}
else
{
dc.AbortDoc();
}
//~~~~~~~~~~~~~~~~~~~~~~~~
On_MY_EndPrinting(&dc,&pIn
//~~~~~~~~~~~~~~~~~~~~~~~~
dc.DeleteDC();//
// }// Ohne CPrintDialogBox
GlobalFree(dlgPrint.m_pd.h
GlobalFree(dlgPrint.m_pd.h
GlobalFree(m_hDevMode);
GlobalFree(m_hDevNames); }
//xxxxxxxxxxxxxxxxxxxxxxxx
}
i also would make the m_hDevMode and m_hDevNames local variables and pass them to On_My_Print as arguments. the code looks better though i would assume you still didn't get an output?
Sara
Sara
ASKER
Goodmorning Zoppo,
I did the test with the TaskManager
The only thing that is rising per one click print is the Handles (2 per click)
I started with
173 Handles<------------------ this will standy rise 2 per printing click....is this good or bad?
3 Threads
130 User Ob
61 Gdi Ob
Please let me know...untill now no crash
Thank you
Best regards,
Thomas
I did the test with the TaskManager
The only thing that is rising per one click print is the Handles (2 per click)
I started with
173 Handles<------------------
3 Threads
130 User Ob
61 Gdi Ob
Please let me know...untill now no crash
Thank you
Best regards,
Thomas
ASKER
....Sara....you still didn't get an output? yes... will not work
do you write any data in the On_My_Print to the dc (device context) of the printer?
note, the idea behind printing in mfc is to exchange screen dc with printer dc such that anything you see on screen in your view now is put to paper.
is that what you want or do you have a printer output that is different from the view contents?
Sara
note, the idea behind printing in mfc is to exchange screen dc with printer dc such that anything you see on screen in your view now is put to paper.
is that what you want or do you have a printer output that is different from the view contents?
Sara
ASKER
is that what you want or do you have a printer output that is different from the view contents?
I don´t understand your question.
I will later print a delivery paper "Lieferschein"....that is displayed on a Listenelement ....I will go through every row and print a delievery paper
What is about the HANDLES they are increasing 2 per click when I print...is this good or bad?
I don´t understand your question.
I will later print a delivery paper "Lieferschein"....that is displayed on a Listenelement ....I will go through every row and print a delievery paper
What is about the HANDLES they are increasing 2 per click when I print...is this good or bad?
handles are pointers to windows resources (where there are pretty much cause you need at least one handle for any windows object, such as windows, controls, bitmaps, files, fonts, ..., ).
as far as i know windows tries to create new handle numbers as long as possible before it reuses old freed handles. that way an invalid use of a freed handle can be detected rather than a wrong one be used.
so your observation seems ok for me.
Sara
as far as i know windows tries to create new handle numbers as long as possible before it reuses old freed handles. that way an invalid use of a freed handle can be detected rather than a wrong one be used.
so your observation seems ok for me.
Sara
ASKER
Thank you all for your great help...untill now I had no crash
I guess the the 'GlobalFree' calls to the end of the function to ensure they are cleaned up correctly. was the trick
Thank you very much.
Have a great weekend.
Best regards,
Thomas
I guess the the 'GlobalFree' calls to the end of the function to ensure they are cleaned up correctly. was the trick
Thank you very much.
Have a great weekend.
Best regards,
Thomas
Fine - I'm glad we could help.
Have a nice weekend too ...
Have a nice weekend too ...
you simply forgot to create the CFont instance - add the bold line from below:
void CAuftragsHistory_Liefersch
{
//Druckbereich in 0,1mm
pDC->SetMapMode(MM_LOMETRI
//------------------------
pInfo->SetMaxPage(1);
//------------------------
//--------------- Neue Schrift erstellen ------------------
if(m_fontUeberschrift==NUL
{
m_fontUeberschrift = new CFont;
m_fontUeberschrift->Create
0,
0,
0,
600,
0,
0,
0,
DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS,
CLIP_CHARACTER_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
"Arial");
}
//------------------------
}
Hope that helps,
ZOPPO