忘了说明,listctrl是在report格式下的,顺便问一下如何改变没行的高度

解决方案 »

  1.   

    Step 1: WM_SETFONT :
    :
    //}}AFX_MSG
    afx_msg LRESULT OnSetFont(WPARAM wParam, LPARAM);
    afx_msg void MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct );
    DECLARE_MESSAGE_MAP()
    //////////////////////////////////////////////////////////////////////
    // In the cpp file
    BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrl)
    //{{AFX_MSG_MAP(CMyListCtrl)
    :
    :
    //}}AFX_MSG_MAP
    ON_MESSAGE(WM_SETFONT, OnSetFont)
    ON_WM_MEASUREITEM_REFLECT( )
    END_MESSAGE_MAP()
    LRESULT CMyListCtrl::OnSetFont(WPARAM wParam, LPARAM)
    {
    LRESULT res =  Default(); CRect rc;
    GetWindowRect( &rc ); WINDOWPOS wp;
    wp.hwnd = m_hWnd;
    wp.cx = rc.Width();
    wp.cy = rc.Height();
    wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
    SendMessage( WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp ); return res;
    }Step 2: WM_MEASUREITEMvoid CMyListCtrl::MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct )
    {
    LOGFONT lf;
    GetFont()->GetLogFont( &lf ); if( lf.lfHeight < 0 )
    lpMeasureItemStruct->itemHeight = -lf.lfHeight; 
    else
    lpMeasureItemStruct->itemHeight = lf.lfHeight; 
    }