VB6 里怎么在自定义控件中设置输入光标的位置?
我做了一个假的TEXT控件,模拟了普通TEXT控件的输入功能。但现在就是无法实现输入法的光标跟随功能。我想知道在VB6.0里如何去设置输入光标的位置,让输入法知道应该跑到...
我做了一个假的 TEXT 控件,模拟了普通 TEXT 控件的输入功能。但现在就是无法实现输入法的光标跟随功能。
我想知道在 VB6.0 里如何去设置输入光标的位置,让输入法知道应该跑到哪里去“跟随”。
我的那个假控件上显示的内容是在 KeyPress 里用 CHR(keyascii) “手动”加上去的。 展开
我想知道在 VB6.0 里如何去设置输入光标的位置,让输入法知道应该跑到哪里去“跟随”。
我的那个假控件上显示的内容是在 KeyPress 里用 CHR(keyascii) “手动”加上去的。 展开
展开全部
根据楼主的意思,似乎假的TEXT控件里没有光标是吧.
那楼主是怎么获取键盘输入的? KEYPRESS ?? 用KEYPRESS好象没法调用输入法吧.
想问一下楼主是怎么获取中文输入的?
不行假的TEXT控件下面再放一个真的TEXT控件,哈哈.
看楼主怎么获取中文了.
----------------------------------------------------------------------------------------
根据你说的我写了一个试了试,代码如下.
Private Declare Function ImmSetCompositionWindow Lib "imm32.dll" (ByVal himc As Long, lpCompositionForm As COMPOSITIONFORM) As Long
Private Declare Function ImmGetContext Lib "imm32.dll" (ByVal hwnd As Long) As Long
Private Declare Function ImmReleaseContext Lib "imm32.dll" (ByVal hwnd As Long, ByVal himc As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type COMPOSITIONFORM
dwStyle As Long
ptCurrentPos As POINTAPI
rcArea As RECT
End Type
Private Sub Form_KeyPress(KeyAscii As Integer)
Label1.Caption = Label1.Caption & Chr(KeyAscii)
End Sub
Private Sub Label1_Click()
Dim b As COMPOSITIONFORM
b.dwStyle = &H2
b.ptCurrentPos.x = Label1.Left / 15
b.ptCurrentPos.y = Label1.Top / 15 + Label1.Height / 15
a = ImmGetContext(Me.hwnd)
ImmSetCompositionWindow a, b
ImmReleaseContext Me.hwnd, a
End Sub
那楼主是怎么获取键盘输入的? KEYPRESS ?? 用KEYPRESS好象没法调用输入法吧.
想问一下楼主是怎么获取中文输入的?
不行假的TEXT控件下面再放一个真的TEXT控件,哈哈.
看楼主怎么获取中文了.
----------------------------------------------------------------------------------------
根据你说的我写了一个试了试,代码如下.
Private Declare Function ImmSetCompositionWindow Lib "imm32.dll" (ByVal himc As Long, lpCompositionForm As COMPOSITIONFORM) As Long
Private Declare Function ImmGetContext Lib "imm32.dll" (ByVal hwnd As Long) As Long
Private Declare Function ImmReleaseContext Lib "imm32.dll" (ByVal hwnd As Long, ByVal himc As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type COMPOSITIONFORM
dwStyle As Long
ptCurrentPos As POINTAPI
rcArea As RECT
End Type
Private Sub Form_KeyPress(KeyAscii As Integer)
Label1.Caption = Label1.Caption & Chr(KeyAscii)
End Sub
Private Sub Label1_Click()
Dim b As COMPOSITIONFORM
b.dwStyle = &H2
b.ptCurrentPos.x = Label1.Left / 15
b.ptCurrentPos.y = Label1.Top / 15 + Label1.Height / 15
a = ImmGetContext(Me.hwnd)
ImmSetCompositionWindow a, b
ImmReleaseContext Me.hwnd, a
End Sub
参考资料: http://topic.csdn.net/t/20040423/13/3000326.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询