+ Reply to Thread
Results 1 to 3 of 3

Thread: Change font of a control in dialog box.

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    43

    Change font of a control in dialog box.

    How can I change the font of specific control of CDialog class.

    Is there any way to do this?

    Please help.

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    37
    You can use following code snippet:

    Code:
    class CMyDialog: public CDialog
    {
    private:
            CFont m_objFont ;
            void ChangeFont(UINT nDialogITem) ;
    } ;
    
    void CMyDialog::ChangeFont(UINT nDialogITem)
    {
    	GetDlgItem(nDialogITem)->SetFont(&m_objFont) ;         // without a member variable associated
    }
    
    BOOL CMyDialog::OnInitDialog()
    {
    	CDialog::OnInitDialog();
            m_objFont.CreatePointFont(100, _T("Arial"));
    	ChangeFont(IDC_BUTTON1) ;
    }
    Thanks.

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    43
    Really, it worked for me.

    Nice job.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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