borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Send and Retrieve sms using GPRS Modem)Next Topic (My AirBrush Class..) New Topic New Poll Post Reply
AndreaVB Forum : API : Unicode Textbox with API? Solved Topic
Poster Message
Vpa
Level: Sage


Registered: 14-03-2004
Posts: 66

icon Unicode Textbox with API?

I've made a translator form Dutch to Ekáná (own language), but in that language you have a G with an accent. I was used to translate it as g'. But becouse I need the normal accent ['] too, its much clearer as G with a [^] on top of it. Therefore I need a textbox with Unicode, I tried the textbox from MSform 2.0, but that didn't worked, it has a different layout as a normal winXP-textbox, nor the RTF textbox has

can somenone tell me how to get unicode characters in a normal textbox (with or without API)

____________________________
Shondoit fais G'ot < http://home.deds.nl/~7dfp >

23-02-2005 at 02:51 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
humberto
Level: VB Lord

Registered: 13-01-2005
Posts: 246
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
Vpa
Level: Sage


Registered: 14-03-2004
Posts: 66
icon Re: Unicode Textbox with API?

I'm sorry but the link doesn't work
Could you give me an example prigram? I don't understand how to combine it to my textbox. For example: 1 textbox with unichar &h11f. Thank you in advance

____________________________
Shondoit fais G'ot < http://home.deds.nl/~7dfp >

24-02-2005 at 06:22 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
humberto
Level: VB Lord

Registered: 13-01-2005
Posts: 246
icon Re: Unicode Textbox with API?

Ga hier naar toe


24-02-2005 at 07:21 AM
View Profile Send Email to User Show All Posts | Quote Reply
Vpa
Level: Sage


Registered: 14-03-2004
Posts: 66
icon Re: Unicode Textbox with API?

Well, I looked at it, but I'm not that good in japanese and how the (****) that is related to Unicode passing to a textbox, I don't know
I need to get an Unicode char into a textbox

____________________________
Shondoit fais G'ot < http://home.deds.nl/~7dfp >

24-02-2005 at 03:20 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
humberto
Level: VB Lord

Registered: 13-01-2005
Posts: 246
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
Vpa
Level: Sage


Registered: 14-03-2004
Posts: 66
icon Re: Unicode Textbox with API?

That won't work. I ay get the unicode string but if I paste it in a textbox or send as property, I get questionmarks for every unicode higher than 255

____________________________
Shondoit fais G'ot < http://home.deds.nl/~7dfp >

24-02-2005 at 07:53 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
dseaman
Level: Trainee

Registered: 04-07-2005
Posts: 1
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
thuongall
Level: Trainee

Registered: 24-07-2006
Posts: 1
icon 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
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : Unicode Textbox with API? Solved Topic
Previous Topic (Send and Retrieve sms using GPRS Modem)Next Topic (My AirBrush Class..) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder