void CYycqView::OnMenuFont()
{
// TODO: Add your command handler code here
LPLOGFONT m_lf;
CFontDialog Fontdlg(NULL,CF_EFFECTS|CF_SCREENFONTS,NULL,NULL);
CFont *m_pFont=new CFont;
if(IDOK==Fontdlg.DoModal())
{
m_lf=Fontdlg.m_cf.lpLogFont;
CFont *m_pFont=new CFont;
m_pFont->CreateFontIndirect(m_lf);
GetRichEditCtrl().SetFont(m_pFont,TRUE);
}
}
调用字体对话框后发现字体颜色不变,该怎么解决?另外设置三个按钮分别代表粗体、斜体和下划线。同样的代码,斜体和下划线都很正常,粗体没反应;但要是调用字体对话框后,再设置粗体,就完全正常了。这该怎么解决?
void CYycqView::OnInitialUpdate()
{
CRichEditView::OnInitialUpdate();
// Set the printing margins (720 twips = 1/2 inch).
SetMargins(CRect(720, 720, 720, 720));
tag2=tag3=0;
tag1=1;
}void CYycqView::OnMenuBold()
{
// TODO: Add your command handler code here
CHARFORMAT cf1;
GetRichEditCtrl().GetSelectionCharFormat(cf1);
if(tag1==0)
{
cf1.dwEffects|=CFM_BOLD;
tag1=1;
}
else
{
cf1.dwEffects&=0xfffffffe;
tag1=0;
}
GetRichEditCtrl().SetSelectionCharFormat(cf1);
}void CYycqView::OnMenuIntatic()
{
// TODO: Add your command handler code here;
CHARFORMAT cf1;
GetRichEditCtrl().GetSelectionCharFormat(cf1);
if(tag2==0)
{
cf1.dwEffects|=CFM_ITALIC;
tag2=1;
}
else
{
cf1.dwEffects&=0xfffffffd;
tag2=0;
}
GetRichEditCtrl().SetSelectionCharFormat(cf1);
}void CYycqView::OnMenuUnderline()
{
// TODO: Add your command handler code here
CHARFORMAT cf1;
GetRichEditCtrl().GetSelectionCharFormat(cf1);
if(tag3==0)
{
cf1.dwEffects|=CFM_UNDERLINE;
tag3=1;
}
else
{
cf1.dwEffects&=0xfffffffb;
tag3=0;
}
GetRichEditCtrl().SetSelectionCharFormat(cf1);
}
{
// TODO: Add your command handler code here
LPLOGFONT m_lf;
CFontDialog Fontdlg(NULL,CF_EFFECTS|CF_SCREENFONTS,NULL,NULL);
CFont *m_pFont=new CFont;
if(IDOK==Fontdlg.DoModal())
{
m_lf=Fontdlg.m_cf.lpLogFont;
CFont *m_pFont=new CFont;
m_pFont->CreateFontIndirect(m_lf);
GetRichEditCtrl().SetFont(m_pFont,TRUE);
}
}
调用字体对话框后发现字体颜色不变,该怎么解决?另外设置三个按钮分别代表粗体、斜体和下划线。同样的代码,斜体和下划线都很正常,粗体没反应;但要是调用字体对话框后,再设置粗体,就完全正常了。这该怎么解决?
void CYycqView::OnInitialUpdate()
{
CRichEditView::OnInitialUpdate();
// Set the printing margins (720 twips = 1/2 inch).
SetMargins(CRect(720, 720, 720, 720));
tag2=tag3=0;
tag1=1;
}void CYycqView::OnMenuBold()
{
// TODO: Add your command handler code here
CHARFORMAT cf1;
GetRichEditCtrl().GetSelectionCharFormat(cf1);
if(tag1==0)
{
cf1.dwEffects|=CFM_BOLD;
tag1=1;
}
else
{
cf1.dwEffects&=0xfffffffe;
tag1=0;
}
GetRichEditCtrl().SetSelectionCharFormat(cf1);
}void CYycqView::OnMenuIntatic()
{
// TODO: Add your command handler code here;
CHARFORMAT cf1;
GetRichEditCtrl().GetSelectionCharFormat(cf1);
if(tag2==0)
{
cf1.dwEffects|=CFM_ITALIC;
tag2=1;
}
else
{
cf1.dwEffects&=0xfffffffd;
tag2=0;
}
GetRichEditCtrl().SetSelectionCharFormat(cf1);
}void CYycqView::OnMenuUnderline()
{
// TODO: Add your command handler code here
CHARFORMAT cf1;
GetRichEditCtrl().GetSelectionCharFormat(cf1);
if(tag3==0)
{
cf1.dwEffects|=CFM_UNDERLINE;
tag3=1;
}
else
{
cf1.dwEffects&=0xfffffffb;
tag3=0;
}
GetRichEditCtrl().SetSelectionCharFormat(cf1);
}
解决方案 »
- FindwindowEx的问题
- 98下的DOS系统与另一台机子(xin98)串口通讯的问题
- 求《Windows程序调试》电子版,有的朋友给共享一下:)
- 我想用MFC做个俄罗斯方块,大家给个思路
- 求助,非常简单,但我就是不会!再现等待!
- 便宜拿分
- 怎么没有菜单?
- When maxmize a dialog, It corvered the taskbar and fulled the screen, How to make it displying as a normal dialog
- 用visual studio2008做MFC的时候一个小问题
- 如何使自己的程序随某个特定的程序启动而启动?
- 在dialogbar里面放cedit,显示不出来??
- 大家聊(2)
-----------------------------------------------
应该是你定义的CFont *m_pFont=new CFont;对象的生命期不够,函数返回的时候就结束了。你把它定义为一个类的成员变量。