basecombobox.cpp

来自「用Visual c++实现汽配件管理系统」· C++ 代码 · 共 78 行

CPP
78
字号
// BaseComboBox.cpp : implementation file
//

#include "stdafx.h"
#include "qpglxt.h"
#include "BaseComboBox.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBaseComboBox

CBaseComboBox::CBaseComboBox()
{
}

CBaseComboBox::~CBaseComboBox()
{
}


BEGIN_MESSAGE_MAP(CBaseComboBox, CComboBox)
	//{{AFX_MSG_MAP(CBaseComboBox)
	ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
	ON_CONTROL_REFLECT(CBN_EDITCHANGE, OnEditchange)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBaseComboBox message handlers

void CBaseComboBox::SetRecordset(RxRecordset rs, CString Field)
{
	CString sText;
	int m=rs.GetRecordCount();
	rs.MoveFirst();
	for(int i=0;i<rs.GetRecordCount();i++)
	{
		rs.Move(i);
		sText=rs.GetFieldValue(Field);
		this->AddString(sText);
	}
	rst=rs;
}

void CBaseComboBox::SetFieldset(RxRecordset rs)
{
	CString FieldName;
	int m=rs.GetFieldCount();
	for(int i=0;i<m;i++)
	{
		FieldName=rs.GetFieldName(i);
		this->AddString(FieldName);
	}
	rst=rs;
}

BOOL CBaseComboBox::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
		pMsg->wParam=9;		
	return CComboBox::PreTranslateMessage(pMsg);
}

void CBaseComboBox::OnSelchange() 
{
	m_CurrentFieldType=rst.GetFieldType(this->GetCurSel());		
}

void CBaseComboBox::OnEditchange() 
{
	m_CurrentFieldType=rst.GetFieldType(this->GetCurSel());	
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?