Solved

CFontDialog::GetCurentFont()  fails

Posted on 1997-06-07
2
300 Views
Last Modified: 2013-11-20
Hello,

I am invoking a create font dialog and after the user presses O.K.
I try to read out the selected font:

CFontDialog fontDialog;
int         result;
LOGFONT     fontInfo;

result = fontDialog.DoModal ()

if (result == IDOK)
{
   fontDialog.GetCurrentFont (&fontInfo);
}


The call to GetCurrentFont however results in a failed assertion
ASSERT(m_hWnd != NULL).

According to the documentation this function is intended to be called
after the user has pressed o.k. and the dialog is destroyed. So I cannot
understand the assertion.

Can you explain me whether this is right or wrong?

Bye
Wolfgang


0
Comment
Question by:wth
2 Comments
 
LVL 1

Accepted Solution

by:
MarkusLoibl earned 70 total points
Comment Utility
Well, I use VC++ 5.0 and have tried your code. I didn't resolve any problems.
I stepped into the MFC-code and found, that it doesn't matter, if hWnd is NULL:
void CFontDialog::GetCurrentFont(LPLOGFONT lplf)
{
      ASSERT(lplf != NULL);

      if (m_hWnd != NULL)
            SendMessage(WM_CHOOSEFONT_GETLOGFONT, 0, (DWORD)(LPVOID)lplf);
      else
            *lplf = m_lf;
}

But under VC++1.52 I had the problems you describe.
But you can just use the "new"-code form VC++ 5.0:
      CFontDialog            fontDialog;
      int                        result;
      LOGFONT                  *pFontInfo;

      result = fontDialog.DoModal ();

      if (result == IDOK)
      {
            pFontInfo = &(fontDialog.m_lf);
      }


0
 

Author Comment

by:wth
Comment Utility
excellent response time!

Thank you
Wolfgang
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now