LB Booster
Programming >> Liberty BASIC language >> limiting text in combo box
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1433087128

limiting text in combo box
Post by Alincon on May 31st, 2015, 3:45pm

How can I limit the number of characters typed into the the textbox
section of a combo box?

Some modification of this call for a regular textbox, maybe?

Code:
calldll #user32, "SendMessageA",htext as word,_EM_LIMITTEXT as word, lmt as word, 0 as long, r as long
 


r.m.
Re: limiting text in combo box
Post by Richard Russell on May 31st, 2015, 5:32pm

on May 31st, 2015, 3:45pm, Alincon wrote:
How can I limit the number of characters typed into the the textbox section of a combo box? Some modification of this call for a regular textbox, maybe?

Edit: Janet pointed out at the LB Forum that there is in fact an equivalent constant _CB_LIMITTEXT that you can use directly, which is simpler than the solution I posted earlier:

Code:
    array$(1) = "First item"
    array$(2) = "Second item"
    combobox #w.cb, array$(), [cbclick], 20, 20, 270, 40
    open "Combobox Limit Text" for window as #w
    #w "trapclose [quit]"
    hwndCB = hwnd(#w.cb)
    limit = 10
    calldll #user32, "SendMessageA", hwndCB as ulong, _
      _CB_LIMITTEXT as long, limit as long, 0 as long, ret as long
    wait

[quit]
    close #w
    end