⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycombobox.cpp

📁 SQLBig5BugTool 宽字符操作问题
💻 CPP
字号:
// MyComboBox.cpp: implementation of the CMyComboBox class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MyComboBox.h"

#include "myinifile.h"
#include "mylog.h"
#include <string>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMyComboBox::CMyComboBox()
{

}

CMyComboBox::~CMyComboBox()
{

}

BOOL ChooseFolderWithComboBox(
							  CComboBox*	pComboBox,
							  const char*	pszChooseFolderTitle,
							  const char*	pszIniSection,
							  const char*	pszIniFile,
							  const DWORD   dwMaxItem,
							  HWND			hWnd
							  )
{
	std::string strFolder;
	
	CString strFolderOld;
	
	if(pComboBox->GetCurSel()>=0)
	{
		pComboBox->GetLBText(pComboBox->GetCurSel(),strFolderOld);
	}
	
	if(ChooseFolder(
		pszChooseFolderTitle,
		hWnd,//GetSafeHwnd(),
		(const char*)strFolderOld,
		strFolder
		))
	{
		if(pComboBox->GetCount()>=dwMaxItem)
		{
			pComboBox->DeleteString(0);
		}

		CString strFolderNew=strFolder.c_str();
		strFolderNew.MakeLower();
		if(pComboBox->FindString(-1,strFolderNew)<0)
		{
			pComboBox->AddString(strFolderNew);
		}
		pComboBox->SelectString(-1,strFolderNew);
		
		
		//
		SaveComboBox(
			pComboBox,
			pszIniFile,
			pszIniSection
			);
		
		return TRUE;
	};

	return FALSE;
}

void SaveComboBox(
				  CComboBox*	pComboBox,
				  const char*	pszIniFile,
				  const char*	pszSection
				  )
{
	if(!pComboBox->GetSafeHwnd())
	{
		return;
	}
	STRING_LIST StringList;
	
	CString strTxt;
	for(long l=0;l<pComboBox->GetCount();l++)
	{
		pComboBox->GetLBText(l,strTxt);

		StringList.push_back((const char*)strTxt);
	}
	SaveIniStringList(
					   pszIniFile,
					   pszSection,
					   StringList
					   );

	strTxt="";
	if(pComboBox->GetCurSel()>=0)
	{
		pComboBox->GetLBText(pComboBox->GetCurSel(),strTxt);
	};
	WritePrivateProfileString(
		pszSection,
		"LastSelectedItem",
		strTxt,
		pszIniFile
		);
}

void LoadComboBox(
				  CComboBox*	pComboBox,
				  const char*	pszIniFile,
				  const char*	pszSection
				  )
{
	if(!pComboBox->GetSafeHwnd())
	{
		return;
	}
	STRING_LIST StringList;
	
	LoadIniStringList(
					   pszIniFile,
					   pszSection,
					   StringList
					   );

	pComboBox->ResetContent();

	for(long l=0;l<StringList.size();l++)
	{
		pComboBox->AddString((const char*)StringList[l].c_str());
	}
	
	char szTxt[1024]={0,};
	szTxt[0]=0;
	GetPrivateProfileString(
		pszSection,
		"LastSelectedItem",
		"",
		szTxt,
		sizeof(szTxt),
		pszIniFile
		);

	pComboBox->SelectString(0,szTxt);

}

⌨️ 快捷键说明

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