Mystery: this bit of code gives the listbox in SORTED order. Using the option to specify the array name (ECsbm$) does the same. Since the %LBS_SORT style is absent, what can the reason be? By putting a MsgBox just before the "NEXT" of the loop, I could observe that (a) the strings are fetched in turn, as per original array, and (b) they are inserted in their alphabetical positions immediately.
I downloaded from the BBS the several example files of Dave Navarro's, and in the bit which I used here, the REMARKS read:
REMARKS: If the listbox does not have the %LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list and the list is sorted.
I downloaded from the BBS the several example files of Dave Navarro's, and in the bit which I used here, the REMARKS read:
REMARKS: If the listbox does not have the %LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list and the list is sorted.
Code:
'--------------------------------------------------------------------- CallBack Function ECmenus() If CbMsg = %WM_COMMAND Then If CbCtl=1000 Or CbCtl=1001 Then ReDim ECsbm$(16) ECsbm$(1)="New quotation" ECsbm$(2)="Quotations in progress" ECsbm$(3)="Standard quotation" ECsbm$(4)="Ex-archive quotation" ECsbm$(5)="Worktickets menu" ECsbm$(6)="Set up standard jobs" ECsbm$(7)="JOB COSTING SUBMENU" ECsbm$(8)="Print setup files" ECsbm$(9)="Suppliers' price list report" ECsbm$(10)="Transfer archive to diskette" ECsbm$(11)="Ticket/time report" ECsbm$(12)="Ticket/sales report" ECsbm$(13)="Agents' commission report" ECsbm$(14)="Company stock selling prices" ECsbm$(15)="Time dockets checklist" ECsbm$(16)="Browse archived jobs" Control Add ListBox, pDlg&, %ID_EstSbm,, 140, 20, 120, 140 Call ECselect hFont = MakeFont("MS Sans Serif", 10) Dialog Send pDlg&, %WM_SETFONT, hFont, 1 Control Handle pDlg&, %ID_EstSbm To hCtl& For i&=1 To 16 RetVal& = LbAddString(hCtl&, ECsbm$(i&)) Next End If End If End Function '---------------------------------------------------------------------- Excerpt from BBS download: ' TITLE: LbAddString ' DESC: Add a string to a listbox. ' SYNTAX: RetVal = LbAddString(hListBox, Text$) 'RETURNS: The return value is the zero-based index to the string in the ' list box. The return value is %LB_ERR if an error occurs; the ' return value is %LB_ERRSPACE if insufficient space is available ' to store the new string. 'REMARKS: If the listbox does not have the %LBS_SORT style, the string ' is added to the end of the list. Otherwise, the string is ' inserted into the list and the list is sorted. ' FUNCTION LbAddString(BYVAL hListBox AS LONG, BYVAL Text AS STRING) AS LONG FUNCTION = SendMessage(hListBox, %LB_ADDSTRING, 0, STRPTR(Text)) END FUNCTION '----------------------------------------------------------------------
Comment