CPrintDialog :: OnInitDialog is not called every time

I am using MyPrintDialog advanced CPrintDialog. Problem in: The OnInitDialog () method of MyPrintDialog is not called the first time the application tries to open the Print dialog box.

I am trying to set the printer name in the Print dialog from the OnInitDialog () method. The printer name is entered by the user in the application that I want to use for printing. A.

My OnInitDialog () Method

CComboBox *wndCmbBox = (CComboBox *)GetDlgItem( IDC_PER_USER ); /*IDC_PER_USER which is ID of Prin Dialog combo */ if( wndCmbBox != NULL ) { wndCmbBox->SelectString( -1, PrinterName ); } 

Or their any way to set a custom choice. Printer name in the Print dialog box.?

Explain, please.

Edit

Yes, byInInit () I mean OnInitDialog()

I am using VS 2012 with Win7 32 bit. I ran into this problem only with the first call to DoModel() . The following sequential methods DoModel() calls OnInitDialog() . I am debugging a problem and found something

 INT_PTR CALLBACK AfxDlgProc(HWND hWnd, UINT message, WPARAM, LPARAM) { if (message == WM_INITDIALOG) { // special case for WM_INITDIALOG CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd)); if (pDlg != NULL) return pDlg->OnInitDialog(); else return 1; } return 0; } 

The above function is dlgcore.cpp. When the problem reproduces, I noticed that DYNAMIC_DOWNCAST returns NULL .

Note that I configured CPrintDialog and added one checkbox to it. I doubt this creates a problem.

+4
source share
1 answer

If you wanted to say OnInitDialog() instead of OnInit() , then it is possible that your problem is explained in this MSKB article , although it seems to have been fixed after VC6 SP1.

0
source

All Articles