荔园在线
荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀
[回到开始]
[上一篇][下一篇]
发信人: Peter (小飞侠), 信区: Program
标 题: VC FAQ(5)
发信站: BBS 荔园晨风站 (Tue Jan 26 22:50:06 1999), 转信
_____________________________________________________
How subclass the listbox portion of a combobox?
_____________________________________________________
The listbox portion of a combobox is of type COMBOLBOX ( notice the
'L').
Because the ComboLBox window is not a child of the ComboBox window, it is
not obvious how to subclass the COMBOLBOX control. Luckily, under the
Win32
API, Windows sends a message to the COMBOBOX ( notice no 'L') called
WM_CTLCOLORLISTBOX before the listbox is drawn. The lParam passed with this
message contains the handle of the listbox. For example:
LRESULT CFileUpdateCombo::OnCtlColorListBox(WPARAM wParam,
LPARAM lParam)
{
if ( ! m_bSubclassedListBox )
{
HWND hWnd = (HWND)lParam;
CWnd* pWnd = FromHandle(hWnd);
if ( pWnd && pWnd != this )
{
// m_ListBox is derived from CListBox
m_ListBox.SubclassWindow(hWnd );
m_ListBox.SetOwner(this);
m_bSubclassedListBox = TRUE;
}
}
return (LRESULT)GetStockObject(WHITE_BRUSH);
}
--
※ 来源:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: 192.168.1.3]
[回到开始]
[上一篇][下一篇]
荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店