00 点击CComboBox控件的下拉按钮控制下拉框ListBox的显示和隐藏

Post date: 2012/4/24 上午 06:49:27

  1. /*
  2. The WM_CTLCOLORLISTBOX message is sent to the parent window of a list box
  3. before the system draws the list box. By responding to this message, the
  4. parent window can set the text and background colors of the list box by
  5. using the specified display device context handle.
  6. A window receives this message through its WindowProc function.
  7. */
  8. /*从MSDN上可以清楚的看到WM_CTLCOLORLISTBOX是用来自绘CComboBox下得ListBox控件的,
  9. 这里需重写CComboBox类,在虚函数中WindowProc处理WM_CTLCOLORLISTBOX消息。*/
  10. // 从这里可以很容易的看到这里很容易来控制显示和隐藏ComboBox控件的下拉框ListBox控件
  11. LRESULT CNewComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  12. {
  13. // TODO: Add your specialized code here and/or call the base class
  14. if(WM_CTLCOLORLISTBOX == message)
  15. {
  16. HWND hListBox = (HWND)lParam;
  17. ::ShowWindow(hListBox, SW_HIDE);
  18. }
  19. return CComboBox::WindowProc(message, wParam, lParam);
  20. }