troubleshooting Question

Need some help with CFont*

Avatar of Thomas Stockbruegger
Thomas StockbrueggerFlag for Germany asked on
Programming Languages-OtherVisual C++.NET
19 Comments1 Solution707 ViewsLast Modified:
Hello,
I need some help with my printing program.
In my h.file I have 7 pointer for my fonts
CFont* m_fontUeberschrift1;
CFont* m_fontUeberschrift2;
CFont* m_fontUeberschrift3;
CFont* m_fontUeberschrift4;
CFont* m_fontUeberschrift5;
CFont* m_fontUeberschrift6;
CFont* m_fontUeberschrift7;


When I declare a new pointer  (No.8) like
CFont* m_fontUeberschrift8; my program will crash. Please look at my stack.

With only 7 pointers everything runs fine. With the 8 pointers my program crash when I start.










here I create the fonts for my printing
void CAuftragsHistory_Lieferschein_Dialog::On_MY_BeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
      //Druckbereich in 0,1mm
      pDC->SetMapMode(MM_LOMETRIC);
    //--------------------------------------
      
    pInfo->SetMaxPage(1);
    //--------------------------------------
 
      //--------------- Neue Schrift erstellen ------------------
              m_fontUeberschrift1 = new CFont;
     m_fontUeberschrift1->CreateFont(-75,
                                         0,
                                       0,
                                         0,
                                         700,
                                         0,
                                            0,
                                         0,
                                         DEFAULT_CHARSET,
                                         OUT_CHARACTER_PRECIS,
                                         CLIP_CHARACTER_PRECIS,
                                         DEFAULT_QUALITY,
                                         DEFAULT_PITCH|FF_DONTCARE,
                                         "Arial");
    //----------------------------------------------------------
.
.
.
.

---------------------------------------------------------------------------------------------------------



here I print and use the different fonts
void CAuftragsHistory_Lieferschein_Dialog::On_MY_Print(CDC* pDC, CPrintInfo* pInfo)
{


      //Druckbereich in 0,1mm
      pDC->SetMapMode(MM_LOMETRIC);
    //--------------------------------------
      pInfo->SetMaxPage(1);
   //--------------------------------------

 

      CFont* pOldFont = pDC->SelectObject(m_fontUeberschrift1);
      //--------------------- Briefkopf -------------------------------
       pDC->TextOut(155,-180,"WILHELM STOCKBRÜGGER OHG");
.
.
.
.



---------------------------------------------------------------------------------------------------------



here I delete the fonts
void CAuftragsHistory_Lieferschein_Dialog::On_MY_EndPrinting(CDC* pDC, CPrintInfo* pInfo)
{
      delete m_fontUeberschrift1;
       m_fontUeberschrift=NULL;

      delete m_fontUeberschrift2;
       m_fontUeberschrift1=NULL;
.
.
.
.

---------------------------------------------------------------------------------------------------------










When I create the new font here it works fine.

      void CAuftragsHistory_Lieferschein_Dialog::On_MY_Print(CDC* pDC, CPrintInfo* pInfo)
{


      //Druckbereich in 0,1mm
      pDC->SetMapMode(MM_LOMETRIC);
    //--------------------------------------
      pInfo->SetMaxPage(1);
   //--------------------------------------

 

      CFont* pOldFont = pDC->SelectObject(m_fontUeberschrift1);
      //--------------------- Briefkopf -------------------------------
       pDC->TextOut(155,-180,"WILHELM STOCKBRÜGGER OHG");
      
     pDC->SelectObject(m_fontUeberschrift1);
     pDC->TextOut(500,-265,"Stahl - Service - Center");


       CString strSchriftart2="Microsoft Sans Serif";
     
       CFont *fontPtr = new CFont();
       fontPtr->CreateFont(
       40,
        0,
        0,
        0,
       FW_NORMAL,
        0,
        0,
        0,
       DEFAULT_CHARSET,
       OUT_CHARACTER_PRECIS,
       CLIP_CHARACTER_PRECIS,
       DEFAULT_QUALITY,
       DEFAULT_PITCH|FF_DONTCARE,
       strSchriftart2);

 pDC->SelectObject(fontPtr);
 pDC->TextOut(1470,-570,"E-mail: my email");
 fontPtr->DeleteObject();
.
.
.
.
.
 

Can I use only a few pointer....like here 7. Or is there any other reason that my program will crash.
Please let me know.
500 points.
Best regards,
Thomas


1.BMP
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 19 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros