My problem is when I call pDC->StartDoc( &stDocInfo ), I get the error "The
parameter is incorrect." This happens for both printing and previewing
printing.
Following the only examples I could find, I created a new DOCINFO structure and
set everything to NULL except for stDocInfo.lpszDocName which I set to a
character string.
I traced through the code and found that CDC::StartDoc() is expecting a long
pointer to a character string and not a DOCINFO pointer, as the documentation
led me to believe. I changed my call to pDC->StartDoc( "Name" ) but I still
got the parameter error. I traced as far as I could into the program execution
but could get only as far as a call to ::StartDoc(m_hDC, lpDocInfo) in
Afxwin1.inl. I could not trace into this. I ran it again and checked to make
sure m_hDC was not NULL and it was not. I watched the lpDocInfo parameter
passed to this function get created in CDC::StartDoc(), so it should be valid
also.
I am using Visual C++ 5 with Service Pack 3 loaded.
I am going crazy.
You need to set cbSize to sizeof( DOCINFO ).
>I traced through the code and found that CDC::StartDoc() is expecting a long
>pointer to a character string and not a DOCINFO pointer, as the documentation
>led me to believe.
No, CDC::StartDoc is defined as:
int StartDoc( LPDOCINFO lpDocInfo );
>I traced as far as I could into the program execution
>but could get only as far as a call to ::StartDoc(m_hDC, lpDocInfo) in
>Afxwin1.inl. I could not trace into this.
::StartDoc is the Win32 API, you don't have source for this, so it
wouldn't make much sense to debug it.
Dave
----
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.
Sorry, I forgot to say I set that one, too:
DOCINFO stDocInfo;
memset( &stDocInfo, 0, sizeof( stDocInfo ) );
stDocInfo.cbSize = sizeof( stDocInfo );
stDocInfo.lpszDocName = "Document Name";
>>I traced through the code and found that CDC::StartDoc() is expecting a long
>>pointer to a character string and not a DOCINFO pointer, as the
>documentation
>>led me to believe.
>
>No, CDC::StartDoc is defined as:
>
>int StartDoc( LPDOCINFO lpDocInfo );
I know. However, I (just) found that CDC::StartDoc is overloaded to accept
either a pointer to a DOCINFO structure or a string. When given a pointer to a
string it creates a DOCINFO structure and fills it exactly as I have above and
calls the Win32 API function. It does not seem to matter which I call, I get
the "incorrect parameter" message.
>>I traced as far as I could into the program execution
>>but could get only as far as a call to ::StartDoc(m_hDC, lpDocInfo) in
>>Afxwin1.inl. I could not trace into this.
>
> ::StartDoc is the Win32 API, you don't have source for this, so it
>wouldn't make much sense to debug it.
Thanks for your response, but unfortunately I'm still at square one here.
In that case, the only other "parameter" is your device context. How
do you get that set-up?
The device context is coming from MFC/Visual C++. I'm using the one passed to
the "OnPrint" function parameters: CDC *pDC, CPrintInfo *pInfo (I'm naming
these from memory--I'm on vacation and my Visual C++ stuff is all at work) that
are supplied by Class Wizard. Shouldn't that be the correct device context?
I guess it should be, but as there's obviously something wrong, and
it's not a particularly involved API, the problem's not far away!
Merry Christmas
Dave
----
Address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow up email copies.
http://www.bj.co.uk