📄 inputset.cpp
字号:
// inputset.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "systemse.h"
#include "inputset.h"
#include "iniinput.h"
#include "csinput.h" //输入法头文件
extern CInputInit OInputInit ; //输入菜单初始化对象
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInputSet dialog
CInputSet::CInputSet(UINT id)
: CCommonPage(id)
{
//{{AFX_DATA_INIT(CInputSet)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CInputSet::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInputSet)
DDX_Control(pDX, IDC_LIST1, m_InputMethods);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInputSet, CPropertyPage)
//{{AFX_MSG_MAP(CInputSet)
ON_BN_CLICKED(IDC_ADD_INPUT_METHOD, OnAddInputMethod)
ON_BN_CLICKED(IDC_DEL_INPUT_METHOD, OnDelInputMethod)
ON_LBN_DBLCLK(IDC_LIST1, OnDelInputMethod)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInputSet message handlers
void CInputSet::OnAddInputMethod()
{
// TODO: Add your control notification handler code here
CFileDialog fileDialog( TRUE , "iml" , "*.iml" ,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT ,
"CS Input Method(*.iml)|*.iml|UCDOS Input Method(*.txt)|*.txt| All Files (*.*) | *.* ||"
) ;
if( fileDialog.DoModal() == IDOK )
{
//得到文件后缀
CString fileExt =fileDialog.GetFileExt() ;
if( fileExt != "TXT" && fileExt != "IML" )
AfxMessageBox( "文件类型不对,必须是.txt或.iml文件!" ,
MB_OK|MB_ICONINFORMATION ) ;
else
{
//增加一种输入法
CString path =fileDialog.GetPathName() ;
//判断文件类型
if( fileExt == "TXT" ) //是UCDOS文本文件
{
if( !TranslateUcdos( path ) ) //转换失败
return ;
::MessageBox( this->m_hWnd , "输入法文件转换成功" ,
"转换输入法" ,
MB_OK|MB_ICONEXCLAMATION ) ;
//重新组织文件名,组织库文件名
path =path.Left( path.GetLength()-3 ) ; //去掉TXT后缀
path +="iml" ; //新后缀
}
//关闭以前的输入法
UnloadInputLib() ;
//安装该输入法
if( !LoadInputLib( path ) )
return ;
//得到输入法名
char sName[20] ;
GetInputMethodName( sName , 20 ) ;
char sBuff[100] ;
wsprintf( sBuff , "%s输入法安装成功!" , sName ) ;
::MessageBox( m_hWnd , sBuff , "安装输入法" ,
MB_OK|MB_ICONEXCLAMATION ) ;
//将输入法加入列表框
m_InputMethods.InsertString( 0 , sName ) ;
//将输入法加入INI文件和菜单
OInputInit.AddInputMethod( sName , path ) ;
}
}
}
void CInputSet::OnDelInputMethod()
{
// TODO: Add your control notification handler code here
int nSelectItem =m_InputMethods.GetCurSel() ;
if( nSelectItem == LB_ERR ) //没有选择
return ;
if( ::MessageBox( m_hWnd , "真想删除该输入法吗?" , "警告" ,
MB_YESNO|MB_ICONEXCLAMATION ) == IDYES )
{
//将其从列表框中删除
m_InputMethods.DeleteString( nSelectItem ) ;
//将其从INI文件和菜单中删除
OInputInit.DeleteInputMethod( nSelectItem ) ;
}
}
BOOL CInputSet::OnInitDialog()
{
CCommonPage ::OnInitDialog();
// TODO: Add extra initialization here
//得到输入法数
int nMethodNum =OInputInit.GetInputMethodNum() ;
char sInputName[100] ; //输入法名称
char sInputFileName[100] ; //输入法文件名
for( int i=1 ; i<nMethodNum ; i++ )
{
//得到输入法的名字与文件名
OInputInit.GetInputMethodMess( i , sInputName , 100 ,
sInputFileName , 100 ) ;
//将输入法名加入列表框
m_InputMethods.InsertString( 0 , sInputName ) ;
}
return TRUE; // return TRUE unless you set the focus to a control
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -