Announcement

Collapse
No announcement yet.

Add to a listbox

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

  • Paul Squires
    replied
    As myself and others in this thread have said, you are using the lCount parameter incorrectly. Your code is passing the value of 30 for lCount, but in your SampleListBox function there are only 6 elements in the string that you are parsing. The LISTBOX ADD statement is executing 30 times but only the PARSE$ is only retrieving 6 data elements from the string - the other 24 are blank strings.

    Leave a comment:


  • Dave Biggs
    replied
    While composing your message, when you want to include code samples, first click on the # sign just above the message edit window. That will cause a pair of [ CODE ] [ /CODE ] markers to appear (without any spaces) - paste your code between [..DE] and [/COD..] That will present your code in a frame that preserves the formatting - much easier for others to read.

    In your code.. Compare the SampleListBox function in your code with the SampleListBox function posted in my last msg (post #9) for the answer you seek.

    (It's involves resetting the lCount value).

    Good luck!

    Leave a comment:


  • Brian Heibert
    replied
    Here's my listbox code...

    What do I need to change to get it to work?

    #PBFORMS CREATED V1.51
    '------------------------------------------------------------------------------
    ' The first line in this file is a PB/Forms metastatement.
    ' It should ALWAYS be the first line of the file. Other
    ' PB/Forms metastatements are placed at the beginning and
    ' end of "Named Blocks" of code that should be edited
    ' with PBForms only. Do not manually edit or delete these
    ' metastatements or PB/Forms will not be able to reread
    ' the file correctly. See the PB/Forms documentation for
    ' more information.
    ' Named blocks begin like this: #PBFORMS BEGIN ...
    ' Named blocks end like this: #PBFORMS END ...
    ' Other PB/Forms metastatements such as:
    ' #PBFORMS DECLARATIONS
    ' are used by PB/Forms to insert additional code.
    ' Feel free to make changes anywhere else in the file.
    '------------------------------------------------------------------------------

    #COMPILE EXE
    #DIM ALL

    '------------------------------------------------------------------------------
    ' ** Includes **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN INCLUDES
    #RESOURCE "SearchPal.pbr"
    #IF NOT %DEF(%WINAPI)
    #INCLUDE "WIN32API.INC"
    #ENDIF
    #INCLUDE "PBForms.INC"
    #PBFORMS END INCLUDES
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** Constants **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN CONSTANTS
    %FEXTKEY = 0
    %IDD_SEARCHPAL = 101
    %IDC_SPTXT = 1001
    %IDC_MSCTLS_PROGRESS32_1 = 1002 '*
    %IDC_MSCTLS_UPDOWN32_1 = 1003 '*
    %IDC_SearchForStatic = 1004
    %IDC_QUERY = 1005
    %IDC_LABEL1 = 1006
    %IDC_LABEL2 = 1007 '*
    %IDC_LABEL3 = 1008 '*
    %IDC_LABEL4 = 1009
    %IDC_LABEL5 = 1010 '*
    %IDC_LABEL6 = 1011 '*
    %IDC_LABEL7 = 1012 '*
    %IDC_LABEL8 = 1013 '*
    %IDC_LABEL9 = 1014 '*
    %IDC_LABEL10 = 1015
    %IDC_LABEL11 = 1016
    %IDC_SearchBox = 1017
    %IDC_LABEL12 = 1018
    %IDC_SearchBtn = 1019
    %IDC_EXIT = 1020
    %IDC_LABEL13 = 1021 '*
    %IDC_LABEL14 = 1023
    %IDR_MENU1 = 102
    %IDM_FILE_EXIT = 1024
    %IDR_ACCELERATOR1 = 103
    %IDM_EDIT_CUT = 1025
    %IDM_EDIT_COPY = 1026
    %IDM_EDIT_PASTE = 1027
    %IDM_EDIT_CLEAR = 1028 '*
    %IDM_EDIT_DELETE = 1029
    %IDM_EDIT_SELECTALL = 1030
    %IDM_HELP = 1031 '*
    %IDM_SEARCHPALHELP = 1032
    %IDM_HELP_SHAREWARE100 = 1033
    %IDM_HELP_GOTOMACDESIGNEDSOFTWAR = 1034
    %IDC_ENGINES = 1022
    %IDC_SCROLLBAR1 = 1035 '*
    %IDC_FRAME1 = 1036 '*
    %IDR_IMGFILE1 = 104
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** Declarations **
    '------------------------------------------------------------------------------
    DECLARE FUNCTION AttachMENU1(BYVAL hDlg AS DWORD) AS DWORD
    DECLARE FUNCTION ASSIGNACCEL(tAccel AS ACCELAPI, BYVAL wKey AS WORD, BYVAL _
    wCmd AS WORD, BYVAL byFVirt AS BYTE) AS LONG
    DECLARE FUNCTION AttachACCELERATOR1(BYVAL hDlg AS DWORD) AS DWORD
    DECLARE CALLBACK FUNCTION ShowSEARCHPALProc()
    DECLARE FUNCTION SampleListBox(BYVAL hDlg AS DWORD, BYVAL lID AS LONG, BYVAL _
    lCount AS LONG) AS LONG
    DECLARE FUNCTION ShowSEARCHPAL(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** Main Application Entry Point **
    '------------------------------------------------------------------------------
    FUNCTION PBMAIN()
    ShowSEARCHPAL %HWND_DESKTOP
    END FUNCTION
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** Menus **
    '------------------------------------------------------------------------------

    FUNCTION ShowURL(BYVAL strURL AS STRING) AS INTEGER
    LOCAL pszURL AS ASCIIZ PTR
    LOCAL nResult AS LONG

    pszURL = STRPTR(strURL)
    nResult = ShellExecute(%NULL, "open", @pszURL, "", "", %SW_SHOWDEFAULT)
    IF nResult > 32 THEN
    FUNCTION = %TRUE
    ELSE
    FUNCTION = %FALSE
    END IF
    END FUNCTION

    FUNCTION AttachMENU1(BYVAL hDlg AS DWORD) AS DWORD
    #PBFORMS BEGIN MENU %IDR_MENU1->%IDD_SEARCHPAL
    LOCAL hMenu AS DWORD
    LOCAL hPopUp1 AS DWORD

    MENU NEW BAR TO hMenu
    MENU NEW POPUP TO hPopUp1
    MENU ADD POPUP, hMenu, "&File", hPopUp1, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "&Exit" + $TAB + "Ctrl+E", %IDM_FILE_EXIT, _
    %MF_ENABLED
    MENU NEW POPUP TO hPopUp1
    MENU ADD POPUP, hMenu, "&Edit", hPopUp1, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "Cu&t" + $TAB + "Ctrl+X", %IDM_EDIT_CUT, _
    %MF_ENABLED
    MENU ADD STRING, hPopUp1, "&Copy" + $TAB + "Ctrl+C", %IDM_EDIT_COPY, _
    %MF_ENABLED
    MENU ADD STRING, hPopUp1, "&Paste" + $TAB + "Ctrl+V", _
    %IDM_EDIT_PASTE, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "-", 0, 0
    MENU ADD STRING, hPopUp1, "&Delete" + $TAB + "Delete", _
    %IDM_EDIT_DELETE, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "Select All" + $TAB + "Ctrl+A", _
    %IDM_EDIT_SELECTALL, %MF_ENABLED
    MENU NEW POPUP TO hPopUp1
    MENU ADD POPUP, hMenu, "&Help", hPopUp1, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "SearchPal Help" + $TAB + "F1", _
    %IDM_SEARCHPALHELP, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "-", 0, 0
    MENU ADD STRING, hPopUp1, "Shareware $1.00" + $TAB + "F2", _
    %IDM_HELP_SHAREWARE100, %MF_ENABLED
    MENU ADD STRING, hPopUp1, "Goto MacDesignedSoftware.com", _
    %IDM_HELP_GOTOMACDESIGNEDSOFTWAR, %MF_ENABLED

    MENU ATTACH hMenu, hDlg
    #PBFORMS END MENU
    FUNCTION = hMenu
    END FUNCTION
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** Accelerators **
    '------------------------------------------------------------------------------
    #PBFORMS BEGIN ASSIGNACCEL
    FUNCTION ASSIGNACCEL(tAccel AS ACCELAPI, BYVAL wKey AS WORD, BYVAL wCmd AS _
    WORD, BYVAL byFVirt AS BYTE) AS LONG
    tAccel.fVirt = byFVirt
    tAccel.key = wKey
    tAccel.cmd = wCmd
    END FUNCTION
    #PBFORMS END ASSIGNACCEL
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    FUNCTION AttachACCELERATOR1(BYVAL hDlg AS DWORD) AS DWORD
    #PBFORMS BEGIN ACCEL %IDR_ACCELERATOR1->%IDD_SEARCHPAL
    LOCAL hAccel AS DWORD
    LOCAL tAccel() AS ACCELAPI
    DIM tAccel(1 TO 8) AS ACCELAPI

    ASSIGNACCEL tAccel(1), ASC("E"), %IDM_FILE_EXIT, %FVIRTKEY OR %FCONTROL _
    OR %FNOINVERT
    ASSIGNACCEL tAccel(2), ASC("X"), %IDM_EDIT_CUT, %FVIRTKEY OR %FCONTROL OR _
    %FNOINVERT
    ASSIGNACCEL tAccel(3), ASC("C"), %IDM_EDIT_COPY, %FVIRTKEY OR %FCONTROL _
    OR %FNOINVERT
    ASSIGNACCEL tAccel(4), ASC("V"), %IDM_EDIT_PASTE, %FVIRTKEY OR %FCONTROL _
    OR %FNOINVERT
    ASSIGNACCEL tAccel(5), %VK_DELETE, %IDM_EDIT_DELETE, %FVIRTKEY OR _
    %FEXTKEY OR %FNOINVERT
    ASSIGNACCEL tAccel(6), ASC("A"), %IDM_EDIT_SELECTALL, %FVIRTKEY OR _
    %FCONTROL OR %FNOINVERT
    ASSIGNACCEL tAccel(7), %VK_F1, %IDM_SEARCHPALHELP, %FVIRTKEY OR _
    %FNOINVERT
    ASSIGNACCEL tAccel(8), %VK_F2, %IDM_HELP_SHAREWARE100, %FVIRTKEY OR _
    %FNOINVERT

    ACCEL ATTACH hDlg, tAccel() TO hAccel
    #PBFORMS END ACCEL
    FUNCTION = hAccel
    END FUNCTION
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** CallBacks **
    '------------------------------------------------------------------------------
    CALLBACK FUNCTION ShowSEARCHPALProc()

    SELECT CASE AS LONG CBMSG
    CASE %WM_INITDIALOG
    ' Initialization handler

    CASE %WM_NCACTIVATE
    STATIC hWndSaveFocus AS DWORD
    IF ISFALSE CBWPARAM THEN
    ' Save control focus
    hWndSaveFocus = GetFocus()
    ELSEIF hWndSaveFocus THEN
    ' Restore control focus
    SetFocus(hWndSaveFocus)
    hWndSaveFocus = 0
    END IF

    CASE %WM_COMMAND
    ' Process control notifications
    SELECT CASE AS LONG CBCTL
    CASE %IDC_SPTXT

    CASE %IDC_SearchForStatic

    CASE %IDC_QUERY

    CASE %IDC_LABEL1

    CASE %IDC_LABEL4

    CASE %IDC_LABEL10

    CASE %IDC_LABEL11

    CASE %IDC_SearchBox

    CASE %IDC_LABEL12

    CASE %IDC_SearchBtn


    CASE %IDC_EXIT
    DIALOG END CBHNDL, 0

    CASE %IDC_ENGINES

    CASE %IDC_LABEL14

    CASE %IDM_FILE_EXIT
    DIALOG END CBHNDL, 0
    CASE %IDM_EDIT_CUT
    CONTROL SEND CBHNDL,%IDC_Query, %WM_CUT, 0,0


    CASE %IDM_EDIT_COPY
    CONTROL SEND CBHNDL, %IDC_Query, %WM_COPY, 0,0

    CASE %IDM_EDIT_PASTE
    CONTROL SEND CBHNDL, %IDC_Query, %WM_PASTE, 0, 0

    CASE %IDM_EDIT_DELETE
    MSGBOX "%IDM_EDIT_DELETE=" + FORMAT$(%IDM_EDIT_DELETE), _
    %MB_TASKMODAL

    CASE %IDM_EDIT_SELECTALL
    MSGBOX "%IDM_EDIT_SELECTALL=" + _
    FORMAT$(%IDM_EDIT_SELECTALL), %MB_TASKMODAL

    CASE %IDM_SEARCHPALHELP
    MSGBOX "%IDM_SEARCHPALHELP=" + _
    FORMAT$(%IDM_SEARCHPALHELP), %MB_TASKMODAL

    CASE %IDM_HELP_SHAREWARE100
    ShowURL ("http://www.macdesignedsoftware.com/store_online.html")

    CASE %IDM_HELP_GOTOMACDESIGNEDSOFTWAR
    ShowURL ("http://www.macdesignedsoftware.com")

    END SELECT
    END SELECT
    END FUNCTION
    '------------------------------------------------------------------------------

    '------------------------------------------------------------------------------
    ' ** Sample Code **
    '------------------------------------------------------------------------------
    FUNCTION SampleListBox(BYVAL hDlg AS DWORD, _
    BYVAL lID AS LONG, _
    BYVAL lCount AS LONG) AS LONG
    LOCAL i AS LONG
    LOCAL sItems AS STRING

    sItems = "Yahoo,Excite,Google,Ask.com,AltaVista,Bing" ' Assign list once to a dynamic variable.

    FOR i = 1 TO lCount
    LISTBOX ADD hDlg, lID, PARSE$(sItems, i)
    NEXT i

    END FUNCTION

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

    '------------------------------------------------------------------------------
    ' ** Dialogs **
    '------------------------------------------------------------------------------
    FUNCTION ShowSEARCHPAL(BYVAL hParent AS DWORD) AS LONG
    LOCAL lRslt AS LONG

    #PBFORMS BEGIN DIALOG %IDD_SEARCHPAL->%IDR_MENU1->%IDR_ACCELERATOR1
    LOCAL hDlg AS DWORD
    LOCAL hFont1 AS DWORD
    LOCAL hFont2 AS DWORD
    LOCAL hFont3 AS DWORD
    LOCAL hFont4 AS DWORD

    DIALOG NEW hParent, "SearchPal", 321, 297, 477, 261, %WS_POPUP OR _
    %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION OR %WS_SYSMENU OR _
    %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME _
    OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _
    %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR _
    %WS_EX_RIGHTSCROLLBAR, TO hDlg
    DIALOG SET ICON hDlg, "#" + FORMAT$(%IDR_IMGFILE1)
    CONTROL ADD LABEL, hDlg, %IDC_SPTXT, "SearchPal", 30, 20, 125, 30
    CONTROL ADD LABEL, hDlg, %IDC_SearchForStatic, "S&earch for...", 15, _
    72, 50, 15
    CONTROL ADD TEXTBOX, hDlg, %IDC_QUERY, "", 75, 70, 370, 15
    CONTROL SET COLOR hDlg, %IDC_QUERY, -1, %LTGRAY
    CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "internet search with attitude", _
    185, 25, 135, 15
    CONTROL ADD LABEL, hDlg, %IDC_LABEL4, "TM", 145, 15, 25, 10
    CONTROL ADD LABEL, hDlg, %IDC_LABEL10, "TM", 318, 23, 20, 10
    CONTROL ADD LABEL, hDlg, %IDC_LABEL11, "(C) Copyright 2009 Brian " + _
    "Heibert && MacDesigned Software", 60, 200, 335, 20
    CONTROL ADD LISTBOX, hDlg, %IDC_SearchBox, , 165, 345, 370, 55
    CONTROL SET COLOR hDlg, %IDC_SearchBox, -1, %LTGRAY
    CONTROL ADD LABEL, hDlg, %IDC_LABEL12, "Select &a engine...", 75, 95, _
    370, 15
    CONTROL ADD BUTTON, hDlg, %IDC_SearchBtn, "&Search", 300, 175, 60, 15, _
    %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %WS_TABSTOP OR %BS_TEXT OR _
    %BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, %WS_EX_LEFT OR _
    %WS_EX_LTRREADING
    CONTROL ADD BUTTON, hDlg, %IDC_EXIT, "&Exit", 375, 175, 60, 15
    CONTROL ADD LISTBOX, hDlg, %IDC_ENGINES, , 75, 105, 370, 60
    CONTROL SET COLOR hDlg, %IDC_ENGINES, -1, %LTGRAY
    CONTROL ADD LABEL, hDlg, %IDC_LABEL14, "All Rights Reserved.", 60, 215, _
    335, 20

    hFont1 = PBFormsMakeFont("MS Sans Serif", 12, 400, %FALSE, %FALSE, _
    %FALSE, %ANSI_CHARSET)
    hFont2 = PBFormsMakeFont("Arial Black", 24, 700, %FALSE, %FALSE, %FALSE, _
    %ANSI_CHARSET)
    hFont3 = PBFormsMakeFont("MS Sans Serif", 8, 700, %FALSE, %FALSE, %FALSE, _
    %ANSI_CHARSET)
    hFont4 = PBFormsMakeFont("MS Sans Serif", 12, 700, %FALSE, %FALSE, _
    %FALSE, %ANSI_CHARSET)

    DIALOG SEND hDlg, %WM_SETFONT, hFont1, 0
    CONTROL SEND hDlg, %IDC_SPTXT, %WM_SETFONT, hFont2, 0
    CONTROL SEND hDlg, %IDC_SearchForStatic, %WM_SETFONT, hFont3, 0
    CONTROL SEND hDlg, %IDC_QUERY, %WM_SETFONT, hFont1, 0
    CONTROL SEND hDlg, %IDC_LABEL1, %WM_SETFONT, hFont1, 0
    CONTROL SEND hDlg, %IDC_LABEL11, %WM_SETFONT, hFont1, 0
    CONTROL SEND hDlg, %IDC_SearchBox, %WM_SETFONT, hFont1, 0
    CONTROL SEND hDlg, %IDC_LABEL12, %WM_SETFONT, hFont3, 0
    CONTROL SEND hDlg, %IDC_SearchBtn, %WM_SETFONT, hFont4, 0
    CONTROL SEND hDlg, %IDC_EXIT, %WM_SETFONT, hFont4, 0
    CONTROL SEND hDlg, %IDC_ENGINES, %WM_SETFONT, hFont1, 0
    CONTROL SEND hDlg, %IDC_LABEL14, %WM_SETFONT, hFont1, 0

    AttachMENU1 hDlg

    AttachACCELERATOR1 hDlg
    #PBFORMS END DIALOG

    SampleListBox hDlg, %IDC_SearchBox, 30
    SampleListBox hDlg, %IDC_ENGINES, 30

    DIALOG SHOW MODAL hDlg, CALL ShowSEARCHPALProc TO lRslt

    #PBFORMS BEGIN CLEANUP %IDD_SEARCHPAL
    DeleteObject hFont1
    DeleteObject hFont2
    DeleteObject hFont3
    DeleteObject hFont4
    #PBFORMS END CLEANUP

    FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------

    Leave a comment:


  • Dave Biggs
    replied
    Here's some commented code that might help you see what is happening..
    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "WIN32API.INC"
     
    %IDD_DIALOG1  =  101
    %LSB_LISTBOX1 = 1001
     
    FUNCTION PBMAIN()
      ShowDIALOG1 %HWND_DESKTOP
    END FUNCTION
    '------------------/
     
    FUNCTION SampleListBox(BYVAL hDlg   AS DWORD, _
                           BYVAL lID    AS LONG, _
                           BYVAL lCount AS LONG) AS LONG
     LOCAL i      AS LONG
     LOCAL sItems AS STRING
     
     sItems = "Yahoo,Excite,Google,Ask.com,AltaVista,Bing" ' Assign list once to a dynamic variable.
     
     'lCount = ParseCount(sItems)                    ' Uncomment to reset lCount equal to sItems count
     
     ' NB. If i evaluates is outside of the actual field count, an empty string is returned by PARSE$.
     FOR i = 1 TO lCount
      LISTBOX ADD hDlg, lID, PARSE$(sItems, i)              
      ' NB. If the LISTBOX has the %LBS_SORT style, the new string is inserted in alphanumeric order; 
      '     (Extra empty strings are sorted to top); otherwise it's added to the end of the existing list.
     NEXT i
     
    END FUNCTION
    '------------------/
     
    FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
     LOCAL hDlg  AS DWORD
     
      DIALOG NEW hParent, "'lCount' Strings", 215, 92, 201, 121, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR %WS_CAPTION _
        OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE _
        OR %DS_SETFONT, %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO _
        hDlg
      CONTROL ADD LISTBOX, hDlg, %LSB_LISTBOX1, , 5, 5, 100, 80   ' NB. No Styles so default includes %LBS_SORT
     
       SampleListBox  hDlg, %LSB_LISTBOX1, 10    ' NB. Value 10 -> lCount in SampleListBox function
     
      DIALOG SHOW MODAL hDlg
    END FUNCTION
    '------------------/

    Leave a comment:


  • Gary Beene
    replied
    Brian,

    Post the whole code so we can help.

    My first guess is that when you created the ListBox, you put blank lines in the listbox - but without seeing your code, I cannot tell.

    Also, when you show code in a post, please use the "#" button to put quotes around your code so the code will be easier to read.

    I put (more-or-less) your code in this example and it works just fine.

    Code:
    #Compile Exe
    #Dim All
    Global hDlg As Dword
    Function PBMain() As Long
      Dialog New Pixels, 0, "ListBox Test",300,300,200,200, %WS_SysMenu, 0 To hDlg
      Control Add Button, hDlg, 200, "Test", 50,10,75,20
      Control Add ListBox, hDlg, 100, ,50,50,75,100
      Dialog Show Modal hDlg Call DlgProc
    End Function
    
    CallBack Function DlgProc() As Long
      If Cb.Msg = %WM_Command And Cb.Ctl = 200 Then
        Local i As Long, Lcount As Long
        Local sItems As String, t As String
        sItems = "Yahoo,Excite,Google,Ask.com,AltaVista,Bing" ' Assign list once to a dynamic variable.
        lCount = 5
        For i = 1 To lCount
           ListBox Add hDlg, 100, Parse$(sItems, i)
        Next i
      End If
    End Function

    Leave a comment:


  • Paul Squires
    replied
    You're incoming value for the the lCount parameter in the SampleListBox function is probably a different value than the number of parses in the sItem string. Instead of passing in the lCount, why not just calculate the lCount value using ParseCount.

    Leave a comment:


  • Brian Heibert
    replied
    I tried using this code to create a listbox
    well there is a lot of empty space before my items appear
    and this empty space is selectable
    what do I do to fix that?

    FUNCTION SampleListBox(BYVAL hDlg AS DWORD, _
    BYVAL lID AS LONG, _
    BYVAL lCount AS LONG) AS LONG
    LOCAL i AS LONG
    LOCAL sItems AS STRING

    sItems = "Yahoo,Excite,Google,Ask.com,AltaVista,Bing" ' Assign list once to a dynamic variable.

    FOR i = 1 TO lCount
    LISTBOX ADD hDlg, lID, PARSE$(sItems, i)
    NEXT i

    END FUNCTION

    Leave a comment:


  • Richard Angell
    replied
    Adding to a Listbox is easy enough, however inserting into a listbox is more involved.

    See the LISTBOX command page in your help file for the full list of DDT Listbox commands, specifically here the LISTBOX ADD statement. However if you will be inserting then see the LISTBOX insert command, which depends on if your listbox has the sort style off, if not use LISTBOX ADD.

    Leave a comment:


  • Brian Heibert
    replied
    DDT

    Brian

    Leave a comment:


  • George Bleck
    replied
    Are you using DDT or SDK format to create the dialog and listbox?

    ADDED: Dave posted just as I did... his response only works if you created it using the DDT method.

    Leave a comment:


  • Dave Biggs
    replied
    Here's one way..
    http://www.powerbasic.com/support/pb...93&postcount=2

    Leave a comment:


  • Brian Heibert
    started a topic Add to a listbox

    Add to a listbox

    Hi,

    How do I add to a listbox
    Right now my listbox is blank

    Brian
Working...
X