Solved

CFontDialog::GetCurentFont()  fails

Posted on 1997-06-07
2
306 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 35
deburging in oracle form 12 99
maven archtype selection in eclipse 1 57
Message not shown 5 50
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

777 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