Liberty BASIC Community Forum
« ComboBox Question »

Welcome Guest. Please Login or Register.
Sep 20th, 2017, 09:50am


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


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: ComboBox Question  (Read 172 times)
xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 24
xx ComboBox Question
« Thread started on: Sep 14th, 2017, 11:00am »

I have three ComboBoxes
ComboBox 1 contains "Folder" & "File"

Clicking Folder
Hides Green-colored Combobox3
Shows Yellow-colored ComboBox2
Clicking ComboBox2 displays the folder names on yellow background

Clicking File
Hides Yellow-colored Combobox2
Shows Greem-colored ComboBox3 containg file names
Clicking ComboBox3 displays the file names on green background

Is there a way to click ComboBox 1 and select Folder or File and simulate a click
on the corresponding ComboBox 2 or 3, thus eliminating a manual mouse click?

ComboBoxes 2 & 3 occupy the same screen area
« Last Edit: Sep 14th, 2017, 11:03am by xtal » User IP Logged

Rod
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Graphics = goosebumps!


PM

Gender: Male
Posts: 5526
xx Re: ComboBox Question
« Reply #1 on: Sep 14th, 2017, 1:31pm »

demo code that runs will get you the best help.
User IP Logged

Brandon Parker
Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1115
xx Re: ComboBox Question
« Reply #2 on: Sep 15th, 2017, 8:24pm »

Here is the example exactly as you requested. You can see that clicking on the top ComboBox Hides/ Shows the bottom ComboBoxes as you mentioned along with activating the event handler for the bottom ComboBox that is being Shown. Clicking on the bottom ComboBox and changing the selection shows that the same code is activated.

There is most likely a better and more elegant solution for what you are trying to achieve; not to say anything is bad, but just a little more about what you are trying to achieve along with some at least "half-working" code helps people provide you with better examples.

Let us know if this works for you or if you are trying to achieve something completely different.

Feel free to adapt this code for your needs.....

Code:
NoMainWin

Dim cboArray1$(1)

cboArray1$(0) = "File"
cboArray1$(1) = "Folder"

Dim cboArray2$(1)
cboArray2$(0) = "Folder Name 1"
cboArray2$(1) = "Folder Name 2"

Dim cboArray3$(1)
cboArray3$(0) = "File Name 1"
cboArray3$(1) = "File Name 2"

ComboBox #Test.cboFileFolder, cboArray1$(), comboClick, 10, 10, 120, 200
ComboboxColor$ = "Yellow"
ComboBox #Test.cboYellow, cboArray2$(), comboClick, 10, 40, 120, 200
ComboboxColor$ = "DarkGreen"
ComboBox #Test.cboGreen, cboArray3$(), comboClick, 10, 40, 120, 200
Open "Combobox Demo" For Window As #Test
#Test "TrapClose Quit"
#Test.cboFileFolder "SelectIndex 1"
#Test.cboYellow "SelectIndex 1"
#Test.cboGreen "SelectIndex 1"
#Test.cboYellow "Hide"
Wait

Sub Quit handle$
    Close #handle$
    End
End Sub

Sub comboClick handle$
    #handle$ "Selection? selection$"
    Select Case handle$
        Case "#Test.cboFileFolder"
            If selection$ = "File" Then
                #Test.cboYellow "Hide"
                #Test.cboGreen "Show"
                Call comboClick "#Test.cboGreen"
            Else
                #Test.cboGreen "Hide"
                #Test.cboYellow "Show"
                Call comboClick "#Test.cboYellow"
            End If
        Case "#Test.cboYellow"
            Notice "You clicked cboYellow!"
        Case "#Test.cboGreen"
            Notice "You clicked cboGreen!"
    End Select
End Sub 



{:0)

Brandon Parker
« Last Edit: Sep 15th, 2017, 8:38pm by Brandon Parker » User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2278
xx Re: ComboBox Question
« Reply #3 on: Sep 15th, 2017, 9:54pm »

Close, but I think he's asking for the corresponding combo box to automatically drop down when a selection is made in the first box.

Something like this:

Code:
NoMainWin

Dim cboArray1$(1)

cboArray1$(0) = "File"
cboArray1$(1) = "Folder"

Dim cboArray2$(1)
cboArray2$(0) = "Folder Name 1"
cboArray2$(1) = "Folder Name 2"

Dim cboArray3$(1)
cboArray3$(0) = "File Name 1"
cboArray3$(1) = "File Name 2"

ComboBox #Test.cboFileFolder, cboArray1$(), comboClick, 10, 10, 120, 200
ComboboxColor$ = "Yellow"
ComboBox #Test.cboYellow, cboArray2$(), comboClick, 10, 40, 120, 200
ComboboxColor$ = "DarkGreen"
ComboBox #Test.cboGreen, cboArray3$(), comboClick, 10, 40, 120, 200
Open "Combobox Demo" For Window As #Test
#Test "TrapClose Quit"
#Test.cboFileFolder "SelectIndex 1"
#Test.cboYellow "SelectIndex 1"
#Test.cboGreen "SelectIndex 1"
#Test.cboYellow "Hide"
Wait

Sub Quit handle$
    Close #handle$
    End
End Sub

Function SendMessageA(hWnd, uMsg, wParam, lParam)
    CallDLL #user32, "SendMessageA",_
    hWnd as ulong,_
    uMsg as long,_
    wParam as long,_
    lParam as long,_
    SendMessageA as long
End Function

Sub showDropDown handle$
    hWnd = hwnd(#handle$)
    a = SendMessageA(hWnd, _CB_SHOWDROPDOWN, 1, 0)
End Sub

Sub comboClick handle$
    #handle$ "Selection? selection$"

    Select Case handle$
        Case "#Test.cboFileFolder"
            If selection$ = "File" Then
                #Test.cboYellow "Hide"
                #Test.cboGreen "Show"
                Call showDropDown "#Test.cboGreen"
            Else
                #Test.cboGreen "Hide"
                #Test.cboYellow "Show"
                Call showDropDown "#Test.cboYellow"
            End If
        Case "#Test.cboYellow"
            Notice "You clicked cboYellow!"
        Case "#Test.cboGreen"
            Notice "You clicked cboGreen!"
    End Select
End Sub 
User IP Logged

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


member is offline

Avatar




PM

Gender: Male
Posts: 24
xx Re: ComboBox Question
« Reply #4 on: Sep 15th, 2017, 11:09pm »

thanks all I think it will work, will try ti incorporate tomorrow....
User IP Logged

xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 24
xx Re: ComboBox Question
« Reply #5 on: Sep 17th, 2017, 4:53pm »

Have incorporated in my cnc sender for GRBL pgm -- works good
Here is the equivilent modified code.....


Code:
noMainWin

Dim drv$(4)
drv$(1)="C:\" : drv$(2)="D:\" : drv$(3)="E:\" : drv$(4)="F:\"

Dim cboArray1$(2)
cboArray1$(1) = "File" : cboArray1$(2) = "Folder"

Dim cboArray2$(4)
cboArray2$(1) = "Folder Name 1" :cboArray2$(2) = "Folder Name 2"
cboArray2$(3) = "Folder Name 3" : cboArray2$(4) = "Folder Name 4"

Dim cboArray3$(4)
cboArray3$(1) = "File Name 1" : cboArray3$(2) = "File Name 2"
cboArray3$(3) = "File Name 3" : cboArray3$(4) = "File Name 4"

global Path$
Statictext #Test.drvtxt, "Drive", 10,10,50,20
ComboBox #Test.drvbox, drv$(),comboClick, 70,10,120,200

Statictext #Test.FFbox, "F/F", 10,40,50,20
ComboBox #Test.cboFileFolder, cboArray1$(), comboClick, 70, 40, 120, 200

Statictext #Test.FilFdr, "Fil/Fdr", 10,80,50,20
ComboboxColor$ = "Yellow"
ComboBox #Test.cboYellow, cboArray2$(), comboClick, 70, 80, 120, 200

ComboboxColor$ = "Green"
ComboBox #Test.cboGreen, cboArray3$(), comboClick, 70, 80, 120, 200

Statictext #Test.stxt, "Path", 10,280,50,20
Textbox #Test.tbox, 10, 300, 470, 20

WindowWidth = 500
WindowHeight = 500
'------------------------------------------------------------------------
Open "Combobox Demo" For Window As #Test
#Test "TrapClose Quit"
#Test.drvbox "SelectIndex 0"
#Test.cboFileFolder "SelectIndex 0"
#Test.cboYellow "SelectIndex 0"
#Test.cboGreen "SelectIndex 0"
#Test.cboYellow "Hide"
Wait
'------------------------------------------------------------------------
Sub Quit handle$
    Close #handle$
    End
End Sub
'------------------------------------------------------------------------
Function SendMessageA(hWnd, uMsg, wParam, lParam)
    CallDLL #user32, "SendMessageA",_
    hWnd as ulong,_
    uMsg as long,_
    wParam as long,_
    lParam as long,_
    SendMessageA as long
End Function
'------------------------------------------------------------------------
Sub showDropDown handle$
    hWnd = hwnd(#handle$)
    a = SendMessageA(hWnd, _CB_SHOWDROPDOWN, 1, 0)   ' &H14F
End Sub
'------------------------------------------------------------------------
Sub comboClick handle$
    #handle$ "Selection? selection$"
    Select Case handle$
        Case "#Test.drvbox"                          ' Drive Letter  was Clicked
             Path$=""                                ' Clear Path var
             #Test.drvbox,"selection? Path$"         ' put selected drive into Path$
             '' #Test.drvbox,"!";P$                  ' put var data into Combobox
             #Test.tbox, Path$                       ' Display Path$ Data
        Case "#Test.cboFileFolder"
            If selection$ = "File" Then
                #Test.cboYellow "Hide"
                #Test.cboGreen "Show"
                Call showDropDown "#Test.cboGreen"
            Else
                #Test.cboGreen "Hide"
                #Test.cboYellow "Show"
                Call showDropDown "#Test.cboYellow"
            End If
            #Test.drvbox "SelectIndex 0"
        Case "#Test.cboYellow"
            #Test.cboYellow,"selection? yel$"
            Path$=Path$;yel$;"\"
            #Test.tbox, Path$
            #Test.cboYellow "SelectIndex 0"
        Case "#Test.cboGreen"
            #Test.cboGreen,"selection? grn$"
             Path$=Path$;grn$
            #Test.tbox, Path$
            #Test.cboGreen "SelectIndex 0"
    End Select
End Sub



 
User IP Logged

Brandon Parker
Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1115
xx Re: ComboBox Question
« Reply #6 on: Sep 17th, 2017, 8:57pm »

Since everyone will not have the same Drives as you it might be best to check out the "Drives$" parameter that is filled automatically by Liberty BASIC. You can use the variable directly or parse out the Drives into your array.

Code:
Print Drives$ 



{:0)

Brandon Parker
« Last Edit: Sep 17th, 2017, 8:57pm by Brandon Parker » User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
xtal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 24
xx Re: ComboBox Question
« Reply #7 on: Sep 18th, 2017, 11:33am »

It is in the cnc pgm
User IP Logged

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