От: | RussianFellow | http://russianfellow.livejournal.com | |
Дата: | 11.04.22 07:28 | ||
Оценка: | -2 |
Debug Assertion Failed!
Program: C:\WINDOWS\SYSTEM32\mfc110ud.dll
File: f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\winutil.cpp
Line: 183
void TrackingDialog::OnBnClickedButton5()
// если была нажата кнопка "Печать"
{
int i, j, n, len, typeeph1, length, strcount, cyPage, cyChar, yPos, xlpPrinter, ylpPrinter, dim1;
long double val;
TEXTMETRIC txtm;
LOGFONT lf, lf2;
CFont myFont, myFont2;
FILE *f;
INT_PTR fdret;
char sfilename[MAX_PATH*4], sfilenamebrief[80], sresult[160], s1[40], s2[40], s3[40], s4[40], s5[40], s6[40], s7[40], sresinfo[320];
wchar_t *wides;
LPCTSTR pzText;
CString mystr;
TCHAR Bufefr[MAX_PATH*4];
strcpy(sfilename,"params.txt");
f = fopen(sfilename,"w+");
n = m_IDC_LIST1.GetItemCount();
if (n>0)
{
for (i=0; i<n; i++)
{
// запись строки в файл params.txt;
}
}
fclose(f);
Sleep(1000);
strcount = 0;
CPrintDialog cp(FALSE);
BOOL bRet = AfxGetApp->GetPrinterDeviceDefaults(&(cp.m_pd));
if (bRet)
{
DEVMODE FAR *pDevMode = (DEVMODE FAR*)::GlobalLock(cp.m_pd.hDevMode);
pDevMode->dmOrientation = DMORIENT_LANDSCAPE; // альбомная ориентация печати
::GlobalUnlock(cp.m_pd.hDevMode);
}
if (cp.DOModal()==IDOK)
{
CDC printDC;
printDC.Attach(cp.GetPrinterDC());
cyPage = printDC.GetDeviceCaps(VERTRES);
printDC.GetTextMetrics(&txtm);
cyChar = txtm.txHeigth + txtm.tmExternalLeading;
yPos = 200;
xlpPrinter = ::GetDeviceCaps(printDC,LOGPIXELSX);
ylpPrinter = ::GetDeviceCaps(printDC,LOGPIXELSY);
DOCINFO docinfo;
::ZeroMemory(&docinfo,sizeof(DOCINFO));
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = L"Simple";
docinfo.lpszOutput = NULL;
docindo.lpszDatatype = L"RAW";
docindo.fwType = 0;
dim1 = 44; // количество строк на одну страницу
CFont *savedFont;
savedFont = printDC.GetCurrentFont();
savedFont->GetLogFont(&lf);
savedFont->GetLogFont(&lf2);
wcscpy(lf.lfFaceName,L"Courier New");
lf.lfHeight = 15;
lf.lfWidth = 6;
lf.lfHeight = (int)(((long double)lf.lfHeight/72.0)*(long double)ylpPrinter);
lf.lfWidth = (int)(((long double)lf.lfWidth/72.0)*(long double)xlpPrinter);
myFont.CreateFontIndirect(&lf);
wcscpy(lf2.lfFaceName,L"Courier New");
lf2.lfHeight = 18;
lf2.lfWidth = 6;
lf2.lfHeight = (int)(((long double)lf2.lfHeight/72.0)*(long double)ylpPrinter);
lf2.lfWidth = (int)(((long double)lf2.lfWIdth/72.0)*(long double)xlpPrinter);
myFont2.CreateFontIndirect(&lf2);
printDC.SelectFont(&myFont);
if (printDC.StartDoc(&docinfo)>0)
{
if (printDC.StartPage()>0)
{
f = fopen("params.txt","rt");
while (!feof(f));
{
fgets(s,256,f);
len = strlen(s);
length = MultiByteToWideChar(1251,0,s,-1,0,0);
wides = new wchar_t[length];
MultiByteToWideChar(1251,0,s,-1,wides,length);
printDC.TextOut(320,yPos,wides,len);
yPos += cyChar;
strcount++;
delete[] wides;
if ((strcount % dim1)==0)
{
printDC.EndPage();
yPos = 200;
printDC.StartPAge();
}
}
fclose(f);
printDC.EndPage();
}
printDC.EndDoc();
}
printDC.SelectObject(savedFont);
printdDC.Detach();
}
}