Changing the font in a Combo Box?
-
Hi All, just a quick one - How can I change the font type and size that is used to display text in a combo box? At the moment my MDI App has one located in the MainFrame toolbar, but because the Arial font looks so pants its made my app look as though its been designed for Windows 3.x. Please help make my app look better, Cheers Guys, Alan.:-D "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
-
Hi All, just a quick one - How can I change the font type and size that is used to display text in a combo box? At the moment my MDI App has one located in the MainFrame toolbar, but because the Arial font looks so pants its made my app look as though its been designed for Windows 3.x. Please help make my app look better, Cheers Guys, Alan.:-D "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
Just as with any other window:
void CWnd::SetFont( CFont* pFont, BOOL bRedraw = TRUE );
I vote pro drink :beer: -
Just as with any other window:
void CWnd::SetFont( CFont* pFont, BOOL bRedraw = TRUE );
I vote pro drink :beer:Thanks for the response, however, I have inevitably reached a problem and my efforts have gone to no avail, please help. This is the code that has resulted from my patheticness in an attempt to get it going :
int CMainFrame::OnCreate(etc..)
//Toolbar definition.
stdFont.CreateFont(25,12,10,10,FW_THIN,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_OUTLINE_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,0,"Times New Roman");
SetFont(&stdFont, TRUE);//ComboBox setup and displaying code.
Can you see where I`m going wrong with this? I`ve tried different values for the third and forth arguments, but the combo box still uses the same crappy font to display the strings!!! Also I have checked the return value of the CreateFont function and its 1, so it must be doing something? Any advice on my failings would be hugely welcomed. Thanks again, Alan.:confused: "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
-
Thanks for the response, however, I have inevitably reached a problem and my efforts have gone to no avail, please help. This is the code that has resulted from my patheticness in an attempt to get it going :
int CMainFrame::OnCreate(etc..)
//Toolbar definition.
stdFont.CreateFont(25,12,10,10,FW_THIN,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_OUTLINE_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,0,"Times New Roman");
SetFont(&stdFont, TRUE);//ComboBox setup and displaying code.
Can you see where I`m going wrong with this? I`ve tried different values for the third and forth arguments, but the combo box still uses the same crappy font to display the strings!!! Also I have checked the return value of the CreateFont function and its 1, so it must be doing something? Any advice on my failings would be hugely welcomed. Thanks again, Alan.:confused: "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
Is stdFont defined locally to the OnCreate function, or is a member variable? If it's defined locally, then when OnCreate finishes, the CFont object is destroyed, so you end up with the crappy default font. I don't know if this is the problem, but I know I've done this a lot of times! ------------------------ Derek Waters derek@lj-oz.com
-
Is stdFont defined locally to the OnCreate function, or is a member variable? If it's defined locally, then when OnCreate finishes, the CFont object is destroyed, so you end up with the crappy default font. I don't know if this is the problem, but I know I've done this a lot of times! ------------------------ Derek Waters derek@lj-oz.com
I found the answer, at last. I had been changing the MainFrame's standard font, and it was not being reflected in the combo box. As soon as I changed my code to m_ctlCombo.SetFont(&stdFont, TRUE), it worked! amazing! Many thanks to those of you who offered their advice on this, I very much appreciate it. Cheers, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
-
I found the answer, at last. I had been changing the MainFrame's standard font, and it was not being reflected in the combo box. As soon as I changed my code to m_ctlCombo.SetFont(&stdFont, TRUE), it worked! amazing! Many thanks to those of you who offered their advice on this, I very much appreciate it. Cheers, Alan. "When I left you I was but the learner, now I am the Master" - Darth Vader:mad:
Here's some code for changing the font in a combobox... LOGFONT lf = { 0 }; (void)lstrcpy( lf.lfFaceName, _T("MS Sans Serif") ); lf.lfHeight = -MulDiv( 10, GetDeviceCaps( GetDC()->m_hDC, LOGPIXELSY ), 72 ); VERIFY( m_font.CreateFontIndirect( &lf ) ); m_ctlCombo.SetFont( &m_font ); Best regards, Mark www.mjsoft.co.uk