发信人: mendy.bbs@bbs.nju.edu.cn (孟迪), 信区: cnprogram
标 题: VC FAQ(5)
发信站: nju_bbs (Sun Apr 19 13:49:47 1998)
转信站: Lilac!ustcnews!nju_bbs
2m发信人:m TMN (派生类)
2m信 区:m RAD
2m标 题:m VC FAQ(5)
2m发信站:m '3m紫金飞鸿m' (Wed Apr 8 08:13:51 1998) , 5m站内信件m
[返回首页] [分类讨论区] [全部讨论区]
_____________________________________________________
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);
}
[返回首页] [分类讨论区] [全部讨论区]
--
m;31m※ 来源:·紫金飞鸿 bbs.njupt.edu.cn·[FROM: pc05.info.njupt]m
--
※ 来源:.南大小百合信息交换站 bbs.nju.edu.cn.[FROM: a507yjh.nju.edu]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.148毫秒