Hi,
How do I add to a listbox
Right now my listbox is blank
Brian
How do I add to a listbox
Right now my listbox is blank
Brian
#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
#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 '------------------/
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment