Results 1 to 39 of 39

Thread: Unicode Textbox

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Unicode Textbox

    Here's my version of a Unicode & RTF textbox.

    It's about as full featured as you can get while using the RichTx32.ocx control.

    Full Unicode and RTF editing while in the IDE design mode. Just right-click and "Edit" to paste in your Unicode/RTF text.

    Every single event, property, and method is passed through (with the exception of the data bound properties).

    It's actually a bit like a mini-Unicode-word-processor while you're in the IDE design mode. Be sure to take a look at the Sel... properties. Usually, with the regular RTF box, those are only available at runtime, but with this control, they're all available at design time as well. Mess with them while in "Edit" mode of the control, and you can format your text while you're typing it.

    The only downside is that pasted text (while in "Edit" mode), must be RTF (or ascii). There can be Unicode embedded in the RTF, but you can't paste "raw" Unicode. So what does this mean? It means you can paste pretty much anything from WordPad (and Word), and it'll go straight in (Unicode and all). Because, in these circumstances, there'll be an RTF representation of the copy in the clipboard. However, Notepad can do Unicode but it doesn't do RTF. Therefore, if you try to copy-and-paste Unicode from the Notepad, it won't work. However, if you copy from Notepad, paste to WordPad, then copy the same text from WordPad, and then paste into this control, it'll work. That's because WordPad will give you an RTF representation of the Unicode.

    From WordPad, you can even paste pictures into it.

    Please let me know what you think of it and whether you see any problem/enhancements from which it may benefit. Also, if anyone can figure out the pure-Unicode pasting, I'd be delighted to listen.

    Enjoy,
    UnicodeTextbox.zip


    UPDATED: It'll now accept pasted (from clipboard) Unicode without the equivalent RTF being in the clipboard (such as what you'd get from copying Unicode out of Notepad). I also smartened up the Sel... properties so that they're always dynamically updated as you're typing without any typing lag. All of this is true regardless of whether you're in the IDE or during runtime.

    UPDATE2: Ok, I added some shortcut keys to use while in "Edit" mode (design time or runtime). Things such as ctrl-b (toggle bold), ctrl-i (toggle italic), etc. It was just trivial to do compared to where I already was with this thing. I'm hopefully DONE with it for a while now. There's also a new property (TabStaysInside). This specifies whether a Tab inserts vbTab into control's text or moves to next control on the form. See the "About" property for summary of shortcut keys.

    UPDATE3: Added a SelTextUnicode (both Get and Let) property. This allows you to select some text and then, during runtime, get that text in a unicode form. Or, you can insert unicode text at the carat (selection point). This is all runtime only because the control can just be directly edited at design time (and also, the properties window isn't Unicode compatible).
    Last edited by Elroy; Oct 30th, 2014 at 11:43 AM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Unicode Textbox

    Think my post to your Unicode > RTB thread may have solved that last issue for you?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I use my old code here, on your user control to add TAB and shift TAB to add paragraph indentation and auto line indentation when we press enter...but I lost unicode because I use text....property...

    Code:
    Private Sub UnicodeRtfTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
    
    Select Case KeyCode
    Case vbKeyReturn
    KeyCode = 0
    If UnicodeRtfTextBox1.SelLength > 0 Then UnicodeRtfTextBox1.SelText = ""
    Dim ii As Long, JJ As Long
    ii = UnicodeRtfTextBox1.SelStart
    JJ = InStrRev(Left$(UnicodeRtfTextBox1.Text, UnicodeRtfTextBox1.SelStart), vbLf)
    
    If JJ >= 0 Then JJ = JJ + 1
    If JJ > 0 Then
    
        ii = Len(Mid$(UnicodeRtfTextBox1.Text, JJ))
        ii = ii - Len(LTrim$(Mid$(UnicodeRtfTextBox1.Text, JJ)))
        If ii > 0 Then
        JJ = ii Mod 6
        ii = (ii \ 6)
        If ii = 0 Then
            ii = JJ
        Else
            ii = ii * 6
        End If
        JJ = UnicodeRtfTextBox1.SelStart + ii + 2
        UnicodeRtfTextBox1.Text = Mid$(UnicodeRtfTextBox1.Text, 1, UnicodeRtfTextBox1.SelStart) + vbCrLf + Space$(ii) + LTrim$(Mid$(UnicodeRtfTextBox1.Text, UnicodeRtfTextBox1.SelStart + 1))
         UnicodeRtfTextBox1.SelStart = JJ
         
         Else
         JJ = UnicodeRtfTextBox1.SelStart
    
       UnicodeRtfTextBox1.Text = Mid$(UnicodeRtfTextBox1.Text, 1, UnicodeRtfTextBox1.SelStart) + vbCrLf + Mid$(UnicodeRtfTextBox1.Text, UnicodeRtfTextBox1.SelStart + 1)
       
       UnicodeRtfTextBox1.SelStart = JJ + 2
    
    
         End If
    
    
    
         Else
         JJ = UnicodeRtfTextBox1.SelStart
    
       UnicodeRtfTextBox1.Text = Mid$(UnicodeRtfTextBox1.Text, 1, UnicodeRtfTextBox1.SelStart) + vbCrLf + Mid$(UnicodeRtfTextBox1.Text, UnicodeRtfTextBox1.SelStart + 1)
       
       UnicodeRtfTextBox1.SelStart = JJ + 2
    
    
    End If
    
    
    Case vbKeyTab
    
    JJ = UnicodeRtfTextBox1.SelStart
    Where = JJ
    ii = InStrRev(vbCrLf + Mid$(UnicodeRtfTextBox1.Text, 1, JJ), vbCrLf) - 1
    
    
    
    If UnicodeRtfTextBox1.SelLength > 0 Then
    
    JJ = UnicodeRtfTextBox1.SelLength + JJ - ii
    UnicodeRtfTextBox1.SelStart = ii
    UnicodeRtfTextBox1.SelLength = JJ
    JJ = Where
    Else
    UnicodeRtfTextBox1.SelStart = ii
    End If
    
    
    If UnicodeRtfTextBox1.SelText <> "" Then
        a$ = vbCrLf + UnicodeRtfTextBox1.SelText + "*"
        If Shift <> 0 Then  ' âãÜëå
            a$ = Replace(a$, vbCrLf + Space$(6), vbCrLf)
            UnicodeRtfTextBox1.SelText = Mid$(a$, 3, Len(a$) - 3)
            UnicodeRtfTextBox1.SelStart = ii
            UnicodeRtfTextBox1.SelLength = Len(a$) - 3
        Else
            a$ = Replace(a$, vbCrLf, vbCrLf + Space$(6))
            UnicodeRtfTextBox1.SelText = Mid$(a$, 3, Len(a$) - 3)
            UnicodeRtfTextBox1.SelStart = Where + 6
            UnicodeRtfTextBox1.SelLength = Len(a$) - 3 - (Where + 6 - ii)
        End If
      
    Else
    If Shift <> 0 Then
        If Mid$(UnicodeRtfTextBox1.Text, JJ + 1, 6) = Space$(6) Then
                UnicodeRtfTextBox1.Text = Left$(UnicodeRtfTextBox1.Text, JJ) + Mid$(UnicodeRtfTextBox1.Text, JJ + 7)
                UnicodeRtfTextBox1.SelStart = ii
        End If
        Else
            UnicodeRtfTextBox1.SelStart = JJ
            UnicodeRtfTextBox1.SelText = Space(6)
            UnicodeRtfTextBox1.SelStart = Where + 6
        End If
    End If
    
    KeyCode = 0
    
    End Select
    End Sub

  4. #4

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Ahhhh, yeah georgekar, I did think about some of that. I thought about catching things like Ctrl-B and Ctrl-I and others for text formatting, but my intent really wasn't to make a mini-word-processor. I just wanted a TextBox (just like the standard VB6 TextBox) that you could put Unicode into at design time. There are quite a few relatively full featured Unicode text editors around using the RTB. I was hoping to keep this one simple, but it really didn't turn out terribly simple. I've got Unicode option buttons and checkboxes that are VERY simple. I was hoping the same for this one.

    Actually, now that you've reminded me, I may put some Ctrl-B, Ctrl-I, Ctrl-U, as well as looking at your Tabbing code, and put those in.

    Thanks for reminding me,
    Elroy

    EDIT: That actually reminds me of a good question for the forum. I'll post it in just a second.

  5. #5
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    Also I notice that give only one undo...
    Have see my Nice textboxes???
    They are classes on a same glist4 control. This control can be use as menu with unlimited items (2bilions) and we can make some "band" of them as radio buttons. some other as textboxes for input, and some other for just chekk boxes, also we can replace any item with a line, and we have items that cursor cannot show. I use this in a file selector for setup.

  6. #6

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    George, I didn't do any Undo's at all. That's just what's built into the RTB control. Again, I wasn't shooting for a WordPad replacement, just a nice Unicode textbox that works bulletproof at design time.

  7. #7
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I write from a tablet now. So maybe I am wrong, but except the displaying of typed text how we can insert a string to this box?. Using text property is converted to ansi. Maybe you have to change that. As for the undo, is not so big problem.

  8. #8

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Nooo, in MY implementation, if you read from the Text property, you'll get Unicode, either Get or Let. Now that property doesn't show in design mode in the Properties Window because the Properties Window can't handle Unicode. However, that's why you can "Edit" the control directly in design mode. But at runtime, the Text property is full Unicode (UTF-16).

    EDIT: Correction. There are actually 3 texts properties: Text, TextRTF, & TextUnicode. You're actually right, the Text property returns non-Unicode text. However, if you use the TextUnicode property, you can Get and Let true Unicode at runtime through straight-up assignments.

  9. #9
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I put all text to textunicode...but the problem exist because Seltext is not a unicode one. As I see only SelText and SelRTF you have in your user control Elroy.

  10. #10

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Hmmm, that's an excellent point, george. At this point, it'd be fairly easy for me to add a SelTextUnicode property so I may do that. No promises (because I don't make promises on free work), but maybe in the next day or two. It feels like about 30 minutes of work, but my motivation for things is always a crap shoot.

    Again, thanks for pointing out a weakness that's probably needed fairly often.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  11. #11

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    To George,

    All fixed, see UPDATE3.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  12. #12
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Unicode Textbox

    There is this major bug with your unicode control, any unicode control hosted in VB6 compiled application:

    The users just cannot enter unicode input with the keyboard at all :-))

    The thing is that VB6 runtime uses PeekMessageA/DispatchMessageA in it's internal message pump. This leads to ANSI translation for wParam of WM_CHAR message, so even unicode windows (created with CreateWindowExW) receive "?" instead of unicode input. And this is a problem that all commercial ActiveX controls hosted on VB6 forms do have too: http://forum.codejock.com/forum_posts.asp?TID=17177

    What I did in a recent project of mine as a last resort was API hooking -- just hooked DispatchMessageA import of MSVBVM60 and replaced it with my custom function that calls DispatchMessageW. I was less successful with PeekMessageA for one reason or another but a WH_GETMESSAGE *unicode* hook was good enough to intercept WM_CHAR's wParam before it turning to "?'. No subclassing each and every unicode control was involved in this massive hack.

    cheers,
    </wqw>

  13. #13

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    wqweto,

    If you don't mind, please say more about what you mean. I have an English/American keyboard, so it doesn't have Unicode characters on it. But when I'm editing the control (design time / runtime / or compiled), using the ALT key and keypad to enter Unicode works just fine.

    Are you talking about keyboards with keys other than mine?

    EDIT: Wow, wqweto. I responded almost immediately to your post. If you're going to make a statement like...
    There is this major bug with your unicode control
    ... it'd sure be nice if you'd stick around long enough to make it clear what it is.
    Last edited by Elroy; Nov 1st, 2014 at 11:21 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  14. #14
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Unicode Textbox

    wqweto - There is this major bug with your unicode control
    Perhaps I can shed some light here.
    Typing in a TextBox via IME is an essential feature.
    Sure, you can type Unicode using the Alt Key with the Unicode value but that is not practical.
    What we are referring here, for example, is a mapped keyboard where you press "a" in Kazakh IME and get "ф".
    This problem exists on a number of controls, and in this case the problem is with the underlying Vb6 RichTextBox.

    You do not need a foreign keyboard to test this.
    Install the Kazakh IME and type "asdf 890" in a TextBox.
    If Unicode IME is corectly implemented you should get "фыва үұқ".
    If not, you just get "???? ???".
    Notepad, Wordpad, and Office WinWord all OK work with IME.

    You can also use the OnScreenKeyboard.
    You still install and activate an IME, but now you can click the keys from the OnScreenKeyboard.
    Your OnScreenKeyboard will change to match the IME so that you know what you are typing.
    See the last line of these controls where we try to type "asdf 890" on several controls.
    http://cyberactivex.com/UnicodeTutor...llback/Linking
    http://cyberactivex.com/UnicodeTutor...ScreenKeyboard

    This is a partial list of controls that don't properly handle IME (mapped keyboard):
    1. Timosoft Edit Controls http://www.timosoft-software.de/wp-c...80-Release.exe
    2. Hexagora Unicode Controls http://www.hexagora.com/en_dw_unictrl.asp
    3. VbForums CommonControls Replacement http://www.vbforums.com/showthread.p...mmon-controls)
    4. Microsoft InkEdit (actually a RichEdit control)
    5. Microsoft Forms 2.0 Object Library (TextBox)
    6. Vb6 RichTextBox.

    wqweto - And this is a problem that all commercial ActiveX controls hosted on VB6 forms do have too
    Definitely not True!

    Some Vb6 Unicode controls DO handle this correctly such as:
    1. UniTextBox and UniRichEdit100_EDA1811C from http://cyberactivex.com/
    2. Woodbury Associates UniToolBox UniText control from http://www.iconico.com/download.aspx?app=UniToolbox

  15. #15
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Unicode Textbox

    Quote Originally Posted by DrUnicode View Post
    Definitely not True!
    You are definitely right :-))

    UniTextBox fails unicode input and symbols get converted to ? by the ANSI message pump.

    On the other hand UniText control seems to handle my tests ok. Probably they "record" unicode WM_CHARs with a hook and "restore" wParam in controls wndproc.

    cheers,
    </wqw>

  16. #16
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    Can you test my nice textbox???
    Attached Files Attached Files

  17. #17
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I found the solution
    First I found a simple program by someone Cris,he did that: utilize a timer to show the change of the language...So i found that using the LOCALE_ILANGUAGE we get the localeId which is useful fotr StrConv.
    all the magic is here
    debug.print AscW(StrConv(ChrW$(ASCII Mod 256), 64, 1032))
    З = P = Π in the position of Keyboard. Vb6 read the Ascii value...so we need to make it with a ChrW$(ascii) as unicode but not in the right locale, so we do the conversion.
    Do not remove the added AscW() because Strconv give 4 bytes...
    you can use that also: GetKeY = Left$(StrConv(ChrW$(ASCII Mod 256), 64, CLng(Val("&h" + Left$(Buffer, Ret - 1)))), 1)

    If you change ChrW$(Ascii...to simple...Chr$() you loose the magic...


    Code:
    Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoW" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As Long, ByVal cchData As Long) As Long
    Private Declare Function GetKeyboardLayout& Lib "USER32" (ByVal dwLayout&) 
    Private Const DWL_ANYTHREAD& = 0
    Const LOCALE_ILANGUAGE = 1
    
    
     Function GetKeY(ASCII As Integer) As String
        Dim Buffer As String, Ret As String
        Buffer = String$(514, 0)
        Dim r&, K&
          r = GetKeyboardLayout(DWL_ANYTHREAD) And &HFFFF
          r = Val("&H" & Right(Hex(r), 4))
        Ret = GetLocaleInfo(r, LOCALE_ILANGUAGE, StrPtr(Buffer), Len(Buffer))
        If Ret > 0 Then
            GetKeY = ChrW$(AscW(StrConv(ChrW$(ASCII Mod 256), 64, CLng(Val("&h" + Left$(Buffer, Ret - 1))))))
        Else
            GetKeY = ChrW$(AscW(StrConv(ChrW$(ASCII Mod 256), 64, 1033)))
        End If
    End Function
    Attached Files Attached Files
    Last edited by georgekar; Nov 2nd, 2014 at 05:02 PM. Reason: Example Nice Textboxes

  18. #18
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    In glist control we have to change the event to maintain the undo system (unlimited undo-redo)
    I insert a new variable beacuse I would like one snap from the GetKey. Two maybe have different result...
    Code:
    '....start of the keypress event 
    Dim kk$
    
                kk$ = GetKeY(KeyAscii)    ' here is what I forged
                 RaiseEvent removeone(kk$)
                If SelStart = 0 Then mSelstart = 1
               
                SelStartEventAlways = SelStart + 1
       
                    List(SELECTEDITEM - 1) = Left$(List(SELECTEDITEM - 1), SelStart - 2) + kk$ + Mid$(List(SELECTEDITEM - 1), SelStart - 1)
                
             
                End If

  19. #19
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: Unicode Textbox

    I don't understand what you are talking about. At least I can typing Chinese and Japanese normally using either IME or Baidu input in Elroy's UnicodeTextbox or Krool's textbox.

    Edited: For Kazakh, Krool's textbox seems to fail for digit keyboard. asdf 890 show "фыва ???" instead of "фыва үұқ"
    Last edited by Jonney; Nov 4th, 2014 at 04:56 AM.

  20. #20
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    In my computer which has a Greek system language, there is no problem to input Greek or english letters through the keyboard in a vb application. But when I put Russian language for keyboard, and check it with Osk (on screen keyboard) I understand what DrUnicode said. The keyboard event give ascii, from the current keyboard language. So how this ascii go to be unicode? Vb do that using the system locale, or thread locale, that is the same. So you have no problem if you use some kind of advance input system, if vb knows that and the conversion before. But for all like me, that use no special IME, there is a problem.
    For RTB with Russian keyboard I saw no problem, in Xp windows, but a textbox has problem..

  21. #21
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I found the problem and I found the solution in the net...and I adopted it for nice text boxes...

    Code:
    Private Declare Function PeekMessageW Lib "user32" (lpMsg As Msg, ByVal hwnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
    Const WM_KEYFIRST = &H100
     Const WM_KEYLAST = &H108
     Private Type POINTAPI
        X As Long
        Y As Long
    End Type
     Private Type Msg
        hwnd As Long
        Message As Long
        wParam As Long
        lParam As Long
        time As Long
        pt As POINTAPI
    End Type
    Dim UKEY$
    Public Function GetLastKeyPressed() As Long
    Dim Message As Msg
        If PeekMessageW(Message, 0, WM_KEYFIRST, WM_KEYLAST, 0) Then
            GetLastKeyPressed = Message.wParam
        Else
            GetLastKeyPressed = -1
        End If
        Exit Function
    End Function
    We get the GetLastKeyPressed in keydown event..
    we can store it in a string and then we can use it in the keypress event..
    I will post in a new thread with final nice textboxes...

  22. #22

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Wow, I never did even get my head around what the problem was. However, since I'm one of those unilingual Yankees (actually more of a Texan/Tennessean), I don't have a keyboard to test it. However, my software was recently installed in Columbia, with another going in at Mexico City, and another in Puerto Rico, I'm bracing myself for translation work. I could probably get away with ANSI and codepages, but I'd rather just go straight to Unicode.

    I saw Jonney's post #19, and figured that I'm good to go, but maybe not.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  23. #23
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    You have a Keyboard...(just load Kazakhstan language for keyboard)

  24. #24

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Щлб ьшту ыууьы ещ цщкл зукауседню Erm ... Ok, mine seems to work perfectly. (My Unicode TextBox, that is.)

    Thanks
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  25. #25
    Fanatic Member DrUnicode's Avatar
    Join Date
    Mar 2008
    Location
    Natal, Brazil
    Posts
    631

    Re: Unicode Textbox

    Ok, mine seems to work perfectly. (My Unicode TextBox, that is.)
    Kazakhistan Russian IME works, it is Kazakhistan Kazakh IME that does not.
    Testing here all I get is "???"

  26. #26
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I found why...қ Қ is in 0 but this is no problem...The problem is that this character has no ANSI equivalent. So we can only have the unicode keypress and only in the keydown event...If this is -1 then we didn't store it..
    Here I pass the chars with keystrokes..

    Name:  thebest.jpg
Views: 4034
Size:  36.1 KB

  27. #27

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Ahhhh, ok. Same here. Quite interesting. It's definitely broken.

    And say George, I'm not sure why all of the work shouldn't be done in the KeyPress event. It's certainly easy enough to zero out the KeyAscii variable, and then use PeekMessageW to get the Unicode keystroke. However, without some testing, I'm not totally clear on what to do with the return from PeekMessageW. If you're using a RTB as I am, it'll probably take more playing around with API calls, or possibly doing a lot of massaging of the text.

    The SelStart and SelLength would have to be honored. And it couldn't emulate keystrokes because that'd just send it right back to the KeyPress event.

    The only thing I can think of is to grab the Unicode text from the RTB control, examine SelStart and SelLenth, and then either insert or replace the text with the pressed character.

    What a mess.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  28. #28
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    I am not using any other control..but a listbox (a glist) that I have wrote, and I wrap a class TextViewer and some other classes...All the user controls are the same glist. (a listbox, as an empty user control with three shapes to construct a scroll bar).
    Also the "green" headlines move the control.
    I put it in M2000 interpreter (where I wrap another code over the TextViewer and we can indent multilnes to left or right..)

    I use keypress in listbox, as the bottom level. Keydown process keystrokes for scroll bar. When I make an extended Scrollio I make new control, a Large Bar, a flat bar for really big lists and for pictures. Here I merge an old glist with large bar, and I adopt an other style of programming, to make classes to subclass the usercontrol. So I move code for a particular job to the class that needed to have it. Now glist has only the basics. You can use it as a listbox and as a menu (with thousand of radio menu items..titles, items to place text and values, items as check boxes...and for commands.)

    Code:
    Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim I&
    If Shift <> 0 And KeyCode = 0 Then Exit Sub
    RaiseEvent KeyDown(KeyCode, Shift)
    If (KeyCode = 0) Or Not (Enabled Or State) Then Exit Sub
    If SELECTEDITEM < 0 Then
    SELECTEDITEM = topitem + 1: ShowMe2
    If Not EditFlag Then: KeyCode = 0
    End If
    LargeBar1KeyDown KeyCode, Shift
    If EnabledBar Then
    Select Case KeyCode
    Case vbKeyLeft, vbKeyUp
    If Spinner Then
    If Shift Then
    Value = Value - 1
    Else
    Value = Value - mSmallChange
    End If
    Else
    Value = Value - mSmallChange
    End If
    Case vbKeyPageUp
    Value = Value - largechange
    Case vbKeyRight, vbKeyDown
    If Spinner Then
    If Shift Then
    Value = Value + 1
    Else
    Value = Value + mSmallChange
    End If
    Else
    If Value + largechange + 1 <= Max Then
    Value = Value + mSmallChange
    End If
    End If
    Case vbKeyPageDown
    Value = Value + largechange
    End Select
    End If
    I = GetLastKeyPressed
     If I <> -1 Then UKEY$ = ChrW(I) Else UKEY$ = ""
    End Sub
    So I have here the latest version of glist4.. (an example with a form and a user control only...no .bas files or dependencies)

    and the LargeBar (in this example the same control has two presences, on as vertical and one as horizontal. Has auto orientation, means that without changing code can work in two orientations).

    ln glist Listbox I use only vertical bar -auto hidden- and float above items, but we can use an external largebar to scroll left or right. Also List box can write left or center justified text, with basic editing, without block mark, copy and drag. These functions are gained from TextViewer class, using events.from glist4. You can find it in Nice textboxes..- and if you wish change the list box with that...is the newest one.
    Attached Files Attached Files

  29. #29
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    glist4 is complicated...but we can get as much as we can from that.
    Here is an example that a small code feed unicode file names (I found that code...isn't mydir class), to a glist and a second one use the list of the first and read it when need to refresh. So this example primary show how to use glist as a listbox, a second one as an advance listbox, and there is a secondary "modification", we change a const to "Extreme" and we see what happen...
    Attached Files Attached Files

  30. #30
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    After DrUinicode write about the dead keys (that keys for marks on the letters)...I do a test to find what happen..because with greek letters I haven't see any fault. But after I insert an additional keyboard. a french one, I found that I got an m and not the dead key (that comes with the next key), so I look and I found that this key the 94 in unicode is the reversed key, so this is the dead key...
    I have to do only an addition "And I <> 94 " and voilà.

    Name:  absolutefree.jpg
Views: 3597
Size:  43.2 KB


    So change in the Keydown event as indicate here
    I = GetLastKeyPressed
    If I <> -1 And I <> 94 Then UKEY$ = ChrW(I) Else UKEY$ = ""

  31. #31
    New Member
    Join Date
    May 2021
    Posts
    5

    Re: Unicode Textbox

    Hello,

    I'm just testing your control and found I can't change neither font type nor font size. Is there any limit or am I not understand how to change it? I set both SelFontName and SelFontSize in dessign time and in run time with no success.

    Thank you.

  32. #32

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Hi dbimeno,

    Sorry, but I haven't looked at this thing in quite a while. It is used in places in my primary application, but even those are places I haven't tampered with in years. Personally, if I were doing it over again, I'd take a look at Krool's controls and use those instead. They're found here. And, without much work, you can take his controls and strip out the specific control (or control subset) you want, as I've done that several times (and also discussed doing that in various threads here).

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  33. #33
    New Member
    Join Date
    May 2021
    Posts
    5

    Re: Unicode Textbox

    Thanks, Elroy.

    DVD


    Quote Originally Posted by Elroy View Post
    Hi dbimeno,

    Sorry, but I haven't looked at this thing in quite a while. It is used in places in my primary application, but even those are places I haven't tampered with in years. Personally, if I were doing it over again, I'd take a look at Krool's controls and use those instead. They're found here. And, without much work, you can take his controls and strip out the specific control (or control subset) you want, as I've done that several times (and also discussed doing that in various threads here).

    Good Luck,
    Elroy

  34. #34
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Unicode Textbox

    Quote Originally Posted by Elroy View Post
    Hi dbimeno,

    And, without much work, you can take his controls and strip out the specific control (or control subset) you want, as I've done that several times (and also discussed doing that in various threads here).
    I have managed that with Krool's Slider and Tree controls but failed dismally with his unicode TextBoxW. Has any one succeeded and managed to create an OCX from Krool's text box? I'd love to have a copy if anyone has one available to give to me?

    I really do wish Krool would separate out his controls and allow us to choose individual controls to add to our projects. It would really benefit the VB6 community to have each control installable and selectable as required, minimal changes to our code.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  35. #35
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    You don't have to use these in an ocx.
    Here is a program I made with selected controls.

    Its very stable in the final exe. Also if you are a fast saver (means SAVE always your work, before a test for a new code entry), there are a few moments which get crashes.
    Attached Images Attached Images  

  36. #36
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Unicode Textbox

    There is also a nice tooltip. Here is a form for a password. I use the same form for Message Box, for Input Box, for Password Input. This is the messagebox.frm. For curiosity just look the code. (sorry some times i didn't use indentation)

    Name:  unique.jpg
Views: 1177
Size:  25.4 KB
    Attached Files Attached Files

  37. #37

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Unicode Textbox

    Interestingly, without seeing this activity, I've recently PMd Krool and asked him if he'd mind me stripping out his individual controls, and posting them in the CodeBank, and he said he didn't mind.

    For my own uses, I've personally stripped out the TextBoxW and several other controls. Also, just as an FYI, when I do it, I also strip out all of his custom property pages (because they're often linked to his other custom controls, making the "strip out" more difficult). When doing this, to set any initial Unicode, we must do it during runtime, but I don't mind that.

    But, if I find some time over the next few days, I'll start a new CodeBank thread and start posting Krool's individual controls in a way that they can be easily added to our own project, on a onesie-twosie bases rather than the whole package.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  38. #38
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Unicode Textbox

    Quote Originally Posted by Elroy View Post
    Interestingly, without seeing this activity, I've recently PMd Krool and asked him if he'd mind me stripping out his individual controls, and posting them in the CodeBank, and he said he didn't mind...
    But, if I find some time over the next few days, I'll start a new CodeBank thread and start posting Krool's individual controls in a way that they can be easily added to our own project, on a onesie-twosie bases rather than the whole package.
    Thankyou for that kind offer Elroy, you are one of the best. When it comes to code I always think, leaner the better - as if you pull in the whole monolith there is a bug just waiting to get you... I feel safer with just the one bit of functionality that I specifically need.

    In addition I think that Krool's approach is a little scary for most ordinary VB6 programmers. You go into the shop looking for a hammer and the hire shop tries to rent you a tractor...
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

  39. #39
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,235

    Re: Unicode Textbox

    Quote Originally Posted by georgekar View Post
    There is also a nice tooltip. Here is a form for a password. I use the same form for Message Box, for Input Box, for Password Input. This is the messagebox.frm. For curiosity just look the code. (sorry some times i didn't use indentation)
    George, I will look at this too, thankyou.
    https://github.com/yereverluvinunclebert

    Skillset: VMS,DOS,Windows Sysadmin from 1985, fault-tolerance, VaxCluster, Alpha,Sparc. DCL,QB,VBDOS- VB6,.NET, PHP,NODE.JS, Graphic Design, Project Manager, CMS, Quad Electronics. classic cars & m'bikes. Artist in water & oils. Historian.

    By the power invested in me, all the threads I start are battle free zones - no arguing about the benefits of VB6 over .NET here please. Happiness must reign.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width