From: Dan Bloomquist on

Hi,

I've started using the Ex version of the print dialog. All has been fine
until I've pressed the 'Apply' button. The only thing showing on the
call stack I can see is:

if (bCallDefault)
lResult = CallWindowProc(oldWndProc, hWnd, nMsg, wParam, lParam);

in:
_AfxActivationWndProc(..)

with oldWndProc == NULL.

And the error is:
Invalid Address specified to RtlReAllocateHeap( 00150000, 00757250 )
Unhandled exception at 0x7c901230 in ars.exe: User breakpoint.

So, I figured I wanted notification of 'Apply' and copied the
CPrintDialogEx stuff to my own files and renamed it. It compiles but
won't link.

temp_test.obj : error LNK2001: unresolved external symbol "class
CThreadLocal<class _AFX_THREAD_STATE> _afxThreadState"
(?_afxThreadState@@3V?$CThreadLocal(a)V_AFX_THREAD_STATE@@@@A)

I haven't got a clue were to find _afxThreadState.

Thanks, Dan.

From: Dan Bloomquist on


Dan Bloomquist wrote:

>
> Hi,
>
> I've started using the Ex version of the print dialog. All has been fine
> until I've pressed the 'Apply' button...

> And the error is:...

Ok, my bad. I found the error was also showing up on 'Print', so I knew
it was something I did elsewhere. I was setting the printer, as:

dlg.m_pdex.hDevMode= GetDevMode( );
dlg.m_pdex.hDevNames= GetDevNames( );

Where these return the Apps, m_hDevMode and m_hDevNames. This, just like
CWinApp::DoPrintDialog does for CPrintDialog. But for some reason it
breaks CPrintDialogEx. I'm not sure why. Picky about hDevNames?

Best, Dan.

From: Dan Bloomquist on


Dan Bloomquist wrote:

> So, I figured I wanted notification of 'Apply' and copied the
> CPrintDialogEx stuff to my own files and renamed it. It compiles but
> won't link.
>
> temp_test.obj : error LNK2001: unresolved external symbol "class
> CThreadLocal<class _AFX_THREAD_STATE> _afxThreadState"
> (?_afxThreadState@@3V?$CThreadLocal(a)V_AFX_THREAD_STATE@@@@A)
>
> I haven't got a clue were to find _afxThreadState.


So, I thought I would add here, so I would not need to
AFX_MODULE_THREAD_STATE* (get). The only thing I had to guard out was:

if( message != WM_CTLCOLORDLG
&& message != WM_CTLCOLORSTATIC
&& message != WM_CTLCOLOREDIT )
hRet= OnWndMsg(message, wParam, lParam, plResult) ? S_OK : S_FALSE;

and CMyPrintDialogEx works fine, (if scary). But I still have not worked
out the proper passing of devnames and/or devmode. So many other things
to do! :)

Best, Dan.

From: Dan Bloomquist on


For the life of me, I can't set the printer in CPrintDialogEx. I have:

if( !GetPrinterDevice( "microsoft office document image writer",
&dlg.m_pdex.hDevMode, &dlg.m_pdex.hDevNames ) )
ASSERT( false );

And even if it has no effect, (It does for CPrintDialog ):

HGLOBAL hDevMode = NULL;
HGLOBAL hDevNames = NULL;
if (GetPrinterDevice(_T("microsoft office document image writer"),
&hDevNames, &hDevMode))
AfxGetApp()->SelectPrinter(hDevNames, hDevMode);

from:
http://support.microsoft.com/kb/166129

The computer default printer is selected when the dialog comes up.
GetPrinterDevice returns good info, I can 'Apply' and 'Print' with it
now. Has anyone successfully set the printer for CPrintDialogEx?

Thanks, Dan.