如何在Edit控件中限制输入为英文字符(在中文输入法下)? 如题目所示。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 利用CEdit的WM_CHAR消息处理函数,检测nChar参数。 下面的代码用来屏蔽某一个控件的输入法状态。HIMC m_hImc = NULL; // 全局或者成员变量// Function for Disabling IMEvoid CMyDlg::DisableIME(){HWND hWnd = GetDlgItem(IDC_EDIT1)->m_hWnd;if (hWnd && IsWindow(hWnd)){// Get input context for backup. m_hImc = ImmGetContext(hWnd);// Remove association the testing if (m_hImc)ImmAssociateContext(hWnd, NULL);// Release input contextImmReleaseContext(hWnd, m_hImc);::SetFocus(hWnd);}}// Function for Enabling IMEvoid CMyDlg::EnableIME() {HWND hWnd = GetDlgItem(IDC_EDIT1)->m_hWnd;if (hWnd && IsWindow(hWnd)){// Enable IMEif (m_hImc){// Associate the input context with testing windowImmAssociateContext(hWnd, m_hImc);m_hImc = NULL;}::SetFocus(hWnd);}}回复人: pomelowu(羽战士) 利用CEdit的WM_CHAR消息处理函数,检测nChar参数,好象大于255是中文 屏蔽输入法是不能过滤粘贴上去的中文,检查nChar参数,是大于127,而不是duyhui(一天到晚游泳的鱼)所说的255。 EagleTwenty(玄风残翼@鹰)说的有道理,多谢了! C++找茬 为何在VS2008调试环境下好使,不在调试环境下不好使? 为什么VS2005与VC6.0的运行结果不一致 关于双缓存刷新问题 如何在MessageBox上显示整型变量值 端口扫描的问题 用了MFC我们还要学哪些开发框架及模式呢?? 我想在一个显示连续图像的窗口里用鼠标拖拽出一个矩形窗口,请问该怎么办? 如何在程序中模拟鼠标单击事件?! 再问如何截获api 问个问题:在javascript中external.menuArguments.document做为com中一个参数,在com中的参数类型是什么类型? 我要判断当前的输入法是否为英文输入状态应该怎么判断?
下面的代码用来屏蔽某一个控件的输入法状态。HIMC m_hImc = NULL; // 全局或者成员变量// Function for Disabling IME
void CMyDlg::DisableIME()
{
HWND hWnd = GetDlgItem(IDC_EDIT1)->m_hWnd;
if (hWnd && IsWindow(hWnd))
{
// Get input context for backup.
m_hImc = ImmGetContext(hWnd);// Remove association the testing
if (m_hImc)
ImmAssociateContext(hWnd, NULL);// Release input context
ImmReleaseContext(hWnd, m_hImc);
::SetFocus(hWnd);
}
}
// Function for Enabling IME
void CMyDlg::EnableIME()
{
HWND hWnd = GetDlgItem(IDC_EDIT1)->m_hWnd;
if (hWnd && IsWindow(hWnd))
{
// Enable IME
if (m_hImc)
{
// Associate the input context with testing window
ImmAssociateContext(hWnd, m_hImc);
m_hImc = NULL;
}::SetFocus(hWnd);
}
}
回复人: pomelowu(羽战士)