Click here to Skip to main content
15,907,687 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralInitialize MFC-ODBC app from query Pin
Robert Bushlow4-Apr-01 4:49
Robert Bushlow4-Apr-01 4:49 
GeneralCCheckBox buttons Pin
Roger4-Apr-01 4:27
Roger4-Apr-01 4:27 
GeneralRemove Read Only flag ? (no MFC ) Pin
Christian Graus4-Apr-01 1:57
protectorChristian Graus4-Apr-01 1:57 
GeneralRe: Remove Read Only flag ? (no MFC ) Pin
4-Apr-01 3:37
suss4-Apr-01 3:37 
Questionhow to construct a OLE DB framework in regular DLL? Pin
3-Apr-01 22:21
suss3-Apr-01 22:21 
QuestionCustom Appwizard to create no MFC? Pin
3-Apr-01 20:18
suss3-Apr-01 20:18 
AnswerRe: Custom Appwizard to create no MFC? Pin
Michael Dunn3-Apr-01 22:04
sitebuilderMichael Dunn3-Apr-01 22:04 
General? Strange print behaviour Pin
Richard Ellis3-Apr-01 19:07
Richard Ellis3-Apr-01 19:07 
Firstly thanks to all who maintain and contribute to this site. I have learnt a lot from your efforts, so thanks again.

Now to my problem. I have an application that is required to print some reports. I have done this by deriving a view from CView and using the MFC framework to do the printing for me. I have overwritten OnPreparePrinting, OnPrepareDC, OnBeginPrinting etc. Now everything has been working fine for quite a while now. Yesterday I came to do some minor modifications to the format of the report. I recompiled my application in debug and stepped into my code. I got an assertion failure in ...\mfc\src\viewprnt.cpp. It occurs in the function DoPreparePrinting(). pInfo has been created using default values etc - I don't try and do anything with it.

I won't copy all the code for the function in here but basically it is an if..else statement. My code executes the else statement and I have marked the bit that fails.

else
{
// otherwise, bring up the print dialog and allow user to change things
// preset From-To range same as Min-Max range
pInfo->m_pPD->m_pd.nFromPage = (WORD)pInfo->GetMinPage();
pInfo->m_pPD->m_pd.nToPage = (WORD)pInfo->GetMaxPage();

if (pApp->DoPrintDialog(pInfo->m_pPD) != IDOK)
return FALSE; // do not print
}

ASSERT(pInfo->m_pPD != NULL);
***** ASSERT(pInfo->m_pPD->m_pd.hDC != NULL); **** This fails
if (pInfo->m_pPD->m_pd.hDC == NULL)
return FALSE;

Now the things that bother me are that it worked in the past but not now. I have not changed the code that produces the report - only a small cosmetic change the the layout of the report. And further if I execute the program rather than step into it it works!

I have done my best to wade through the documentation hand have searched the MSDN site and read the references I could find. I have stepped through this repeatedly and am most puzzled. From looking at the code in CView I can see that pInfo->m_pPD->m_pd.hDC seems to be created when CreatePrinterDC is called. However as I step through that statement is never called - it is in branches of code that my application doesn't execute. I don't really want to change what the user sees because I do want them to be able to change the default printer used. I have tried cutting and pasting CView's DoPreparePrinting function and inserting a CreatePrinterDC call but all this leads to is a crash when CView later on calls GetPortName because the pointer returned by ::GlobalLock(hDevnames) is NULL.

If anyone has any ideas as to what might have happened or to where I might look next for an answer then I would be most grateful.

Thankyou in anticipation and sorry for the length of this post.
QuestionHow to block win98 explorer.exe when win98 startup ? Pin
Hong Bob3-Apr-01 18:31
Hong Bob3-Apr-01 18:31 
QuestionHow to block win98 explorer.exe when win98 startup ? Pin
Hong Bob3-Apr-01 18:31
Hong Bob3-Apr-01 18:31 
QuestionHow Save a CListCtrl Pin
BLaZe3-Apr-01 17:40
BLaZe3-Apr-01 17:40 
AnswerRe: How Save a CListCtrl Pin
Robert Bushlow4-Apr-01 12:48
Robert Bushlow4-Apr-01 12:48 
GeneralRe: How Save a CListCtrl Pin
BLaZe8-Apr-01 18:15
BLaZe8-Apr-01 18:15 
Generaldeveloping a ms-paint like application Pin
mayank3-Apr-01 17:16
mayank3-Apr-01 17:16 
GeneralRe: developing a ms-paint like application Pin
Christian Graus3-Apr-01 18:12
protectorChristian Graus3-Apr-01 18:12 
GeneralCString::ReleaseBuffer() Pin
3-Apr-01 16:52
suss3-Apr-01 16:52 
GeneralRe: CString::ReleaseBuffer() Pin
Michael Dunn3-Apr-01 18:39
sitebuilderMichael Dunn3-Apr-01 18:39 
GeneralRe: CString::ReleaseBuffer() Pin
Kannan Kalyanaraman3-Apr-01 20:44
Kannan Kalyanaraman3-Apr-01 20:44 
GeneralDEBUG vs. RELEASE Pin
Manfred Ramosch3-Apr-01 14:21
Manfred Ramosch3-Apr-01 14:21 
GeneralRe: DEBUG vs. RELEASE Pin
Christian Graus3-Apr-01 15:06
protectorChristian Graus3-Apr-01 15:06 
GeneralRe: DEBUG vs. RELEASE - closer description... Pin
Manfred Ramosch3-Apr-01 19:33
Manfred Ramosch3-Apr-01 19:33 
GeneralCan anyone believe this...??? Pin
Manfred Ramosch4-Apr-01 5:24
Manfred Ramosch4-Apr-01 5:24 
GeneralRe: Can anyone believe this...??? Pin
Chris Losinger5-Apr-01 8:59
professionalChris Losinger5-Apr-01 8:59 
QuestionAre there performance issues(resource or otherwise) in using CStatic controls to display bitmaps? Pin
eric kaminski3-Apr-01 8:13
eric kaminski3-Apr-01 8:13 
GeneralUsing the system image list with CImageList Pin
3-Apr-01 8:09
suss3-Apr-01 8:09 

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.