标  题: 如何改变控件的字体                               
发信人: Pacific (无情~~~Nolove), 信区: VisualC
发信站: BBS 水木清华站 (Fri Oct 16 17:13:21 1998)


    由于控件是也是窗口,用户可以调用CWnd: : SetFont指定新字体。该函数用          
一个Cfont指针,要保证在控件撤消之前不能撤消字体对象。下例将下压按钮的字          
体改为8点Arial字体:                                                             
//Declare font object in class declaration (.H file ).                           
private :                                                                        
    Cfont m_font ;                                                               
// Set font in class implementation (.Cpp file ). Note m_wndButton is a          
//member variable added by ClassWizard.DDX routines hook the member              
//variable to a dialog button contrlo.                                           
BOOL CSampleDialog : : OnInitDialog ( )                                          
{                                                                                
                                                                                 
    …                                                                           
                                                                                 
    //Create an 8-point Arial font                                               
    m_font . CreateFont  (MulDiv (8 , -pDC—> GetDeviceCaps  (LOGPIXELSY) ,      
72).                                                                             
       0 , 0 , 0 , FW_NORMAL , 0 , 0, 0, ANSI_CHARSER, OUT_STROKE_PRECIS ,       
                                                                                 
       CLIP_STROKE _PRECIS , DRAFT _QUALITY                                      
       VARIABLE_PITCH |FF_SWISS, _T ("Arial") );                                
                                                                                 
    //Set font for push button .                                                 
    m_wndButton . SetFont (&m _font );                                           
                                                                                 
    …                                                                           
}                                                                                
                                                                                 

--
        老鸟有交待,中鸟要等待,菜鸟要忍耐。
        老鸟级功夫:吹牛、聊天、玩MUD 、发呆。
        中鸟级功夫:睡觉、灌水、玩游戏、NT&VC。
        菜鸟级功夫:学习、泡妞、玩篮球、And so on

        My E-Mail: Nolove@263.net

--
☆ 来源:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: yazhou.bbs@bbs.net.t]
※ 修改:.fzx 于 Aug  9 16:51:06 修改本文.[FROM: heart.hit.edu.cn]
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.272毫秒