 |
humberto Level: VB Lord
 Registered: 13-01-2005 Posts: 246
|
Re: Unicode Textbox with API?
The trick here is to use the UNICODE version of the function and pass
to this the actual pointer to the string by using StrPtr as suggested
Public Declare Function ImmGetCompositionString Lib "imm32.dll" _
Alias "ImmGetCompositionStringW" _
(ByVal himc As Long, ByVal dw As Long, _
ByVal lpv As Long, ByVal dw2 As Long) As Long
very good article to help understand VB strings can be found
at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnw3...
|
|
23-02-2005 at 09:54 PM |
|
|
humberto Level: VB Lord
 Registered: 13-01-2005 Posts: 246
|
Re: Unicode Textbox with API?
Ga hier naar toe
|
|
24-02-2005 at 07:21 AM |
|
|
humberto Level: VB Lord
 Registered: 13-01-2005 Posts: 246
|
Re: Unicode Textbox with API?
May this will help:
Option Explicit
Private Declare Function GetVersion Lib "kernel32" () As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
lpDest As Any, _
lpSource As Any, _
ByVal nCount As Long)
Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" ( _
ByVal cChar As Byte) As Integer
Private Declare Function VkKeyScanW Lib "user32" ( _
ByVal cChar As Integer) As Integer
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" ( _
ByVal wCode As Long, _
ByVal wMapType As Long) As Long
Private Declare Function MapVirtualKeyW Lib "user32" ( _
ByVal wCode As Long, _
ByVal wMapType As Long) As Long
Private Declare Function GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" ( _
ByVal lParam As Long, _
ByVal lpBuffer As String, _
ByVal nSize As Long) As Long
Private Declare Function GetKeyNameTextW Lib "user32" ( _
ByVal lParam As Long, _
ByVal lpBuffer As Long, _
ByVal nSize As Long) As Long
Public Function GetKeyboardString( _
ByVal sChar As String, _
Optional ByRef vKey As KeyCodeConstants, _
Optional ByRef iShift As ShiftConstants) As String
Dim lScanCode As Long
Dim b() As Byte
Dim sRet As String
Dim sBuf As String
Dim lSize As Long
Dim bNt As Boolean
Dim iKeyCode As Integer
' Determine if we have Unicode support or not:
bNt = ((GetVersion() And &H80000000) = 0)
' Get the keyboard scan code for the character:
If (bNt) Then
b = sChar
CopyMemory vKey, b(0), 2
iKeyCode = VkKeyScanW(vKey)
Else
b = StrConv(sChar, vbFromUnicode)
iKeyCode = VkKeyScan(b(0))
End If
' Split into shift and key portions:
iShift = (iKeyCode And &HFF00&) \ &H100&
vKey = iKeyCode And &HFF&
' Build the string for the return state:
sRet = _
IIf(iShift And vbAltMask, "Alt+", vbNullString) & _
IIf(iShift And vbCtrlMask, "Ctrl+", vbNullString) & _
IIf(iShift And vbShiftMask, "Shift+", vbNullString)
' Translate the virtual-key code into a scan code.
If (bNt) Then
lScanCode = MapVirtualKeyW(vKey, 0)
Else
lScanCode = MapVirtualKey(vKey, 0)
End If
' GetKeyNameText retrieves the name of a key (the scan code
' must be in bits 16-23):
lScanCode = lScanCode * &H10000
If (bNt) Then
ReDim b(0 To 512) As Byte
lSize = GetKeyNameTextW(lScanCode, VarPtr(b(0)), 256)
If (lSize > 0) Then
sBuf = b
sRet = sRet & Left$(sBuf, lSize)
End If
Else
sBuf = Space$(256)
lSize = GetKeyNameText(lScanCode, sBuf, 256)
sRet = sRet & Left$(sBuf, lSize)
End If
GetKeyboardString = sRet
End Function
|
|
|
24-02-2005 at 03:53 PM |
|
|
dseaman Level: Trainee
 Registered: 04-07-2005 Posts: 1
|
Re: Unicode Textbox with API?
Vb TextBox was created as ANSI only therefore you cannot make it accept Unicode even if you set Font to "Arial Unicode MS". Your options are a 3rd party Unicode aware TextBox, a RichEdit control, or use the MS Forms 2.0 object Library TextBox. Make sure you set a Font that contains the glyphs that you require since there is NO Font Fallback support in this library. Your best bet is Font "Arial Unicode MS". There are other limitations to Forms 2.0 - see Unicode Tutorial at my site www.cyberactivex.com.
|
|
04-07-2005 at 01:56 AM |
|
|
thuongall Level: Trainee
 Registered: 24-07-2006 Posts: 1
|
Re: Unicode Textbox with API?
I need the Unicode TextBox UserControl too (not TextBox of MS Forms 2.0). Any one help me, please!
|
|
24-07-2006 at 07:35 PM |
|
|
|
|
 |
 |