Announcement

Collapse
No announcement yet.

Combobox DDT Style

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

  • Scott Turchin
    replied
    Ah, that would be the control get text part?

    Glad it worked!

    Scott

    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Steven Geisler
    replied
    BINGO! Thanks for the help and speedy reply.

    ------------------

    Leave a comment:


  • Scott Turchin
    replied
    Maybe a bit off of the same thing, but I had similiar issues with the ComboBox, here's how i handled it, if anyone can see a better way let me know.
    Basically the combo box is used to hold server NAMES for the time server.
    I keep an index of where each server is at, and index the array for the string.
    Code:
    'In Winmain
                Control Add ComboBox, g_hDlgMisc(lLoop), %IDCOMBOBOX,serv(), 60, 30, 160, _
                                    120,%CBS_DROPDOWNLIST Or %WS_VSCROLL Or %WS_TABSTOP
    
    'In the dialog callback, user selects which time server to use:
    
              Case %IDCOMBOBOX
                   EnableButtons
                   If LoWrd(CbCtlMsg) = %CBN_SELENDOK Then
                       ComboBox Get Text g_hDlgMisc(1),%IDCOMBOBOX To nServer
                       ServerNum =  GetServerNum(nServer)
                       ComboBox Select g_hDlgMisc(ServerNum), %IDCOMBOBOX,ServerNum  
                   End If
                   Function = 1
                   Exit Function
    
    ;And then the function
    
    Function GetServerNum(nServer As String) As Long
    Local x As Long
    For x = 1 To %MAX_SERVERS
        If nServer = Serv(x)Then
            Function = x
            Exit For
        End If
    Next
    End Function
    
    
    I'm not sure if this is related or not, and you may have to reverse it...but basically you can either get text or get the ID of the selection and then match a string to that (??)
    
    Maybe i'm way off base here, but if this helps...


    ------------------
    Scott
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    Steven --
    Because I don't like separate, I decided to show common callback.
    To say true, you can receive needed element by simple ComboBox Get Text CbHndl, 301 To s$
    Code:
       #Compile Exe
       #Register None
       #Dim All
       #Include "win32api.inc"
       Global perc As Double
       Global s As String
       Global hDlg As Long
    
       CallBack Function DlgProc
          Select Case CbMsg
             Case %WM_COMMAND
                Select Case CbCtl
                   Case %IDOK: Dialog End CbHndl, 1
                   Case %IDCANCEL: Dialog End CbHndl, 0
                   Case 101 To 108
                      If CbCtlMsg = %BN_CLICKED Then
                         If CbCtl = 101 Then perc# = .05#
                         If CbCtl = 102 Then perc# = .10#
                         If CbCtl = 103 Then perc# = .125#
                         If CbCtl = 104 Then perc# = .15#
                         If CbCtl = 105 Then perc# = .175#
                         If CbCtl = 106 Then perc# = .20#
                         If CbCtl = 107 Then perc# = .25#
                         If CbCtl = 108 Then perc# = .30#
                      End If
                   Case 301
                      Select Case CbCtlMsg
                         Case %CBN_SELENDOK
                            Dim txt As String
                            ComboBox Get Text CbHndl, 301 To s$
                         End Select
                      End Select
             End Select
       End Function
    
       Function PbMain
          ' ** Create a new dialog template
          Dialog New %HWND_DESKTOP, "LOG SPIRAL", 0, 0, 367, 250,%WS_CAPTION _
             Or %WS_SYSMENU Or %WS_MINIMIZEBOX Or %DS_CENTER, 0 To hDlg
          ' ** Add controls to it
          Control Add Button, hDlg, %IDOK, "OK", 300, 185, 40, 14, %BS_DEFAULT
          Control Add Button, hDlg, %IDCANCEL, "Cancel", 300, 210, 40, 14, 0
          Control Add Frame,hDlg,-1,"choose a percent",30,50,70,175, _
             %WS_CHILD Or %WS_VISIBLE Or %BS_GROUPBOX Or %WS_EX_TRANSPARENT
          Control Add Option,hDlg,101,"5%",40,65,53,12
          Control Add Option,hDlg,102,"10%",40,85,53,12
          Control Add Option,hDlg,103,"12.5%",40,105,53,12
          Control Add Option,hDlg,104,"15%",40,125,53,12
          Control Add Option,hDlg,105,"17.5%",40,145,53,12
          Control Add Option,hDlg,106,"20%",40,165,53,12
          Control Add Option,hDlg,107,"25%",40,185,53,12
          Control Add Option,hDlg,108,"30%",40,205,53,12
    
          Dim B(1:6) As String
          b$(1) = "Ivan"
          b$(2) = "Petr"
          b$(3) = "Oleg"
          b$(4) = "Vasia"
          b$(5) = "Masha"
          b$(6) = "Lena"
    
          Control Add ComboBox, hDlg,301,B$(), 200, 52, 50, 100, %CBS_DROPDOWNLIST Or %CBS_SORT
          ' ** Display the dialog
          Dim Result As Long
          Dialog Show Modal hDlg  Call DlgProc To Result
          If Result = 1 Then MsgBox Format$(perc#)+ " " + s$ Else MsgBox "Canceled"
       End Function
    ------------------

    Leave a comment:


  • Steven Geisler
    started a topic Combobox DDT Style

    Combobox DDT Style

    I have a list of stocks and want to create a percent
    swing chart. I can return the value of my percent that
    I choose with the option button and display it with the
    MSGBOX, but I am having trouble figuring out how to
    return the string (stock) I choose in my combobox and
    have it display in the MSGBOX as well. I'm missing something.
    Maybe a CALLBACK FUNCTION of some sort?? Otherwise,
    everything displays on the screen OK. Any tips??
    ------------------------------------------------------
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    GLOBAL perc AS DOUBLE
    GLOBAL s AS STRING
    GLOBAL hDlg AS LONG

    CALLBACK FUNCTION OkButton()
    DIALOG END CBHNDL, 1
    END FUNCTION

    CALLBACK FUNCTION CancelButton()
    DIALOG END CBHNDL, 0
    END FUNCTION

    CALLBACK FUNCTION List1()
    IF CBCTLMSG = %BN_CLICKED THEN
    IF CBCTL = 101 THEN perc# = .05#
    IF CBCTL = 102 THEN perc# = .10#
    IF CBCTL = 103 THEN perc# = .125#
    IF CBCTL = 104 THEN perc# = .15#
    IF CBCTL = 105 THEN perc# = .175#
    IF CBCTL = 106 THEN perc# = .20#
    IF CBCTL = 107 THEN perc# = .25#
    IF CBCTL = 108 THEN perc# = .30#
    END IF
    END FUNCTION

    '<=====?CALLBACK HERE AND PLACE SELECTION INTO s$

    '------------------------------------------------------------------------------

    FUNCTION PBMAIN () AS LONG
    $REGISTER NONE

    ' ** Create a new dialog template
    DIALOG NEW hParent&, "LOG SPIRAL", 0, 0, 367, 250,%WS_CAPTION _
    OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %DS_CENTER, 0 TO hDlg

    ' ** Add controls to it
    CONTROL ADD BUTTON, hDlg, %IDOK, "OK", 300, 185, 40, 14, _
    %BS_DEFAULT CALL OkButton
    CONTROL ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 300, 210, 40, _
    14, 0 CALL CancelButton
    CONTROL ADD FRAME,hDlg,-1,"choose a percent",30,50,70,175, _
    %WS_CHILD OR %WS_VISIBLE OR %BS_GROUPBOX OR %WS_EX_TRANSPARENT
    CONTROL ADD OPTION,hDlg,101,"5%",40,65,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,102,"10%",40,85,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,103,"12.5%",40,105,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,104,"15%",40,125,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,105,"17.5%",40,145,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,106,"20%",40,165,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,107,"25%",40,185,53,12 CALL list1
    CONTROL ADD OPTION,hDlg,108,"30%",40,205,53,12 CALL list1

    DIM A$
    DIM B$(1:100)
    ThePath$ = "G:\test\data"
    A$ = DIR$(ThePath$ + "/*.ac5")
    WHILE LEN(A$)
    INCR c&
    A$ = DIR$
    B$(c&)= RTRIM$(A$,".AC5")
    WEND
    REDIM PRESERVE B$(1 TO c&)

    CONTROL ADD COMBOBOX, hDlg,301,B$(), 200, 52, 50, 100, _
    %CBS_DROPDOWNLIST OR %CBS_SORT

    ' ** Display the dialog
    DIALOG SHOW MODAL hDlg

    MSGBOX FORMAT$(perc#)+ " " + s$ '<===perc# displays..need s$

    END FUNCTION



Working...
X