1. mfc 如何改变对话框字体大小
你上面的方法都是设置整个对话框的字体的,你要输出的是在静态文本控件还是在编辑文本控件上?
比如说你对该控件关联了控制变量 m_editor
可使用该变量设置字体 m_editor.SetFont(); 这样设置就会有效了。
2. MFC对话框编程里怎样设对话框里的文字的字体和大小?
右键单击对话框选择“属性”,在“general”中选择“font”
3. MFC中怎么修改对话框标题字体大小(属性里修改除外)?
1 VC的对话框字体设置对所有控件都有效,你不能单独地改变某个静态文本的字体。对于你的问题,需要首先用CreateFont来建立一个字体对象,然后调用控件的SetFont,就可以了。 例子: 1、改静态文体的ID,如:IDC_STATIC1 2、添加一个Edit控件,建立一个关联的控件m_editControl。 3、在OnInitDialog中添加如下代码: CFont * f; f = new CFont; f->CreateFont(16, // nHeight 0, // nWidth 0, // nEscapement 0, // nOrientation FW_BOLD, // nWeight TRUE, // bItalic FALSE, // bUnderline 0, // cStrikeOut ANSI_CHARSET, // nCharSet OUT_DEFAULT_PRECIS, // nOutPrecision CLIP_DEFAULT_PRECIS, // nClipPrecision DEFAULT_QUALITY, // nQuality DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily _T("Arial")); // lpszFac GetDlgItem(IDC_STATIC1)->SetFont(f); 需要注意的是,这里我们使用的是CFont指针,而不是普通的CFont局部变量, 在非MFC程序,首先用CreateFont来建立一个字体句柄,然后再用SendMessage发给控件WM_SETFONT消息,将建立的字体句柄赋值过去,就可以了。实例下载:http://www.china-askpro.com/download/CtrlFont.zip 2 但是整个对话框或窗口的字体的大小,使用对话框或窗口的SetFont()函数却没有任何的作用.可以在初始化时遍历每个控件分别设置来处理,但这里说另一种使用回调函数的简单方法: :调用系统的API:::EnumChildWindows(). ,传入回调函数和重新定义的字体.(第一个参数不用管啊,本来就有啊)) 1)在文档视图结构中CMainFrame::OnCreate().中调用::EnumChildWindows(). 实现所有窗口和子窗口字体改变 2) 在对话框的OnInitDialog(). 中调用::EnumChildWindows(). 改变对话窗上的所有控件.回调函数如下:// lParam is a pointer to CFont objectBOOL __stdcall SetChildFont(HWND hwnd, LPARAM lparam){ CFont *pFont = (CFont*)lparam; CWnd *pWnd = CWnd::FromHandle(hwnd); pWnd->SetFont(pFont); return TRUE;} 使用1:BOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here ::EnumChildWindows(m_hWnd, ::SetChildFont, (LPARAM)g_Font.GetFont()); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE}使用2:int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct){ if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); ::EnumChildWindows(m_hWnd, ::SetChildFont, (LPARAM)g_Font.GetFont()); return 0;}
4. mfc建立的对话框中各控件的字体大小怎么设置?
在资源视图中选定对话框,按下回车,在弹出的属性对话框中设置字体,为宋体,9号。
5. VC++6.0中对话框中字体大小如何改变
1、可以通过手动设置,右键对话框,选择属性,如下图:
然后点击字体可以进行设置。
2、可以通过添加代码进行改变,示例代码如下:
BOOL __stdcall SetChildFont(HWND hwnd, LPARAM lparam){ CFont *pFont = (CFont*)lparam; CWnd *pWnd = CWnd::FromHandle(hwnd); pWnd->SetFont(pFont); return TRUE;}
BOOL CXXXDlg::OnInitDialog() { CDialog::OnInitDialog(); CFont * f; f = new CFont; const LOGFONT* pFont = new LOGFONT(logFont); f->CreateFontIndirectW(pFont); // TODO: Add extra initialization here ::EnumChildWindows(m_hWnd, ::SetChildFont, (LPARAM)f); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE}
6. 如何改变MFC中对话框控件中某个文字的字体
换HTML对话框、找个别人写好的可改颜色的控件或是自己写一个。
7. MFC对话框编程里怎样设对话框里的文字的字体和大小?
右键单击对话框选择“属性”,在“general”中选择“font”
8. 我想给MFC生成的对话框修改字体,字大小也要改下,怎么修改?
第一种方法:
1.在头文件.h定义一CFont m_fFont;
2.添加WM_CREATE事件,在OnCreate函数里写上
LOGFONT lf;
CFont *pFont = GetFont();
pFong->GetLogFont(&lf);
lf.lfHeigt控制字体高度
lf.lfFaceName控制字体类型,利用LOGFONT这个结构里设置字体
m_fFont.CreateFontIndirect(&lf);
3.在OnInitDialog函数里
SetFont(&m_fFont);
第二种方法:
在对话框属性修改字体