How set font style for button in MFC ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: How set font style for button in MFC ?

  1. #1
    Join Date
    Feb 2013
    Posts
    14

    How set font style for button in MFC ?

    I want to set font size and font color for button in MFC. But MFC differrent from win32. It have no font style in property. please help me , How set font color and font size for button in MFC ?

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,927

    Re: How set font style for button in MFC ?

    Quote Originally Posted by mmc01 View Post
    I want to set font size and font color for button in MFC. But MFC differrent from win32. It have no font style in property.
    From this anybody could conclude that win32 does have ones, right? This is new to me, as VS uses the same resource editor for C++ projects, including MFC and Win32. You might be talking about WinForms, but this is absolutely different story.

    please help me , How set font color and font size for button in MFC ?
    You can change font family, size and weight quite easily by creating new font and setting it explicitly to the button. However, text color is changeable for owner-draw buttons only, but this button style makes you be responsible for drawing entire button face, borders, etc.
    Best regards,
    Igor

  3. #3
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: How set font style for button in MFC ?

    Explicitly define the Font style :

    Code:
    CFont SFont;
    
    SFont.CreateFont(15,7,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,0,0,0,0,"Times New Roman");
    
    ButtonContolName.SetFont(&SFont);
    Finally delete the CFont.

    Refer the below link also :

    Change color and font-color of a MFC-Button

    Color Button
    Regards,

    SaraswathiSrinath

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,288

    Re: How set font style for button in MFC ?

    Quote Originally Posted by saraswathisrinath View Post
    Explicitly define the Font style :

    Code:
    CFont SFont;
    SFont.CreateFont(15,7,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,0,0,0,0,"Times New Roman");
    ButtonContolName.SetFont(&SFont);
    Finally delete the CFont.
    You do NOT need to explicitely delete a CFont object (more correct - underlying font handle). It will be deleted in CFont destructor
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2011
    Location
    India
    Posts
    147

    Re: How set font style for button in MFC ?

    Thank you Mr. Victor, Still now I used the below code in the next line SetFont() method.
    SFont.DeleteObject();
    Regards,

    SaraswathiSrinath

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center