Fred answered your most difficult question, and I'll try to answer your
remaining question. I seem to remember some thread in this forum revealing
the fact that contrary to the Users' manual on p.213, that CONTROL GET TEXT
does not give a single string with items separated by CHR$(0). But I couldn't
find it with a search, and couldn't find it in Lance's Errata sheets. I believe
the book and the IDE help to be in error.
The following code is the best that I could do, and it may be no better than
what you have already come up with. I did use a message box instead of copying
to a text file.
Code:
#COMPILE EXE #DIM ALL #INCLUDE "win32api.INC" DECLARE CALLBACK FUNCTION dlgProc() FUNCTION PBMAIN LOCAL hDlg AS LONG, style AS LONG DIALOG NEW 0, "Listbox Test", , , 120, 120, %WS_SYSMENU + %WS_CAPTION TO hDlg CONTROL ADD TEXTBOX, hDlg, 100, "", 5, 5, 100, 10 CONTROL ADD LISTBOX, hDlg, 101, , 5, 20, 100, 70, %LBS_SORT + %WS_VSCROLL CONTROL ADD BUTTON, hDlg, 102, "&Add", 15, 95, 40, 20 CONTROL ADD BUTTON, hDlg, 103, "&Copy", 65, 95, 40, 20 DIALOG SHOW MODAL hDlg CALL dlgProc END FUNCTION CALLBACK FUNCTION dlgProc() LOCAL i AS LONG, n AS LONG LOCAL txt AS STRING LOCAL s AS ASCIIZ * 80 SELECT CASE CBMSG CASE %WM_COMMAND IF CBCTL = 102 THEN CONTROL GET TEXT CBHNDL, 100 TO txt LISTBOX ADD CBHNDL, 101, txt CONTROL SET TEXT CBHNDL, 100, "" CONTROL SET FOCUS CBHNDL, 100 ELSEIF CBCTL = 103 THEN CONTROL SEND CBHNDL, 101, %LB_GETCOUNT, 0, 0 TO n FOR i = 0 TO n - 1 CONTROL SEND CBHNDL, 101, %LB_GETTEXT, i, VARPTR(s) txt = txt + s + $CRLF NEXT i MSGBOX txt END IF END SELECT END FUNCTION
Leave a comment: