ListWidthChgCombo.cpp
资源名称:ComboBox.rar [点击查看]
上传用户:hbjdyb2005
上传日期:2021-01-26
资源大小:168k
文件大小:1k
源码类别:
组合框控件
开发平台:
Visual C++
- // ListWidthChgCombo.cpp : implementation file
- //
- #include "stdafx.h"
- #include "CListWidthChgCombo.h"
- #include "ListWidthChgCombo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CListWidthChgCombo
- CListWidthChgCombo::CListWidthChgCombo()
- {
- ListWidth=100;
- }
- CListWidthChgCombo::~CListWidthChgCombo()
- {
- }
- BEGIN_MESSAGE_MAP(CListWidthChgCombo, CComboBox)
- //{{AFX_MSG_MAP(CListWidthChgCombo)
- ON_WM_CTLCOLOR()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CListWidthChgCombo message handlers
- HBRUSH CListWidthChgCombo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
- switch (nCtlColor)
- {
- case CTLCOLOR_EDIT:
- break;
- case CTLCOLOR_LISTBOX:
- if (ListWidth > 0)
- {
- CRect rect;
- pWnd->GetWindowRect(&rect);
- if (rect.Width() != ListWidth) {
- rect.right = rect.left + ListWidth;
- pWnd->MoveWindow(&rect);
- }
- }
- break;
- }
- // TODO: Return a different brush if the default is not desired
- return hbr;
- }