外国网友评论中国菜:CListCtrl CHeadeCtrl height
来源:百度文库 编辑:偶看新闻 时间:2024/04/28 13:25:02
1, CHeadCtrl 发送 WM_WINDOWPOSCHANGED后不能触发ON_WM_MEASUREITEM_REFLECTvoid CHeadCtrlX1::SetHeight( int nHeight){m_bSetHeight = TRUE;#if 1m_nHeight = nHeight;WINDOWPOS wp;CRect rcWindow;::GetWindowRect( m_hWnd, &rcWindow);wp.hwnd = m_hWnd;wp.cx = rcWindow.Width();wp.cy = rcWindow.Height();wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);#endif}修改为下面这样的方法LRESULT CHeadCtrlX1::OnLayout( WPARAM wp, LPARAM lParam)
{
LRESULT lResult = CHeaderCtrl::DefWindowProc(HDM_LAYOUT, 0, lParam);
HD_LAYOUT &hdl = *( HD_LAYOUT * ) lParam;
RECT *prc = hdl.prc;
WINDOWPOS *pwpos = hdl.pwpos; if( bSetHeight ){ pwpos->cy = m_nHeight ;}else{ m_nHeight = pwpos->cy;}
return lResult;
}int CHeadCtrlX1::GetHeight( )
{
m_bSetHeight = FALSE;
#if 0
WINDOWPOS wp;
CRect rcWindow;
::GetWindowRect( m_hWnd, &rcWindow);
wp.hwnd = m_hWnd;
wp.cx = rcWindow.Width();
wp.cy = rcWindow.Height();
wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);
#endif
HDLAYOUT hdl;
WINDOWPOS wpos;
RECT rc;
// Reposition the header control so that it is placed at
// the top of its parent window's client area.
GetParent()->GetClientRect(&rc);
hdl.prc = &rc;
hdl.pwpos = &wpos;
Layout(&hdl);
return m_nHeight;
}2, CListCtrl 设置各获取和设置高度void CListCtrlCore::SetHeight( int h){ m_bSetHeight = TRUE;m_nHeight = h;WINDOWPOS wp;CRect rcWindow;::GetWindowRect( m_hWnd, &rcWindow);wp.hwnd = m_hWnd;wp.cx = rcWindow.Width();wp.cy = rcWindow.Height();wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);}int CListCtrlCore::GetHeight( ){m_bSetHeight = FALSE;WINDOWPOS wp;CRect rcWindow;::GetWindowRect( m_hWnd, &rcWindow);wp.hwnd = m_hWnd;wp.cx = rcWindow.Width();wp.cy = rcWindow.Height();wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);return m_nHeight;}void CListCtrlCore::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct){if ( m_bSetHeight){lpMeasureItemStruct->itemHeight = m_nHeight;}else{m_nHeight = lpMeasureItemStruct->itemHeight;}}
{
LRESULT lResult = CHeaderCtrl::DefWindowProc(HDM_LAYOUT, 0, lParam);
HD_LAYOUT &hdl = *( HD_LAYOUT * ) lParam;
RECT *prc = hdl.prc;
WINDOWPOS *pwpos = hdl.pwpos; if( bSetHeight ){ pwpos->cy = m_nHeight ;}else{ m_nHeight = pwpos->cy;}
return lResult;
}int CHeadCtrlX1::GetHeight( )
{
m_bSetHeight = FALSE;
#if 0
WINDOWPOS wp;
CRect rcWindow;
::GetWindowRect( m_hWnd, &rcWindow);
wp.hwnd = m_hWnd;
wp.cx = rcWindow.Width();
wp.cy = rcWindow.Height();
wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);
#endif
HDLAYOUT hdl;
WINDOWPOS wpos;
RECT rc;
// Reposition the header control so that it is placed at
// the top of its parent window's client area.
GetParent()->GetClientRect(&rc);
hdl.prc = &rc;
hdl.pwpos = &wpos;
Layout(&hdl);
return m_nHeight;
}2, CListCtrl 设置各获取和设置高度void CListCtrlCore::SetHeight( int h){ m_bSetHeight = TRUE;m_nHeight = h;WINDOWPOS wp;CRect rcWindow;::GetWindowRect( m_hWnd, &rcWindow);wp.hwnd = m_hWnd;wp.cx = rcWindow.Width();wp.cy = rcWindow.Height();wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);}int CListCtrlCore::GetHeight( ){m_bSetHeight = FALSE;WINDOWPOS wp;CRect rcWindow;::GetWindowRect( m_hWnd, &rcWindow);wp.hwnd = m_hWnd;wp.cx = rcWindow.Width();wp.cy = rcWindow.Height();wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;SendMessage(WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp);return m_nHeight;}void CListCtrlCore::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct){if ( m_bSetHeight){lpMeasureItemStruct->itemHeight = m_nHeight;}else{m_nHeight = lpMeasureItemStruct->itemHeight;}}
VC++ CListCtrl
CListCtrl用法大全(VC++)
VC++ CListCtrl控件问题!
CListCtrl能否取得Column数?
VC的问题list(CListCtrl)
谁对CListCtrl类做个介绍吧 谢谢
如何读取其他应用程序中CListCtrl的内容
vc CListCtrl 如何判断列表中的内容是否被选中?
请问各位会VC的大哥,怎么在CLISTCTRL中实现鼠标拖动?
VC++中CListCtrl如何更改其行高与Header高度?
请问怎么样先获得发VC++中的CListCtrl表中的一条记录,然后删除?
如何快速的向CListCtrl中插入大量的记录(VC)?
用鼠标单击CListCtrl控件时,如何获得编辑点的列号
CListCtrl中Icon模式下怎样设置项目间的距离及与边框的距离
vc下,使用ado 如何获得数据库中的表名并显示在clistctrl控件上
请问大家,CListCtrl里面我有两列,要分别在第一列和第二列插入值该怎么做?
在C++里怎么用代码实现变量与控件的绑定,比如把CListCtrl控件绑定到变量 m_list