Solved

CFontDialog::GetCurentFont()  fails

Posted on 1997-06-07
2
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
MarkusLoibl earned 70 total points
ID: 1302001
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
ID: 1302002
excellent response time!

Thank you
Wolfgang
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

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