We have this application that prints fine under Windows NT 4.0 and 3.51.
However when it is run under Windows 95 it always uses the default fonts
and no matter how you change the parameters in the CreatePointFont
function it still grabs the wrong font so we believe there is a problem in this
particular CreateDC. We are using an HP4SI the drivers are installed, the
system is configured correctly to use this printer. I have included a code
fragment to see if anyone out here has any ideas.
PRINTDLG printDlg;
CWinApp *theApp = AfxGetApp();
if (!theApp->GetPrinterDeviceDefaults(&printDlg))
{
SetCursor(LoadCursor(NULL, IDC_ARROW));
AfxMessageBox("No default printer set up or a printer error detected.");
return FALSE;
}
DEVNAMES FAR *pDevNames = (DEVNAMES FAR *)::GlobalLock(printDlg.hDevNames);
DEVMODE devMode;
memcpy(&devMode, (DEVMODE FAR *)::GlobalLock(printDlg.hDevMode), sizeof(DEVMODE));
CString strDriver((LPCSTR)pDevNames + pDevNames->wDriverOffset);
CString strDevice((LPCSTR)pDevNames + pDevNames->wDeviceOffset);
CString strOutput((LPCSTR)pDevNames + pDevNames->wOutputOffset);
::GlobalUnlock(printDlg.hDevNames);
::GlobalUnlock(printDlg.hDevMode);
CDC *m_pDC = new CDC;
//This is used in windows NT and works fine this does not work in windows 95
if (!m_pDC->CreateDC(strDriver, strDevice, strOutput, &devMode))
{
AfxMessageBox("Unable to create Device driver for printer.");
delete m_pDC;
return FALSE;
}
CFont DiffFont;
DiffFont.CreatePointFont(ReportFileHolder.GetReportFontPoint() * 10, ReportFileHolder.GetReportFontName(), m_pDC);
CFont *oldFont = (CFont*)m_pDC->SelectObject(DiffFont);
//This is what I next attempted to use to create the DC for windows 95 still did not work
if (!m_pDC->CreateDC(/*strDriver*/ NULL, strDevice, /*strOutput*/ NULL, &devMode))
{
AfxMessageBox("Unable to create Device driver for printer.");
delete m_pDC;
return FALSE;
}
The person that wrote this code is no longer here so I have been tasked with
thanks,
Chris Norris