现在难题:
如何定位输入法状态栏到光标位置fmText.frm
====================================================================
VERSION 5.00
Begin VB.Form Form1
Caption = "Lesson4_4"
ClientHeight = 4185
ClientLeft = 60
ClientTop = 345
ClientWidth = 6690
LinkTopic = "Form1"
ScaleHeight = 4185
ScaleWidth = 6690
StartUpPosition = 3 'Windows の既定値
Begin VB.TextBox Text1
Height = 1350
Left = 1560
TabIndex = 1
Text = "Text1"
Top = 2760
Width = 4935
End
Begin VB.PictureBox Picture1
BackColor = &H00FFFFFF&
Height = 2475
Left = 1560
ScaleHeight = 2415
ScaleWidth = 4875
TabIndex = 0
Top = 60
Width = 4935
End
Begin VB.Label Label1
Caption = "Textソリシ"
Height = 315
Left = 660
TabIndex = 3
Top = 2880
Width = 1335
End
Begin VB.Label P
Caption = "PictureBox"
Height = 255
Left = 180
TabIndex = 2
Top = 240
Width = 1515
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function CreateCaret& Lib "user32" (ByVal hwnd As Long, ByVal hBitmap As Long, ByVal nWidth As Long, ByVal nHeight As Long)
Private Declare Function ShowCaret& Lib "user32" (ByVal hwnd As Long)
Private Declare Function SetCaretPos& Lib "user32" (ByVal x As Long, ByVal y As Long)
Private Declare Function HideCaret& Lib "user32" (ByVal hwnd As Long)Private Declare Function DestroyCaret& Lib "user32" ()
Private Sub Form_Load()
Form1.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
Picture1.FontSize = 14
SubClass Picture1.hwnd
End SubPrivate Sub Form_Unload(Cancel As Integer)
UnSubClass Picture1.hwnd
End SubPrivate Sub Picture1_Click()
' Picture1_GotFocus
End SubPrivate Sub Picture1_GotFocus()
Dim dl&
Dim CreateHeight As Integer
CreateHeight = Picture1.TextHeight("I")
dl& = CreateCaret(Picture1.hwnd, 0, 2, CreateHeight)
dl& = SetCaretPos(Picture1.CurrentX, Picture1.CurrentY)
dl& = ShowCaret(Picture1.hwnd)
End SubPrivate Sub Picture1_KeyPress(KeyAscii As Integer)
Dim dl& dl& = HideCaret(Picture1.hwnd)
Picture1.Print Chr(KeyAscii);
If Picture1.CurrentX >= (Picture1.Width - Picture1.TextWidth("W")) Then 'ササミミ
Picture1.CurrentX = 0
Picture1.CurrentY = Picture1.CurrentY + Picture1.TextHeight("I")
End If
dl& = SetCaretPos(Picture1.CurrentX, Picture1.CurrentY)
dl& = ShowCaret(Picture1.hwnd)
End SubPrivate Sub Picture1_LostFocus()
Dim dl&
' dl& = DestroyCaret
End SubModule1.bas
=========================================================
Attribute VB_Name = "Module1"
Option ExplicitPublic Const WM_IME_SETCONTEXT = &H281
Public Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const GWL_WNDPROC = (-4)Dim hPrevProc As LongPublic Sub SubClass(hHwnd As Long)
hPrevProc = SetWindowLong(hHwnd, GWL_WNDPROC, AddressOf WindowProc)
End SubPublic Sub UnSubClass(hHwnd As Long)
SetWindowLong hHwnd, GWL_WNDPROC, hPrevProc
End SubPublic Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_IME_SETCONTEXT
WindowProc = DefWindowProc(hwnd, uMsg, wParam, lParam)
Exit Function
End Select
WindowProc = CallWindowProc(hPrevProc, hwnd, uMsg, wParam, lParam)
End Function
Project1.vbp
=======================================================================
Type=Exe
Form=.\fmText.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation
Module=Module1; Module1.bas
IconForm="Form1"
Startup="Form1"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="-"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1[MS Transaction Server]
AutoRefresh=1
如何定位输入法状态栏到光标位置fmText.frm
====================================================================
VERSION 5.00
Begin VB.Form Form1
Caption = "Lesson4_4"
ClientHeight = 4185
ClientLeft = 60
ClientTop = 345
ClientWidth = 6690
LinkTopic = "Form1"
ScaleHeight = 4185
ScaleWidth = 6690
StartUpPosition = 3 'Windows の既定値
Begin VB.TextBox Text1
Height = 1350
Left = 1560
TabIndex = 1
Text = "Text1"
Top = 2760
Width = 4935
End
Begin VB.PictureBox Picture1
BackColor = &H00FFFFFF&
Height = 2475
Left = 1560
ScaleHeight = 2415
ScaleWidth = 4875
TabIndex = 0
Top = 60
Width = 4935
End
Begin VB.Label Label1
Caption = "Textソリシ"
Height = 315
Left = 660
TabIndex = 3
Top = 2880
Width = 1335
End
Begin VB.Label P
Caption = "PictureBox"
Height = 255
Left = 180
TabIndex = 2
Top = 240
Width = 1515
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function CreateCaret& Lib "user32" (ByVal hwnd As Long, ByVal hBitmap As Long, ByVal nWidth As Long, ByVal nHeight As Long)
Private Declare Function ShowCaret& Lib "user32" (ByVal hwnd As Long)
Private Declare Function SetCaretPos& Lib "user32" (ByVal x As Long, ByVal y As Long)
Private Declare Function HideCaret& Lib "user32" (ByVal hwnd As Long)Private Declare Function DestroyCaret& Lib "user32" ()
Private Sub Form_Load()
Form1.ScaleMode = vbPixels
Picture1.ScaleMode = vbPixels
Picture1.FontSize = 14
SubClass Picture1.hwnd
End SubPrivate Sub Form_Unload(Cancel As Integer)
UnSubClass Picture1.hwnd
End SubPrivate Sub Picture1_Click()
' Picture1_GotFocus
End SubPrivate Sub Picture1_GotFocus()
Dim dl&
Dim CreateHeight As Integer
CreateHeight = Picture1.TextHeight("I")
dl& = CreateCaret(Picture1.hwnd, 0, 2, CreateHeight)
dl& = SetCaretPos(Picture1.CurrentX, Picture1.CurrentY)
dl& = ShowCaret(Picture1.hwnd)
End SubPrivate Sub Picture1_KeyPress(KeyAscii As Integer)
Dim dl& dl& = HideCaret(Picture1.hwnd)
Picture1.Print Chr(KeyAscii);
If Picture1.CurrentX >= (Picture1.Width - Picture1.TextWidth("W")) Then 'ササミミ
Picture1.CurrentX = 0
Picture1.CurrentY = Picture1.CurrentY + Picture1.TextHeight("I")
End If
dl& = SetCaretPos(Picture1.CurrentX, Picture1.CurrentY)
dl& = ShowCaret(Picture1.hwnd)
End SubPrivate Sub Picture1_LostFocus()
Dim dl&
' dl& = DestroyCaret
End SubModule1.bas
=========================================================
Attribute VB_Name = "Module1"
Option ExplicitPublic Const WM_IME_SETCONTEXT = &H281
Public Declare Function DefWindowProc Lib "user32" Alias "DefWindowProcA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const GWL_WNDPROC = (-4)Dim hPrevProc As LongPublic Sub SubClass(hHwnd As Long)
hPrevProc = SetWindowLong(hHwnd, GWL_WNDPROC, AddressOf WindowProc)
End SubPublic Sub UnSubClass(hHwnd As Long)
SetWindowLong hHwnd, GWL_WNDPROC, hPrevProc
End SubPublic Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_IME_SETCONTEXT
WindowProc = DefWindowProc(hwnd, uMsg, wParam, lParam)
Exit Function
End Select
WindowProc = CallWindowProc(hPrevProc, hwnd, uMsg, wParam, lParam)
End Function
Project1.vbp
=======================================================================
Type=Exe
Form=.\fmText.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation
Module=Module1; Module1.bas
IconForm="Form1"
Startup="Form1"
Command32=""
Name="Project1"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=0
AutoIncrementVer=0
ServerSupportFiles=0
VersionCompanyName="-"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1[MS Transaction Server]
AutoRefresh=1
用我这种方法能实现吗?