Need Suggestions for New Freeware Control: Enhanced TextBox 
Author Message
 Need Suggestions for New Freeware Control: Enhanced TextBox

I was going to create a subclassed TextBox control that provided automatic
selection of text when the control received the focus, and publish that
control as freeware (with SOURCE CODE!) to anyone who asked for it.

Then the thought occurred to me: Why not ask you guys what you would like to
see added to the TextBox control? How about LineCount? ParagraphCount? A
FilterCharacters property so you can filter out garbage? Any other events
besides the standard set?

Any suggestions will be greatly appreciated. I will also be looking for
beta-testers.

This could be lots of fun. Perhaps the FreeWare approach will get us what we
want and need.

--
----------------
Michael A. Hofer
Software Engineer & Aspiring DM of Phenomenal Fame

Gil-galad was an elven king,
Of him the harpers sadly sing...



Wed, 31 Jan 2001 03:00:00 GMT  
 Need Suggestions for New Freeware Control: Enhanced TextBox

Mike, one tip for the "select text" perennial: distinguish between getting focus by keyboard and by mouseclick. I believe it's better to avoid forcing a selection in the latter case, as the user is better able to select or just position the insertion point in that case.

How can you distinguish the focus method the user used? I have seen an old FAQ item in the MS KB (but can no longer find it) which suggested using the GetKeyboardState API (I think) and examining the Tab key. This would need to be extended to look at shortcut keys as well, and would be a pain.

What I do in my apps is to use the following routine:

Public Sub SetTextSelection(ByRef pt_TextBox As TextBox, Optional ByVal pv_Content As Variant)

    On Error Resume Next

    With pt_TextBox
        If Not IsMissing(pv_Content) Then .Text = pv_Content
        .SelStart = 0
        .SelLength = Len(.Text)
        If .MultiLine Then .SelStart = .SelLength    ' Optional extra
    End With

End Sub

Then when I initialize Text1 I use
    SetTextSelection Text1, "Initial contents"
and in Text1_LostFocus() I use
    SetTextSelection Text1, Trim(Text1)

Note that this is done in LostFocus rather than GotFocus. This way the textbox carries its selection invisibly until focus is returned, and if the focus returns by mouseclick the user's mouse gesture will automatically reset the selection.

Best of luck with the upper-classed TextBox -- I'll take three copies please...

Bertie

Quote:

>I was going to create a subclassed TextBox control that provided automatic
>selection of text when the control received the focus, and publish that
>control as freeware (with SOURCE CODE!) to anyone who asked for it.

>Then the thought occurred to me: Why not ask you guys what you would like to
>see added to the TextBox control? How about LineCount? ParagraphCount? A
>FilterCharacters property so you can filter out garbage? Any other events
>besides the standard set?

>Any suggestions will be greatly appreciated. I will also be looking for
>beta-testers.

>This could be lots of fun. Perhaps the FreeWare approach will get us what we
>want and need.

>--
>----------------
>Michael A. Hofer
>Software Engineer & Aspiring DM of Phenomenal Fame

>Gil-galad was an elven king,
>Of him the harpers sadly sing...



Thu, 01 Feb 2001 03:00:00 GMT  
 Need Suggestions for New Freeware Control: Enhanced TextBox
Mike,

There are some things I am forever doing with text boxes.  Selecting text on
_GotFocus is only one of them.  If you're minded to create a generalised
control, I have a few suggestions:

1.    Have an expected type flag.  If the field is supposed to represent a
date (or a number etc.) validate that the contents of the .Text field are
mappable to the expected type.

2.    Have a field changed flag.  Invariably on my _GotFocus event I invoke
a subroutine which (amongst other things) copies the contents of the .Text
field to the .Tag field and then in _LostFocus if .Text = .Tag I exit on the
basis that nothing has changed.

3.    Have the user pressing the {Return} key operate just like the {tab}
key (I have some code for doing this if you're interested).

4.    Raise events on specific key presses within the text box.  Obvious
examples (for numeric or date fields) are the +/- keys.

Another thing I would really like is the option of having a right-button
click NOT bring up the standard edit./copy/paste/undo menu (or at least the
ability to specify that I don't want that to happen and to pick my own menu
instead).

Good luck on your project, and I'll happily test it if you like.

Peter

Quote:

>I was going to create a subclassed TextBox control that provided automatic
>selection of text when the control received the focus, and publish that
>control as freeware (with SOURCE CODE!) to anyone who asked for it.

>Then the thought occurred to me: Why not ask you guys what you would like
to
>see added to the TextBox control? How about LineCount? ParagraphCount? A
>FilterCharacters property so you can filter out garbage? Any other events
>besides the standard set?

>Any suggestions will be greatly appreciated. I will also be looking for
>beta-testers.

>This could be lots of fun. Perhaps the FreeWare approach will get us what
we
>want and need.

>--
>----------------
>Michael A. Hofer
>Software Engineer & Aspiring DM of Phenomenal Fame

>Gil-galad was an elven king,
>Of him the harpers sadly sing...



Thu, 01 Feb 2001 03:00:00 GMT  
 Need Suggestions for New Freeware Control: Enhanced TextBox
Mike and Bertie,

I'm glad to hear that the super-TextBox is coming out soon.

Bertie brings up a good issue and gives the solution as well, by the way,
I'd like to share my own solution with you here:-

Private m_MouseDown As Boolean

Private Sub m_TextBox_GotFocus()
    If Not m_MouseDown Then
        m_TextBox.SelStart = 0
        m_TextBox.SelLength = Len(m_TextBox.Text)
    End If
End Sub

Private Sub m_TextBox_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    m_MouseDown = True
End Sub

Private Sub m_TextBox_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    m_MouseDown = False
End Sub

I have once tried to make my own TextBox control base on the original
TextBox but finally gave up, because I was not able to map the Alignment
property which is important to me. After that, I developed a listener class
and container. Thus, to make all TextBoxes in a form AutoSelect, all you
need to do is:-

Dim lsnrMe As New CListeners

Private Sub Form_Load()
    lsnrMe.ListenAll Me
End Sub

Go a big further, It also allow you to do some key filtering controls like
accept unsigned inter only or accept decimal value only:-

Private Sub chkAutoSelect_Click()
    lsnrMe(Text1).AutoSelect = chkAutoSelect
End Sub

Private Sub chkNumberOnly_Click()
    lsnrMe(Text1).NumberOnly = chkNumberOnly
End Sub

Private Sub chkDecimal_Click()
    lsnrMe(Text1).DecimalAllowed = chkDecimal
End Sub

Private Sub chkNegative_Click()
    lsnrMe(Text1).NegativeAllowed = chkNegative
End Sub

I can post the listener class and it's container here if you want me to do

I'm glad to be a beta tester and please do give me a release copy.

Thanks and Regards,

Ken

    How can you distinguish the focus method the user used? I have seen an
old FAQ item in the MS KB (but can no longer find it) which suggested using
the GetKeyboardState API (I think) and examining the Tab key. This would
need to be extended to look at shortcut keys as well, and would be a pain.



Fri, 02 Feb 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. enhanced Rich Textbox control?

2. New OCX --> Enhanced Label ActiveX Control

3. Freeware Rich Textbox Control

4. Need Enhanced Message Box Control

5. Enhanced TreeView control needed

6. New Freeware ActiveX Control Released!

7. New Freeware ActiveX Control Released!

8. New Freeware Titlebar Gradient Control

9. dbListView - suggestions for a new ActiceX control.

10. Need Simple freeware/shareware image control!

11. I need a freeware gif control.

12. Enhanced Textbox to select and replace substrings

 

 
Powered by phpBB® Forum Software