This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
forked from ryancheung/MonoGame.IMEHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IMMNativeMethods.cs
154 lines (128 loc) · 4.96 KB
/
IMMNativeMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#if WINDOWSDX || XNA
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace MonoGame.IMEHelper
{
internal static class IMM
{
#region Constants
public const int KeyDown = 0x0100, Char = 0x0102;
public const int
GCSCompReadStr = 0x0001,
GCSCompReadAttr = 0x0002,
GCSCompReadClause = 0x0004,
GCSCompStr = 0x0008,
GCSCompAttr = 0x0010,
GCSCompClause = 0x0020,
GCSCursorPos = 0x0080,
GCSDeltaStart = 0x0100,
GCSResultReadStr = 0x0200,
GCSResultReadClause = 0x0400,
GCSResultStr = 0x0800,
GCSResultClause = 0x1000;
public const int
ImeStartCompostition = 0x010D,
ImeEndComposition = 0x010E,
ImeComposition = 0x010F,
ImeKeyLast = 0x010F,
ImeSetContext = 0x0281,
ImeNotify = 0x0282,
ImeControl = 0x0283,
ImeCompositionFull = 0x0284,
ImeSelect = 0x0285,
ImeChar = 0x286,
ImeRequest = 0x0288,
ImeKeyDown = 0x0290,
ImeKeyUp = 0x0291;
public const int
ImnCloseStatusWindow = 0x0001,
ImnOpenStatusWindow = 0x0002,
ImnChangeCandidate = 0x0003,
ImnCloseCandidate = 0x0004,
ImnOpenCandidate = 0x0005,
ImnSetConversionMode = 0x0006,
ImnSetSentenceMode = 0x0007,
ImnSetOpenStatus = 0x0008,
ImnSetCandidatePos = 0x0009,
ImnSetCompositionFont = 0x000A,
ImnSetCompositionWindow = 0x000B,
ImnSetStatusWindowPos = 0x000C,
ImnGuideLine = 0x000D,
ImnPrivate = 0x000E;
public const int InputLanguageChange = 0x0051;
#endregion
[DllImport("imm32.dll", SetLastError = true)]
public static extern IntPtr ImmAssociateContext(IntPtr hWnd, IntPtr hIMC);
[DllImport("imm32.dll", SetLastError = true)]
public static extern IntPtr ImmReleaseContext(IntPtr hWnd, IntPtr hIMC);
[DllImport("imm32.dll", CharSet = CharSet.Unicode)]
public static extern uint ImmGetCandidateList(IntPtr hIMC, uint deIndex, IntPtr candidateList, uint dwBufLen);
[DllImport("imm32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int ImmGetCompositionString(IntPtr hIMC, int CompositionStringFlag, IntPtr buffer, int bufferLength);
[DllImport("imm32.dll", SetLastError = true)]
public static extern IntPtr ImmGetContext(IntPtr hWnd);
[DllImport("imm32.dll", SetLastError = true)]
public static extern bool ImmGetOpenStatus(IntPtr hIMC);
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
public static extern bool TranslateMessage(IntPtr message);
[DllImport("user32.dll")]
public static extern short VkKeyScanEx(char ch, IntPtr dwhkl);
public const int CFS_CANDIDATEPOS = 64;
[DllImport("imm32.dll", SetLastError = true)]
public static extern bool ImmSetCandidateWindow(IntPtr hIMC, ref CandidateForm candidateForm);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
[DllImport("user32.dll", SetLastError = true)]
public static extern bool DestroyCaret();
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SetCaretPos(int x, int y);
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct CandidateList
{
public uint dwSize;
public uint dwStyle;
public uint dwCount;
public uint dwSelection;
public uint dwPageStart;
public uint dwPageSize;
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 1, ArraySubType = UnmanagedType.U4)]
public uint[] dwOffset;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct Point
{
public int X;
public int Y;
public Point(int x, int y)
{
X = x;
Y = y;
}
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
}
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct CandidateForm
{
public uint dwIndex;
public uint dwStyle;
public Point ptCurrentPos;
public Rect rcArea;
public CandidateForm(Point pos)
{
this.dwIndex = 0;
this.dwStyle = CFS_CANDIDATEPOS;
this.ptCurrentPos = pos;
this.rcArea = new Rect();
}
}
}
}
#endif