Font text on command button
-
MFC, STUDIO 2008, MDI CButton m_button1; CString font(L"Courier New"); m_button1.SetFont(font,20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' m_button1.SetFont(L"Courier New",20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' 2. // How do to set BOLD FONT on button? m_button1.SetFont(L"Courier New",20,600); // error C2660: 'CWnd::SetFont' : function does not take 3 arguments Add #include "afxctl.h" class CFontHolder; // add into header file my class where is command button that I want write caption.
-
MFC, STUDIO 2008, MDI CButton m_button1; CString font(L"Courier New"); m_button1.SetFont(font,20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' m_button1.SetFont(L"Courier New",20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' 2. // How do to set BOLD FONT on button? m_button1.SetFont(L"Courier New",20,600); // error C2660: 'CWnd::SetFont' : function does not take 3 arguments Add #include "afxctl.h" class CFontHolder; // add into header file my class where is command button that I want write caption.
Have you looked at the documentation at all? Stupid question really, 'cause you obviously haven't. Does help, though. Anyway - that has the definition for
CWnd::SetFont
, which is this:void SetFont(
CFont* pFont,
BOOL bRedraw = TRUE
);No strings mentioned there? So, to change the font, you need to create a
CFont
. To do that, add aCFont
data member to the class this code is in (the view?). Initialise the font withCFont::CreateFont
and callm_button1.SetFont
passing the address of theCFont
data member.Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
MFC, STUDIO 2008, MDI CButton m_button1; CString font(L"Courier New"); m_button1.SetFont(font,20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' m_button1.SetFont(L"Courier New",20); // error C2664: 'CWnd::SetFont' : cannot convert parameter 1 from 'const wchar_t [12]' to 'CFont *' 2. // How do to set BOLD FONT on button? m_button1.SetFont(L"Courier New",20,600); // error C2660: 'CWnd::SetFont' : function does not take 3 arguments Add #include "afxctl.h" class CFontHolder; // add into header file my class where is command button that I want write caption.
First of all you can see parameters of functions on your code you need to make this font(Courier New) for it you can use of CreateFont/CFont class and then you can use of it of the SetFont much as you are new to VC++ you can read error message(Can not convert to CFont*) so you can think its parameter is CFont not CString.
Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )