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

📄 toolbox.cpp

📁 支持Windows 3.x、Windows 9x平台上的中文(GB、Big5)、日文(Shift JIS、EUC JIS)、韩文(KS C 5601)、HZ码的显示与输入,智能内码识别
💻 CPP
字号:
// toolbox.cpp : implementation file
//

#include "stdafx.h"
#include	"resource.h"
#include	"systemse.h"
//#include "toolbox.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CToolBox dialog


CToolBox::CToolBox(UINT id)
	: CCommonPage(id)
{
	//{{AFX_DATA_INIT(CToolBox)
	//}}AFX_DATA_INIT
}

void CToolBox::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CToolBox)
	DDX_Control(pDX, IDC_LIST1, m_Tools);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CToolBox, CPropertyPage)
	//{{AFX_MSG_MAP(CToolBox)
	ON_BN_CLICKED(IDC_BUTTON1, OnAddTool)
	ON_BN_CLICKED(IDC_BUTTON2, OnDeleteTool)
	ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CToolBox message handlers

//增加一个工具
void CToolBox::OnAddTool()
{
	// TODO: Add your control notification handler code here
	CFileDialog	fileDialog( TRUE , "exe" , 	"*.exe" , 
			OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT ,
			"Exec Files(*.exe;*.com)|*.exe;*.com|All Files(*.*)|*.*||" ) ; 
//	fileDialog.m_ofn.lpstrTitle	="请选择需要加入工具箱的执行程序" ;

	if( fileDialog.DoModal() == IDOK )
	{
		CString	pathName	=fileDialog.GetPathName() ;
		LPCSTR	lpcsPathName=pathName.GetBuffer( pathName.GetLength() );
		//检查工具箱中是否已经有该工具
		if( m_Tools.FindString( 0 , lpcsPathName )!=LB_ERR )	//已经存在
		{
			char	sBuff[1000] ;
			wsprintf( sBuff , "%s 已经存在了!" , lpcsPathName ) ;
			MessageBox( sBuff , "中文大观" , MB_ICONSTOP ) ;
		}
		else
		{
			m_Tools.AddString( lpcsPathName ) ;
			AfxGetMainWnd()->SendMessage( 
				WM_USER_CHANGE_ACTION_BUTTON , 
				1 , (LPARAM)lpcsPathName ) ;
		}
	}
}

//删除一个工具
void CToolBox::OnDeleteTool()
{
	// TODO: Add your control notification handler code here
	if( m_Tools.GetCurSel() != LB_ERR )	//选择了一个
		if( MessageBox( "真想删除该工具吗?" , "中文大观" ,
				MB_ICONQUESTION|MB_YESNO ) == IDYES )
		{
			AfxGetMainWnd()->SendMessage( 
				WM_USER_CHANGE_ACTION_BUTTON , 
				2 , (LPARAM)m_Tools.GetCurSel() ) ;
			m_Tools.DeleteString( m_Tools.GetCurSel() ) ;
		}
}

void CToolBox::OnDblclkList1()
{
	// TODO: Add your control notification handler code here
	OnDeleteTool() ;	//删除双击项
}

BOOL CToolBox::OnInitDialog()
{
	CCommonPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	char	sBuff[100] ;
	//得到工具数
	::GetPrivateProfileString( "工具箱" , "工具数目" , "0" ,
				sBuff , 100 , INI_FILE_NAME ) ;
	int		nNumOfTools	=atoi( sBuff ) ;

	char	sToolName[1000] ;	
	for( int i=0 ; i<nNumOfTools ; i++ )
	{
		//得到某个工具执行文件名
		wsprintf( sBuff , "工具%d" , i+1 ) ;
		::GetPrivateProfileString( "工具箱" , sBuff , "Error.error" , 
			sToolName , 1000 , INI_FILE_NAME ) ;
		if( !_fstrcmp( "Error.error" , sToolName ) )
		{
			wsprintf( sBuff , 
				"ini 文件中的工具%d 的执行文件名有问题" , i+1 ) ;
			MessageBox( sBuff , "中文大观" , MB_ICONSTOP ) ;
		}
						
		m_Tools.AddString( sToolName ) ;			
	}

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CToolBox::OnOK()
{
	// TODO: Add extra validation here
	int		nNumOfTools	=m_Tools.GetCount() ;
	if( nNumOfTools != LB_ERR )
	{
		char	sBuff[100] ;
		CString	ToolName ;

		//如果删除了某些工具,先删除INI文件中的多余工具
		//得到工具数
		::GetPrivateProfileString( "工具箱" , "工具数目" , "0" ,
				sBuff , 100 , INI_FILE_NAME ) ;
		int		nNumOfOldTools	=atoi( sBuff ) ;
		for( int i=nNumOfTools ; i<nNumOfOldTools ; i++ )
		{
			wsprintf( sBuff , "工具%d" , i+1 ) ;
			::WritePrivateProfileString( "工具箱" , sBuff , NULL , INI_FILE_NAME) ;
		}
		
		//保存工具箱中的工具
		wsprintf( sBuff , "%d" , nNumOfTools ) ;
		::WritePrivateProfileString( "工具箱" , "工具数目" , sBuff , 
			INI_FILE_NAME ) ;		//工具数目
		for( i=0 ; i<nNumOfTools ; i++ )
		{
			wsprintf( sBuff , "工具%d" , i+1 ) ;
			m_Tools.GetText( i , ToolName ) ;
			::WritePrivateProfileString( "工具箱" , sBuff , 
				ToolName.GetBuffer( ToolName.GetLength() ) , INI_FILE_NAME ) ;
		}
	}

	CPropertyPage::OnOK();
}

void CToolBox::OnCancel()
{
	//重新载入所有动作按钮
	AfxGetMainWnd()->SendMessage( 
		WM_USER_CHANGE_ACTION_BUTTON ) ;
}

⌨️ 快捷键说明

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