Click here to Skip to main content
15,906,626 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Saving printer options Pin
crowbarcberg6-May-05 2:44
crowbarcberg6-May-05 2:44 
GeneralRe: Saving printer options Pin
PJ Arends6-May-05 5:47
professionalPJ Arends6-May-05 5:47 
GeneralRe: Saving printer options Pin
PJ Arends6-May-05 6:45
professionalPJ Arends6-May-05 6:45 
GeneralRe: Saving printer options Pin
crowbarcberg6-May-05 9:14
crowbarcberg6-May-05 9:14 
GeneralRe: Saving printer options Pin
PJ Arends6-May-05 10:59
professionalPJ Arends6-May-05 10:59 
GeneralRe: Saving printer options Pin
crowbarcberg6-May-05 11:15
crowbarcberg6-May-05 11:15 
GeneralRe: Saving printer options Pin
PJ Arends6-May-05 13:46
professionalPJ Arends6-May-05 13:46 
GeneralRe: Saving printer options Pin
crowbarcberg6-May-05 15:31
crowbarcberg6-May-05 15:31 
Actually the problem was reading in the strings with the GetProfileString() call I had:
theApp.GetProfileString("CheckPrinter", "DeviceName", csDeviceName);
which should have been:
csDeviceName=theApp.GetProfileString("CheckPrinter", "DeviceName", "");
so that was an easy fix.

Now the function is working fine, except when the program is closed. After I reopen the program I get an unhandled exception in COMDLG32.DLL (0xC0000005) Access Violation after the dlg.DoModal() call. When debugging the exception comes after executing: m_pd.hwndOwner = PreModal();. Here is the code from the MFC file DLGPRNT.CPP:
<br />
int CPrintDialog::DoModal()<br />
{<br />
	ASSERT_VALID(this);<br />
	ASSERT(m_pd.Flags & PD_ENABLEPRINTHOOK);<br />
	ASSERT(m_pd.Flags & PD_ENABLESETUPHOOK);<br />
	ASSERT(m_pd.lpfnPrintHook != NULL); // can still be a user hook<br />
	ASSERT(m_pd.lpfnSetupHook != NULL); // can still be a user hook<br />
<br />
	m_pd.hwndOwner = PreModal();<br />
	int nResult = ::PrintDlg(&m_pd);<br />
	PostModal();<br />
	return nResult ? nResult : IDCANCEL;<br />
}


I did check the dmDriverExtra member and it was saved correctly.
I also tried using the SelectPrinter function by just replacing:
dlg.m_pd.hDevMode = hDEVMODE;<br />
dlg.m_pd.hDevNames = hDEVNAMES;

with:
theApp.SelectPrinter(hDEVNAMES, hDEVMODE, FALSE);
while it didn't throw an error, it didn't populate the CPrintDialog with the correct printer/values. This application has a MDI, and what I am doing is an attempt to setup a different printer for checks, cash receipts, and reports with out user interaction (once they have been setup of course).
Thanks again,
Chad
GeneralRe: Saving printer options Pin
crowbarcberg13-May-05 6:22
crowbarcberg13-May-05 6:22 
GeneralRe: Saving printer options Pin
crowbarcberg13-May-05 6:30
crowbarcberg13-May-05 6:30 
GeneralRe: Saving printer options Pin
PJ Arends13-May-05 9:11
professionalPJ Arends13-May-05 9:11 
GeneralVS 6.0 - service pack info Pin
john john mackey5-May-05 10:23
john john mackey5-May-05 10:23 
GeneralRe: VS 6.0 - service pack info Pin
Kevin McFarlane5-May-05 10:30
Kevin McFarlane5-May-05 10:30 
GeneralRe: VS 6.0 - service pack info Pin
Anonymous5-May-05 10:43
Anonymous5-May-05 10:43 
GeneralRe: VS 6.0 - service pack info Pin
Kevin McFarlane5-May-05 12:05
Kevin McFarlane5-May-05 12:05 
GeneralRe: VS 6.0 - service pack info Pin
David Crow6-May-05 4:25
David Crow6-May-05 4:25 
GeneralSound Led Pin
RickyC5-May-05 9:26
RickyC5-May-05 9:26 
GeneralRe: Sound Led Pin
Ravi Bhavnani5-May-05 10:07
professionalRavi Bhavnani5-May-05 10:07 
GeneralRe: Sound Led Pin
RickyC5-May-05 10:09
RickyC5-May-05 10:09 
QuestionHow to change the different view in the CSplitterWnd Pin
wwwht5-May-05 9:03
wwwht5-May-05 9:03 
AnswerRe: How to change the different view in the CSplitterWnd Pin
David Crow5-May-05 9:40
David Crow5-May-05 9:40 
GeneralUsing WinPCap Pin
sarmed5-May-05 8:04
sarmed5-May-05 8:04 
GeneralRe: Using WinPCap Pin
CodeBeetle26-May-05 6:50
CodeBeetle26-May-05 6:50 
Questiondo u know the differences between command.com and cmd.exe? Pin
includeh105-May-05 7:57
includeh105-May-05 7:57 
AnswerRe: do u know the differences between command.com and cmd.exe? Pin
David Crow5-May-05 8:06
David Crow5-May-05 8:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.