How to change the font of a button's caption in MFC
-
Hi! Could anyone help me change the font of a button's caption/text in MFC? The button is created with the modal frame style. The problem is that when I try to modify the caption's font, the application crashes. The code which creates the button is:
m_wndButton.CreateEx( WS_EX_DLGMODALFRAME, _T( "Button" ), _T( "Test button" ), WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, CRect( 100, 100, 190, 140 ), &m_wndView, 1, NULL );
m_wndButton is the CButton object I'm trying to modify. Can anybody give me a hint? Thanks in advance! -
Hi! Could anyone help me change the font of a button's caption/text in MFC? The button is created with the modal frame style. The problem is that when I try to modify the caption's font, the application crashes. The code which creates the button is:
m_wndButton.CreateEx( WS_EX_DLGMODALFRAME, _T( "Button" ), _T( "Test button" ), WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, CRect( 100, 100, 190, 140 ), &m_wndView, 1, NULL );
m_wndButton is the CButton object I'm trying to modify. Can anybody give me a hint? Thanks in advance!Do you really need to create the button dynamically?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
-
Do you really need to create the button dynamically?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
The application I am developing is Single Document (SDI). I do not have a dialog which can be modified at design time. The only dialog of this kind is the AboutBox. The button which I am trying to modify is contained on the main frame. It's on the child view exactly. I have no other choice (in my opinion), than to dynamically create the button.
-
Hi! Could anyone help me change the font of a button's caption/text in MFC? The button is created with the modal frame style. The problem is that when I try to modify the caption's font, the application crashes. The code which creates the button is:
m_wndButton.CreateEx( WS_EX_DLGMODALFRAME, _T( "Button" ), _T( "Test button" ), WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, CRect( 100, 100, 190, 140 ), &m_wndView, 1, NULL );
m_wndButton is the CButton object I'm trying to modify. Can anybody give me a hint? Thanks in advance! -
m_wndButton.SetFont( &m_buttonFont);
where m_buttonFont is a CFont object declared in the View object and intialized to whatever font you desire or whatever.led mike
Thanks a lot!!! It finally works! The only thing that was wrong was the declaration of the CFont object: instead of declaring it in the CMainFrame class, it was declared in the same method the button was created in.
-
Hi! Could anyone help me change the font of a button's caption/text in MFC? The button is created with the modal frame style. The problem is that when I try to modify the caption's font, the application crashes. The code which creates the button is:
m_wndButton.CreateEx( WS_EX_DLGMODALFRAME, _T( "Button" ), _T( "Test button" ), WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON, CRect( 100, 100, 190, 140 ), &m_wndView, 1, NULL );
m_wndButton is the CButton object I'm trying to modify. Can anybody give me a hint? Thanks in advance!Whats error?
_**
**_
WhiteSky