Hiding Caret in textbox

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?
B4X:
[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]
 

agraham

Expert
Licensed User
Longtime 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.
 

Byak@

Active Member
Licensed User
it is not good :(
agraham can you see coredll.dll and say-real it or no?
 

RandomCoder

Well-Known Member
Licensed User
Longtime 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
 

Cableguy

Expert
Licensed User
Longtime 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"
 

RandomCoder

Well-Known Member
Licensed User
Longtime 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
 

Byak@

Active Member
Licensed User
no, label it's not variant...
 

Cableguy

Expert
Licensed User
Longtime 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
But NOT impossible!!!!
no, label it's not variant...
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...
 

Attachments

  • label.sbp
    1.4 KB · Views: 223
Last edited:

Byak@

Active Member
Licensed User
thanks Cableguy but using label its not variant in my program...
 
Top