Set the font for text
-
I am trying to set the font for radio button using below code in my project but font does not set. Font and color does not set for text on radio button. I have a dialog base application (MFC), at dialog there are some radio buttons In dialog class, Oninitdialog() i use CFont* pFont = GetDlgItem( IDC_RADIO1 )->GetFont(); LOGFONT LogFont = { 0 }; pFont->GetLogFont( &LogFont ); LogFont.lfItalic = TRUE; LogFont.lfWidth = 9; LogFont.lfHeight = 12; LogFont.lfWeight = FW_BOLD; memcpy(LogFont.lfFaceName,"Verdana",7); m_StaticFont.CreateFontIndirect( &LogFont ); GetDlgItem( IDC_RADIO1 )->SetFont( &m_StaticFont ); in header file CFont m_StaticFont; To set the color for text on radio button, i use OnCtlColor (WM_CTLCOLOR) HBRUSH CtestxmlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { /// if(pWnd->GetDlgCtrlID() == IDC_RADIO1) pDC->SetTextColor(RGB(255,0,0)); //// } But when i use above code in a test program it works. Please suggest what's wrong. I have debug my project and found OnCtlColor calls and it set the text color also. Please help.
-
I am trying to set the font for radio button using below code in my project but font does not set. Font and color does not set for text on radio button. I have a dialog base application (MFC), at dialog there are some radio buttons In dialog class, Oninitdialog() i use CFont* pFont = GetDlgItem( IDC_RADIO1 )->GetFont(); LOGFONT LogFont = { 0 }; pFont->GetLogFont( &LogFont ); LogFont.lfItalic = TRUE; LogFont.lfWidth = 9; LogFont.lfHeight = 12; LogFont.lfWeight = FW_BOLD; memcpy(LogFont.lfFaceName,"Verdana",7); m_StaticFont.CreateFontIndirect( &LogFont ); GetDlgItem( IDC_RADIO1 )->SetFont( &m_StaticFont ); in header file CFont m_StaticFont; To set the color for text on radio button, i use OnCtlColor (WM_CTLCOLOR) HBRUSH CtestxmlDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { /// if(pWnd->GetDlgCtrlID() == IDC_RADIO1) pDC->SetTextColor(RGB(255,0,0)); //// } But when i use above code in a test program it works. Please suggest what's wrong. I have debug my project and found OnCtlColor calls and it set the text color also. Please help.
How is this test program different from the dialog based program that you mentioned first?
«_Superman_» _I love work. It gives me something to do between weekends.
-
How is this test program different from the dialog based program that you mentioned first?
«_Superman_» _I love work. It gives me something to do between weekends.
-
Both are dialog based applications. Test program contains only one radio button. In main program there are lot of controls and work against them
As you can see yourself, the code works. So that means what you've done is correct. That must mean, there is something else going wrong in the first program. Maybe a wrong ID has been used. You could debug the code to get the answer.
«_Superman_» _I love work. It gives me something to do between weekends.
-
As you can see yourself, the code works. So that means what you've done is correct. That must mean, there is something else going wrong in the first program. Maybe a wrong ID has been used. You could debug the code to get the answer.
«_Superman_» _I love work. It gives me something to do between weekends.
The font is set but text color is not set in first program. This is the problem with radio buttons. If i add a new radio button then also text color is not set. But for static control the text color is set. It means something needs to be supported for radio button
-
As you can see yourself, the code works. So that means what you've done is correct. That must mean, there is something else going wrong in the first program. Maybe a wrong ID has been used. You could debug the code to get the answer.
«_Superman_» _I love work. It gives me something to do between weekends.
I found the reason why.I am using XP theme. Below url also says that http://www.go4expert.com/forums/showthread.php?t=16457&page=2 If i remove xp theme then color is set for radio text. Is there any solution for that problem.It's require for me to use XP theme. XP theme
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
processorArchitecture="x86"
version="5.1.0.0"
type="win32"
name="appname.exe"/>
<description>appname</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="x86"/>
</dependentAssembly>
</dependency>
</assembly>