Solved

CFontDialog::GetCurentFont()  fails

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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

615 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