Liberty BASIC Community Forum
« Combobox Text Fit... »

Welcome Guest. Please Login or Register.
Mar 29th, 2017, 04:17am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Combobox Text Fit...  (Read 336 times)
Coda
Junior Member
ImageImage


member is offline

Avatar

Dance first, ask questions later!! ;-)


PM

Gender: Male
Posts: 91
xx Combobox Text Fit...
« Thread started on: Jun 22nd, 2016, 2:24pm »

Hi, I seem to remember reading many years ago that there was a way to program a combobox in LB such that regardless of the physical size of the box on screen, that long items in the box will automatically fit and be seen in the drop down rather than cut off and truncated when the box is clicked. Is this possible through stylebits or API? I have done some searches for it but I didn't find anything. Does anyone know if this can be done and how? Any assistance would be greatly appreciated. smiley
User IP Logged

If it ain't competitive Latin or Ballroom, it ain't dancing!! ;-)

http://napierthompson.redbubble.com/
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2251
xx Re: Combobox Text Fit...
« Reply #1 on: Jun 23rd, 2016, 11:08am »

Trying to experiment with it in my spare time, haven't had much luck just yet. wink
User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
Coda
Junior Member
ImageImage


member is offline

Avatar

Dance first, ask questions later!! ;-)


PM

Gender: Male
Posts: 91
xx Re: Combobox Text Fit...
« Reply #2 on: Jun 24th, 2016, 12:33pm »

Thankyou Chris. You are a fountain of awesome, as always! smiley The annoying part is, I swear I read it either on this forum or on the LB encyclopaedia but I cannot find anything on it... maybe I imagined it...
« Last Edit: Jun 24th, 2016, 12:34pm by Coda » User IP Logged

If it ain't competitive Latin or Ballroom, it ain't dancing!! ;-)

http://napierthompson.redbubble.com/
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2730
xx Re: Combobox Text Fit...
« Reply #3 on: Jun 27th, 2016, 06:58am »

I couldn't find any documented option for comboboxes that automatically adjusts the width. But you can set a minimum width, like so:

Code:
    WindowWidth = 400
    WindowHeight = 500
    UpperLeftX = Int((DisplayWidth - WindowWidth)/2)
    UpperLeftY = Int((DisplayHeight - WindowHeight)/3)

    Dim month$(12)
    For i = 1 to 12
        Read m$
        month$(i) = m$
    Next i

    Nomainwin

'The Standard Combobox
    Statictext #main.st1, "Standard", 30, 14, 100, 24
    Combobox #main.cb1, month$(), selMonth, 30, 40, 100, 124


    Open "Stylebits and the Combobox" for Dialog as #main

    handle = hwnd(#main.cb1)
    msg = _CB_SETDROPPEDWIDTH
    wParam = 320   'width of drop down list in pixels
    lParam = 0

    CallDLL #user32, "SendMessageA", _
        handle as Ulong, _
        msg as Long, _
        wParam as Long, _
        lParam as Long, _
        ReturnedMessage as Long

    #main "Trapclose [endDemo]"
    #main "Font Times_New_Roman 12 Bold"
    #main.cb1 "Setfocus"

    Wait

[endDemo]
    Close #main
    End

    Sub selMonth handle$
        If handle$ = "#main.default" Then
            #main.cb1 "Contents? m1$"
            month$ = "The Textboxes Contents" + Chr$(13) + _
                "Combobox 1: ";m1$ + Chr$(13)
        Else
            #handle$ "Selectionindex? sel"
            month$ = month$(sel)
        End If
        Notice "You chose ";month$
    End Sub

    Data "January", "February", "March", "April", "May", "June", "July"
    Data "August", "September", "October", "Remember, remember the sixth of November", "December"
 

-Carl
« Last Edit: Jun 27th, 2016, 06:59am by CarlGundel » User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
Coda
Junior Member
ImageImage


member is offline

Avatar

Dance first, ask questions later!! ;-)


PM

Gender: Male
Posts: 91
xx Re: Combobox Text Fit...
« Reply #4 on: Jun 30th, 2016, 10:25pm »

Thankyou SOOOOOO much, Carl! smiley That is EXACTLY what I needed to do!!!! :-D You are an absolute genius! PERFECT!!!!
User IP Logged

If it ain't competitive Latin or Ballroom, it ain't dancing!! ;-)

http://napierthompson.redbubble.com/
CarlGundel
Administrator
ImageImageImageImageImage


member is offline

Avatar

author of Liberty BASIC


Homepage PM


Posts: 2730
xx Re: Combobox Text Fit...
« Reply #5 on: Jul 1st, 2016, 07:24am »

on Jun 30th, 2016, 10:25pm, Coda wrote:
Thankyou SOOOOOO much, Carl! smiley That is EXACTLY what I needed to do!!!! :-D You are an absolute genius! PERFECT!!!!


Thanks. I borrowed some of that code from the wiki, but I added the part that sends the CB_SETDROPPEDWIDTH message. smiley

-Carl
User IP Logged

author of Liberty BASIC
http://www.libertybasic.com
Coda
Junior Member
ImageImage


member is offline

Avatar

Dance first, ask questions later!! ;-)


PM

Gender: Male
Posts: 91
xx Re: Combobox Text Fit...
« Reply #6 on: Jul 1st, 2016, 08:24am »

smiley
User IP Logged

If it ain't competitive Latin or Ballroom, it ain't dancing!! ;-)

http://napierthompson.redbubble.com/
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls