-
VS2005IDE中输入法全角[控制输入问题]
1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Text;
7
using System.Windows.Forms;
8
using System.Runtime.InteropServices;
9
10
namespace Lqjt
11![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
12
public partial class ImeForm : Form
13![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
14
public ImeForm()
15![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
16
InitializeComponent();
17
}
18
//声明一些API函数
19
[DllImport("imm32.dll")]
20
public static extern IntPtr ImmGetContext(IntPtr hwnd);
21
[DllImport("imm32.dll")]
22
public static extern bool ImmGetOpenStatus(IntPtr himc);
23
[DllImport("imm32.dll")]
24
public static extern bool ImmSetOpenStatus(IntPtr himc, bool b);
25
[DllImport("imm32.dll")]
26
public static extern bool ImmGetConversionStatus(IntPtr himc, ref int lpdw, ref int lpdw2);
27
[DllImport("imm32.dll")]
28
public static extern int ImmSimulateHotKey(IntPtr hwnd, int lngHotkey);
29
private const int IME_CMODE_FULLSHAPE = 0x8;
30
private const int IME_CHOTKEY_SHAPE_TOGGLE = 0x11;
31
protected override void OnActivated(EventArgs e)
32![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
33
base.OnActivated(e);
34
IntPtr HIme = ImmGetContext(this.Handle);
35
if (ImmGetOpenStatus(HIme)) //如果输入法处于打开状态
36![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
37
int iMode = 0;
38
int iSentence = 0;
39
bool bSuccess = ImmGetConversionStatus(HIme, ref iMode, ref iSentence); //检索输入法信息
40
if (bSuccess)
41![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
42
if ((iMode & IME_CMODE_FULLSHAPE) > 0) //如果是全角
43
ImmSimulateHotKey(this.Handle, IME_CHOTKEY_SHAPE_TOGGLE); //转换成半角
44
}
45
46
}
47
}
48
}//form
49
}
-
相关阅读:
编译原理:正则表达式
编译原理:基于状态转换图识别for语句
汇编小笔记
win10汇编如何debug(小白向)
nodejs模块引用
nodejs环境设置理解
分享几个看上去很酷炫的运算
JavaScript数据结构 (手打代码)
爬取煎蛋XXOO妹子图片
Python Selenium官方文档阅读笔记
-
原文地址:https://www.cnblogs.com/winnxm/p/989506.html
Copyright © 2020-2023
润新知