Combox滚动条hook

How do I 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 list box. 
明白了,可以用枚举线程窗口的方法得到COMBOLBOX这个类的窗口的指针,然后hook它,就挂上滚动条了,因为它不是ComboBox的子窗口,当然不能枚举子窗口了,还有一种方法就是在ComboBox中处理WM_CTLCOLORLISTBOX消息,lparam就是它了,然后hook它,直接hook ComboBox是无效的。


BOOL GetComboBoxInfo(      
    HWND hwndCombo,
    PCOMBOBOXINFO pcbi
);
typedef struct tagCOMBOBOXINFO {
    DWORD cbSize;
    RECT rcItem;
    RECT rcButton;
    DWORD stateButton;
    HWND hwndCombo;
    HWND hwndItem;
    HWND hwndList;//hwndList就是COMBOLBOX的hwnd
} COMBOBOXINFO, *PCOMBOBOXINFO, *LPCOMBOBOXINFO;

转载于:https://www.cnblogs.com/hgy413/archive/2011/08/23/3693605.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值