CListrl怎么改变字体?清赐教.
还有CListrl怎么改变行高啊?CListrl怎么使其可以选中整行啊(不用LVS_EX_FULLROWSELECT我用VC5,里面没有这个)?

解决方案 »

  1.   

    http://www.csdn.net/Dev/Visual%20C++/source%20code/Advanced_UI/gfxlist.shtml.htm
      

  2.   

    [email protected] 
    Thanks!
      

  3.   

    可以调用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 ) 
     
    … 

      

  4.   


    CWnd *stat;
    HFONT currentfont;
    LOGFONT logfont;
    logfont.lfHeight =24;
                logfont.lfWidth  =0;
    logfont.lfEscapement=0;
    logfont.lfOrientation =0;
                logfont.lfWeight=FW_HEAVY;                 // nWeight
                logfont.lfItalic = FALSE;                     // bItalic
                logfont.lfUnderline = FALSE;                     // bUnderline
                logfont.lfStrikeOut =0;                     // cStrikeOut
                logfont.lfCharSet = ANSI_CHARSET;              // nCharSet
     logfont.lfOutPrecision= OUT_DEFAULT_PRECIS;        // nOutPrecision
                logfont.lfClipPrecision= CLIP_DEFAULT_PRECIS;       // nClipPrecision
                logfont.lfQuality=DEFAULT_QUALITY;           // nQuality
                logfont.lfPitchAndFamily=DEFAULT_PITCH | FF_SWISS;  // nPitchAndFamily
                            
    currentfont = CreateFontIndirect(&logfont);
    stat=GetDlgItem(IDC_LIST1);
    ::SendMessage(stat->m_hWnd,WM_SETFONT,(WPARAM)currentfont,MAKELPARAM(true,0));
    我试了一下,可以改变字体大小等!
      

  5.   

    CListCtrl整行选择:
    加在窗口初始化的代码中就行了!(void)m_ListView.SetExtendedStyle(LVS_EX_FULLROWSELECT);m_ListView为控件的变量!!
      

  6.   

    可以用GetFont()获得当前的系统字体的LOGFONT,进行修改如:
    CListrl list;
    ...........
    LOGFONT lf;
    CFont* pFont;
    CFont NewFont;pFont = list.GetFont();
    pFont->GetLogFont(&lf);
    lf.lfItalic = "Courier New";
    lf.lfWeight = 16;
    lf.lfHeight = 20;
    ......
    NewFont.CreateFontIndirect(&lf);list.SetFont(&NewFont);
    或者
    list.GetDC()->SelectObject(&NewFont);
      

  7.   

    Change CListCtrl rows height
    http://www.codeproject.com/listctrl/changerowheight.asp