Announcement

Collapse
No announcement yet.

Setting & retrieving a Textbox width

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting & retrieving a Textbox width

    I am trying to ascertain when the character maximum of a Textbox is reached.

    Code:
           Control Add TextBox, hdlg, %Id_WholeName, "", Col + Wdth + 2, Row, g_Textbox_Width, g_Textbox_Height
    
           Control Send hdlg, %Id_WholeName, %EN_MAXTEXT, 0, 64 'Len(db.WholeName)
    And in the Callback, I tried this but it never gets tripped:
    Code:
            '
            Case %WM_COMMAND  'This processes command messages
                Select Case CbCtl
                  Case %Id_Index To %Id_Comments
                     Select Case CbCtlMsg
                         Case %EN_MAXTEXT
                           m1$ = "No more room":mb
                      End Select
                End Select
    Is the Control Send right? Or do I need to use something other than the Default Style in the Add Textbox? Or both?
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

  • #2
    You can set the maximum amount of text to be entered by using %EM_SETLIMITTEXT - MSDN: EM_SETLIMITTEXT. Once that is sent to the textbox, it will take care of restricting input for you with a nice beep when it hits the limit.

    As you can see on that URL, before EM_SETLIMITTEXT is used, the limit is 32,767 characters.

    Edit: I have never attempted to detect when the limit is encountered myself, but that notification you have seems like it should work once you set the limit.
    Last edited by Adam J. Drake; 10 Sep 2008, 01:29 AM.
    Adam Drake
    PowerBASIC

    Comment


    • #3
      Thanks, Adam, Works fine. For others who may be interested, here's the sending code
      Code:
             Control Send hdlg, %Id_WholeName, %EM_SETLIMITTEXT, Len(db.WholeName), 0 'Len(db.WholeName)
      And in the CallBack
      Code:
              Case %WM_COMMAND  'This processes command messages
                  Select Case CbCtl
                    Case %Id_WholeName
                       Select Case CbCtlMsg
                           Case %EN_MAXTEXT
                             Beep '<<- Doesn't even peep
                           Control Send hdlg, %Id_WholeName, %EM_GETLIMITTEXT, 0, 0 To ctr
       
                             m1$ = "No more room"
                             m3$ = Using$("Len = #, " , ctr)
                             mb ' Msgbox macro gets hit
      No Beep though. Not even a peep.

      ===============================================
      "Peace is not won
      by those who fiercely guard their differences,
      but by those who with open minds and hearts
      seek out connections."
      Katherine Paterson
      ===============================================
      Last edited by Gösta H. Lovgren-2; 10 Sep 2008, 07:56 AM.
      It's a pretty day. I hope you enjoy it.

      Gösta

      JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
      LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

      Comment

      Working...
      X