TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: Neil Heller
from: Darin McBride
date: 2003-03-29 17:18:26
subject: Printer stuff

Hello Neil!

Replying to a message of Neil Heller to All:

 NH> I needed a print dialog box in an application I was writing.  The 
 NH> documentation said:

 NH> "After calling DoModal(), GetDefaults() or GetPrinterDC() a printer DC 
 NH> will be returned in m_pd.hDC.  This DC must be freed by the caller of 
 NH> CPrintDialog."

 NH> Given the following code:

 NH>    pprtdlg = new CPrintDialog(false);


 NH>    if (pprtdlg->DoModal() == IDOK)
 NH>       pcdc->Attach(pprtdlg->GetPrinterDC());

 NH>    delete(pprtdlg->m_pd.hDC); <-------- offending line
 NH>    delete pprtdlg;

 NH> Does anyone have an idea of why the offending line causes a GPF?

It may not have been allocated with new, but with malloc.  When the docs
say "must be freed", they may have meant "free()'d".

Darin
C_PLUSPLUS moderator
dmcbride{at}tower.to.org

---
* Origin: Tanktalus' Tower BBS (1:250/102)
SEEN-BY: 633/267 270
@PATH: 250/102 99 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.