资源简介
研究combox下拉控件不可多得的例子。
代码片段和文件信息
// ComboBoxXP.cpp : implementation file
//
#include “stdafx.h“
#include “./ComboBoxXP.h“
#include “skinscrollwnd.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static WNDPROC g_pWndProc = 0;
extern “C“ static LRESULT FAR PASCAL BitComboBoxListBoxProc(HWND hWnd UINT nMsg WPARAM wParam LPARAM lParam)
{
return CallWindowProc(g_pWndProc hWnd nMsg wParam lParam);
}
/////////////////////////////////////////////////////////////////////////////
// CComboBoxXP
CComboBoxXP::CComboBoxXP()
{
m_colBackGroundHighLight = RGB(255255255);
m_colBackGroundHighLight1 = RGB(130214255);
m_colTextHighLight = RGB(000);
m_colBackGroundNormal = RGB(255255255);//RGB(223230240);//
m_colTextNormal = RGB(000);
m_hWndList = NULL;
}
CComboBoxXP::~CComboBoxXP()
{
}
BEGIN_MESSAGE_MAP(CComboBoxXP CComboBox)
//{{AFX_MSG_MAP(CComboBoxXP)
ON_WM_DESTROY()
ON_WM_PAINT()
ON_WM_CREATE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_CTLCOLORLISTBOX OnCtlColorListBox)
ON_CONTROL_REFLECT(CBN_DROPDOWN OnCbnDropdown)
ON_CONTROL_REFLECT(CBN_CLOSEUP OnCbnCloseup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CComboBoxXP message handlers
void CComboBoxXP::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
if( lpDrawItemStruct->itemID == -1 )
return;
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CBrush pBrush;
CString sItem;
if(lpDrawItemStruct->itemState & ODS_FOCUS)
{
pBrush.CreateSolidBrush(m_colBackGroundHighLight1);
dc.FillRect(&lpDrawItemStruct->rcItem &pBrush);
dc.SetTextColor(m_colTextHighLight);
}
else
{
pBrush.CreateSolidBrush(m_colBackGroundNormal);
dc.FillRect(&lpDrawItemStruct->rcItem &pBrush);
dc.SetTextColor(m_colTextNormal);
}
if(m_lstBox.GetSafeHwnd())
{
// Copy the text of the item to a string
GetLBText(lpDrawItemStruct->itemID sItem);
dc.SetBkMode(TRANSPARENT);
// Draw the text after the images left postion
lpDrawItemStruct->rcItem.left = 4;
dc.Selectobject(m_lstBox.GetFont());
CFont *pOldFont = dc.Selectobject(&m_font);
dc.DrawText(sItem &lpDrawItemStruct->rcItem DT_VCENTER | DT_SINGLELINE);
dc.Selectobject(pOldFont);
}
if(lpDrawItemStruct->itemAction & ODA_DRAWENTIRE)
Invalidate();
}
LRESULT CComboBoxXP::OnCtlColorListBox(WPARAM wParam LPARAM lParam)
{
//*
// Here we need to get a reference to the listbox of the combobox
// (the dropdown part). We can do it using
//TRACE(“OnCtlColorListBox()\n“);
if (this->m_lstBox.m_hWnd == 0) {
HWND hWnd = (HWND)lParam;
if (hWnd != 0 && hWnd != m_hWnd)
{
// Save the handle
m_lstBox.m_hWnd = hWnd;
m_lstBox.ShowWindow(SW_HIDE);
SkinWndScroll(&m_lstBoxm_hBmpScroll);
m_hWndList=m_lstBox.m_hWnd;
// Subclass ListBox
g_pWndProc = (WNDPROC)GetWindowLong(m_lstBox.m_hWnd GW
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7384 2010-07-14 16:38 TESTComBo\ComboBoxXP.cpp
文件 2130 2010-07-14 16:18 TESTComBo\comboboxxp.h
文件 5725 2010-06-03 09:14 TESTComBo\OwnerComBox.cpp
文件 1949 2010-06-03 09:09 TESTComBo\OwnerComBox.h
文件 3633 2010-06-03 08:48 TESTComBo\ReadMe.txt
文件 1304 2010-06-03 11:39 TESTComBo\res\right.bmp
文件 13784 2010-06-03 11:33 TESTComBo\res\scrollbar.bmp
文件 1078 2010-06-03 08:48 TESTComBo\res\TESTComBo.ico
文件 401 2010-06-03 08:48 TESTComBo\res\TESTComBo.rc2
文件 777 2010-06-03 09:43 TESTComBo\resource.h
文件 16898 2010-06-03 10:59 TESTComBo\skinscrollbar.cpp
文件 2152 2007-01-22 20:37 TESTComBo\skinscrollbar.h
文件 10198 2007-06-18 15:22 TESTComBo\skinscrollwnd.cpp
文件 1814 2006-12-22 15:38 TESTComBo\skinscrollwnd.h
文件 211 2010-06-03 08:48 TESTComBo\StdAfx.cpp
文件 1075 2010-06-03 09:23 TESTComBo\StdAfx.h
文件 50864 2010-06-03 10:08 TESTComBo\TESTComBo.aps
文件 1734 2010-11-02 10:06 TESTComBo\TESTComBo.clw
文件 2105 2010-06-03 08:49 TESTComBo\TESTComBo.cpp
文件 4762 2010-07-14 16:53 TESTComBo\TESTComBo.dsp
文件 541 2010-06-03 08:48 TESTComBo\TESTComBo.dsw
文件 1357 2010-06-03 08:48 TESTComBo\TESTComBo.h
文件 82944 2010-11-02 10:06 TESTComBo\TESTComBo.ncb
文件 55808 2010-11-02 10:06 TESTComBo\TESTComBo.opt
文件 1571 2010-11-02 10:06 TESTComBo\TESTComBo.plg
文件 5636 2010-06-03 10:08 TESTComBo\TESTComBo.rc
文件 4720 2010-11-02 10:05 TESTComBo\TESTComBoDlg.cpp
文件 1413 2010-11-02 10:05 TESTComBo\TESTComBoDlg.h
目录 0 2012-08-01 15:24 TESTComBo\res
目录 0 2012-09-24 10:44 TESTComBo
............此处省略3个文件信息
- 上一篇:TCP/IP通讯源代码
- 下一篇:数电模电面试题集锦 值得参考
评论
共有 条评论