📄 mycombobox.cpp
字号:
// MyComboBox.cpp : 实现文件
//
#include "stdafx.h"
#include "LManage.h"
#include "MyComboBox.h"
// CMyComboBox
IMPLEMENT_DYNAMIC(CMyComboBox, CComboBox)
CMyComboBox::CMyComboBox()
{
}
CMyComboBox::~CMyComboBox()
{
}
BEGIN_MESSAGE_MAP(CMyComboBox, CComboBox)
END_MESSAGE_MAP()
// 得到当前显示的ID
int CMyComboBox::GetCurMyID()
{
CString str;
GetLBText( GetCurSel(), str );
return GetStringID(str);
}
// 添加当前显示字符串
void CMyComboBox::AddMyString( int id , CString name )
{
this->AddString( this->GetShowString( id, name ) );
}
// 设置当前显示项,根据ID确定
void CMyComboBox::SetMyCurSel( int id )
{
CString str;
for( int i = 0; i < GetCount(); i++ )
{
GetLBText( i, str );
if( GetStringID(str) == id )
{
SetCurSel( i );
return;
}
}
SetCurSel(0);
}
// 组成显示字符串
CString CMyComboBox::GetShowString( int id, CString name )
{
CString temp;
temp.Format( "%d %s", id, name );
return temp;
}
// 得到显示字符串的ID
int CMyComboBox::GetStringID( CString str )
{
int p = str.Find( " " );
if( p != -1 )
{
CString id = str.Mid( 0, p );
return (int)atol( id );
}
else
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -