|
-
May 25th, 1999, 04:58 AM
#1
How to keep last printer used and provide it to print dialog box ?
In my application, I need to memorize the last printer used to print a document. I have done that :
BOOL MyViewWithPrint::OnPreparePrinting( CPrintInfo *pInfo )
{
char szDriver[ 100 + 1 ];
char szDevice[ 100 + 1 ];
char szOutput[ 100 + 1 ];
GetApp()->GetPrivateProfileString( "Setup", "Driver", "", szDriver, 100 );
GetApp()->GetPrivateProfileString( "Setup", "Device", "", szDevice, 100 );
GetApp()->GetPrivateProfileString( "Setup", "Output", "", szOutput, 100 );
if ( szDriver[ 0 ] != '\0' && szDevice[ 0 ] != '\0' && szOutput[ 0 ] != '\0' )
pInfo->m_pPD->m_pd.hDC = ::CreateDC( szDriver, szDevice, szOutput, NULL );
bool res = DoPreparePrinting(pInfo);
if ( pInfo->m_pPD )
{
CString szDriver = pInfo->m_pPD->GetDriverName();
CString szDevice = pInfo->m_pPD->GetDeviceName();
CString szOutput = pInfo->m_pPD->GetPortName();
LPTSTR p = szDriver.GetBuffer( 100 );
GetApp()->WritePrivateProfileString( "Setup", "Driver", p );
szDriver.ReleaseBuffer();
p = szDevice.GetBuffer( 100 );
GetApp()->WritePrivateProfileString( "Setup", "Device", p );
szDevice.ReleaseBuffer();
p = szOutput.GetBuffer( 100 );
GetApp()->WritePrivateProfileString( "Setup", "Output", p );
szOutput.ReleaseBuffer();
}
return res;
}
The problem is that when I close my application and then I launch it again and when I want to print, the print dialog box doesn't care about my device (created with ::CreateDC) ! It always uses the default printer. How can I say it to use the printer I have memorized ?
Thanks in advance and sorry for my english.
Stéphane.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|