鹿我所录的博客

记录我在学习C#中的点点滴滴,记录下以备后来人借鉴。

 

MFC CEdit改变字体大小的方法

方法很多,这里讲解两种比较简单的方法,也是从google上搜索来的。

方法一:

CWnd*   pEdit;   
  pEdit   =   GetDlgItem(IDC_EDIT_ONE);   
  ASSERT(pEdit   !=   NULL);   
    
  HFONT   hFont   =   (HFONT)::GetStockObject(SYSTEM_FIXED_FONT);   
  CFont*   pFont   =   CFont::FromHandle(hFont);   
  pEdit->SetFont(pFont);  

 

方法二:

 CFont * f; 
 f = new CFont; 
 f->CreateFont(22, // 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_EDIT_RECEIVE)->SetFont(f);      //IDC_EDIT_RECEIVE是Edit框标号

 

posted on 2016-03-27 00:20  鹿我所录  阅读(2651)  评论(0编辑  收藏  举报

导航