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
Solved

CFontDialog::GetCurentFont()  fails

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 99
Expand macro to ask for filename column 8 37
Tab names are off by one 5 54
has22 challenge 11 104
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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