00000016.txt
来自「水木清华BBS站的讨论区精华集锦」· 文本 代码 · 共 52 行
TXT
52 行
--===BBS水木清华站∶精华区===--
-===BBS水木清华站∶精华区===-
_____________________________________________________
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水木清华站∶精华区===-
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?