CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    23

    changing default font

    How to change the font of a control?eg., button control.thanks


  2. #2
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: changing default font

    You will need to create a CFont object in the class dealing with the control, i.e. if the control is on a Dialog box, embed the CFont in the CDialog derived class. Create the font in your class constructor. In the OnInitDialog() function, use the SetFont function for your control either as :

    GetDlgItem(IDC_CONTROL)->SetFont(&font) ;

    or

    m_control_name.SetFont(&font) ;

    Don't forget to destroy the CFont object in your destructor. You have to do the destruction after the controls you selected the font into have been destroyed.


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

  3. #3
    Join Date
    May 1999
    Posts
    23

    Re: changing default font

    how to create a CFont object with predefined windows fonts?


  4. #4
    Join Date
    May 1999
    Location
    West Sussex, England
    Posts
    1,939

    Re: changing default font

    The only way I know of doing this is to use the GetFont() function on an existing window and then apply that to your control. Of course you will have to get the font form a window you know has the font you want to use.

    HTH


    Roger Allen
    Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
    Please remember to rate useful answers. It lets us know when a question has been answered.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured