Hiding Caret in textbox

Discussion in 'Questions (Windows Mobile)' started by Byak@, Sep 4, 2008.

  1. Byak@

    Byak@ Active Member Licensed User

    How cai i hide blinking Caret in textbox?i'm find cod for VB.Net, but how do it in Basic4PPC?
    Code:
    [COLOR=#000080]Private[/COLOR] Declare [COLOR=#000080]Function[/COLOR] HideCaret Lib [COLOR=#0000ff]"user32" [/COLOR]([COLOR=#000080]ByVal[/COLOR] hwnd [COLOR=#000080]As[/COLOR] [COLOR=#000080]Long[/COLOR]) [COLOR=#000080]As[/COLOR] [COLOR=#000080]Long[/COLOR]
    [COLOR=
    #000080]Private[/COLOR] Declare [COLOR=#000080]Function[/COLOR] ShowCaret& Lib [COLOR=#0000ff]"user32" [/COLOR]([COLOR=#000080]ByVal[/COLOR] hwnd [COLOR=#000080]As[/COLOR] [COLOR=#000080]Long[/COLOR])

    [COLOR=
    #000080]Private[/COLOR] [COLOR=#000080]Sub[/COLOR] CheckCaret()
        [COLOR=
    #000080]If[/COLOR] Check1.Value = vbChecked [COLOR=#000080]Then[/COLOR]
            ShowCaret (Text1.hwnd)
        [COLOR=
    #000080]Else[/COLOR]
            HideCaret (Text1.hwnd)
        [COLOR=
    #000080]End[/COLOR] [COLOR=#000080]If[/COLOR]
    [COLOR=
    #000080]End[/COLOR] [COLOR=#000080]Sub[/COLOR]

    [COLOR=
    #000080]Private[/COLOR] [COLOR=#000080]Sub[/COLOR] Form_Load()
        Check1.Value = [COLOR=
    #800000]1[/COLOR]
    [COLOR=
    #000080]End[/COLOR] [COLOR=#000080]Sub[/COLOR]

    [COLOR=
    #000080]Private[/COLOR] [COLOR=#000080]Sub[/COLOR] Text1_Change()
        CheckCaret
    [COLOR=
    #000080]End[/COLOR] [COLOR=#000080]Sub[/COLOR]

    [COLOR=
    #000080]Private[/COLOR] [COLOR=#000080]Sub[/COLOR] Text1_GotFocus()
        CheckCaret
    [COLOR=
    #000080]End[/COLOR] [COLOR=#000080]Sub[/COLOR]
     
  2. agraham

    agraham Expert Licensed User

    To be pedantic (yet again) that code looks like it is for Visual Basic 6.0 as .NET does not expose a hWnd property for a textbox. The equivalent in .NET it is the Handle property of a Control. In any case that code will only work on the desktop as user32 is a desktop Windows dll.

    I think (I'm not sure) that those calls may be present in coredll.dll on a device but the bottom line is that you can't call them from B4ppc, you would need a library to do it for you.
     
  3. Byak@

    Byak@ Active Member Licensed User

    it is not good :(
    agraham can you see coredll.dll and say-real it or no?
     
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I don't know if this will work but you could try placing a label over the textbox which simply displays the text. Set the focus to the text box so that the user can still enter data but update the label with each key press or control it as required.
    It's more cumbersome than what you are really after but should produce the same effect.

    Regards,
    RandomCoder
     
  5. Cableguy

    Cableguy Expert Licensed User

    Still stretching on RANDOM's Idea, why not just the label, get the focus and while with focus, update the text with every key press...No need for the textbox at all...Then when focus leaves the label, it remains "still"
     
  6. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Using just a label makes it more difficult to detect the key press whereas using a textbox hidden behind the label would do this automatically ;)

    Regards,
    RandomCoder
     
  7. Byak@

    Byak@ Active Member Licensed User

    no, label it's not variant...
     
  8. Cableguy

    Cableguy Expert Licensed User

    But NOT impossible!!!!
    YES, it is doable...
    here's how....

    It uses the door lib to expose some props and events...

    Click on the label and a Orange border gets visible...write what you want...
    You can delete and even press enter to leave the control...
    the additional TextBox is only to allow the focus to leave the label...
     

    Attached Files:

    Last edited: Sep 5, 2008
  9. Byak@

    Byak@ Active Member Licensed User

    thanks Cableguy but using label its not variant in my program...
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice