Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:58:22+00:00 2026-06-17T15:58:22+00:00

Doing HFONT childfont = SendMessage (childwin, WM_GETFONT, NULL, NULL); results in the error invalid

  • 0

Doing HFONT childfont = SendMessage (childwin, WM_GETFONT, NULL, NULL); results in the error “invalid conversion from ‘LRESULT’ to ‘HFONT__*'” when MSDN states that the return type is HFONT. What is the proper return type for this function? Should I just use LRESULT or is there something special I have to do because my program will come back and bite me later if I don’t do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:58:23+00:00Added an answer on June 17, 2026 at 3:58 pm

    SendMessage is a Swiss army knife: it does a lot of different things, all of which return various types of values. Since C does not support overloaded return values (remember that the Win32 API is a C API), it has to return a generic LRESULT type.

    So, you need to cast the result to the actual type. The documentation states that it this message returns an HFONT, so you must cast the result to an HFONT:

    HFONT childFont = (HFONT)SendMessage(childWin, WM_GETFONT, ...);
    

    Alternatively, you can use the macro GetWindowFont() defined in the header file <WindowsX.h>, which includes a lot of utility macros:

    // From WindowsX.h.  SNDMSG is a macro which expands to either SendMessage or
    // AfxSendMessage.
    #define GetWindowFont(hwnd) FORWARD_WM_GETFONT((hwnd), SNDMSG)
    #define FORWARD_WM_GETFONT(hwnd, fn) \
        (HFONT)(UINT_PTR)(fn)((hwnd), WM_GETFONT, 0L, 0L)
    
    // Example usage:
    HFONT childFont = GetWindowFont(childWin);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing gql.query and not getting any results when I KNOW from looking at the
Doing a simple db.Dictionary(select Id, Name from \Product\); results in an exception column id
Doing the getting started of Sinatra. I get this error: ./sinatra.rb:5: undefined method `get'
Doing a mysqli query and COUNTing the results, is there a preferred comparison operator
Doing a search using django-sphinx gives me results._sphinx that says there were 68 results,
Doing the following on XP and Windows 7 yields different results in a .NET4
Doing a simple query I'm finding two very different results, and I'm not sure
Doing a recent build, I ran Django's syncdb, and I'm getting the error: Traceback
Doing so select name from sqlite_master where type='table' but I need to display all
Doing a project where I am retrieving the text from an edittext control in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.