【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“MULTICOLUMNCOMBOBOX.CPP”一文,供大家参考学习
/************************************
REVISION LOG ENTRY
Revision By: Mihai Filimon
Revised on 9/16/98 2:20:27 PM
Comments: MultiColumnComboBox.cpp : implementation file
************************************/
#include "stdafx.h"
#include "MultiColumnComboBox.h"
#include "XPropertiesWnd.h"
#include <math.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMultiColumnComboBox
CBrush CMultiColumnComboBox::m_brBkGnd(defaultRGBBkGnd);
CFont CMultiColumnComboBox::m_font;
static const LOGFONT logFontPages =
{
/*LONG lfHeight*/8,
/*LONG lfWidth*/0,
/*LONG lfEscapement*/0,
/*LONG lfOrientation*/0,
/*LONG lfWeight*/FW_NORMAL,
/*BYTE lfItalic*/FALSE,
/*BYTE lfUnderline*/FALSE,
/*BYTE lfStrikeOut*/FALSE,
/*BYTE lfCharSet*/ANSI_CHARSET,
/*BYTE lfOutPrecision*/0,
/*BYTE lfClipPrecision*/0,
/*BYTE lfQuality*/DEFAULT_QUALITY,
/*BYTE lfPitchAndFamily*/DEFAULT_PITCH,
/*CHAR lfFaceName[LF_FACESIZE]*/_T("MS Sans Serif")
};
// Function name : CMultiColumnComboBox::CMultiColumnComboBox
// Description : default constuctor
// Return type :
CMultiColumnComboBox::CMultiColumnComboBox(int nColumnKey)
{
RegClassMultiColumnComboBox();
m_pListCtrl = NULL;
m_pEdit = NULL;
m_bCaptured = FALSE;
m_nColumnKey = nColumnKey;
SetRateWidth(0.0);
SetMultipleHeight();
m_bFirstShow = TRUE;
m_nCurrentItem = -1;
}
// Function name : CMultiColumnComboBox::~CMultiColumnComboBox
// Description : virtual destructor
// Return type :
CMultiColumnComboBox::~CMultiColumnComboBox()
{
}
BEGIN_MESSAGE_MAP(CMultiColumnComboBox, CWnd)
//{{AFX_MSG_MAP(CMultiColumnComboBox)
ON_WM_DESTROY()
ON_WM_LBUTTONDOWN()
ON_WM_WINDOWPOSCHANGED()
ON_WM_PAINT()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
ON_WM_SETFOCUS()
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMultiColumnComboBox message handlers
UINT CMultiColumnComboBox::m_nSelChange = NULL;
// Function name : CMultiColumnComboBox::RegClassMultiColumnComboBox
// Description : Register this window class
// Return type : BOOL
BOOL CMultiColumnComboBox::RegClassMultiColumnComboBox()
{
WNDCLASS wndClass;
wndClass.style = CS_DBLCLKS;
wndClass.lpfnWndProc = ::DefWindowProc;
wndClass.cbClsExtra = NULL;
wndClass.cbWndExtra = NULL;
wndClass.hInstance = AfxGetInstanceHandle();
wndClass.hIcon = NULL;
wndClass.hCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)m_brBkGnd;
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = wndClassName;
BOOL bResult = AfxRegisterClass(&wndClass);
if (bResult)
{
if (!m_nSelChange)
m_nSelChange = RegisterWindowMessage(defaultSelChange);
if (!m_font.GetSafeHandle())
{
//At the first call set the new font
m_font.CreateFontIndirect(&logFontPages);
}
}
return bResult;
}
CMultiColumnComboBox* CMultiColumnComboBox::m_pActiveMCBox = NULL;
CMultiColumnComboBox::CWindowProcs CMultiColumnComboBox::m_wndProcs;
// Function name : CMultiColumnComboBox::ListCtrlWindowProc
// Description : ListControl window procedure
// Return type : LRESULT CALLBACK
// Argument : HWND hWnd
// Argument : UINT nMsg
// Argument : WPARAM wParam
// Argument : LPARAM lParam
LRESULT CALLBACK CMultiColumnComboBox::ListCtrlWindowProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
CMultiColumnComboBox* pOwner = NULL;
if (pOwner = CMultiColumnComboBox::m_pActiveMCBox)
pOwner->ForwardMessage(nMsg, wParam, lParam);
LRESULT lResult = CallWindowProc( CMultiColumnComboBox::m_wndProcs.GetOldListCtrlProcedure(hWnd), hWnd, nMsg, wParam, lParam );
return lResult;
}
// Function name : CMultiColumnComboBox::ParentWindowProc
// Description : Parent window procedure.
// Return type : LRESULT CALLBACK
// Argument : HWND hWnd
// Argument : UINT nMsg
// Argument : WPARAM wParam
// Argument : LPARAM lParam
LRESULT CALLBACK CMultiColumnComboBox::ParentWindowProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
if (CMultiColumnComboBox*