Re: Listbox reset?


Ian_Wade_G3NRW
 

Richard

Many thanks for your example. Yes, I did set LB_RESETCONTENT = 388 as you explained.

Just to make sure it still works if I update the list with new entries each time I click "Empty listbox", I modified your example as below (removing all the unwanted bits). I also set the PROC_listbox style to -2 to prevent sorting.

Just click "Empty listbox" repeatedly. This works as I expected.

Conclusion: Back to the drawing board. I need to re-examine my own code to see what I have missed.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

REM. Program to demonstrate a Dialogue Box *** MODIFIED

INSTALL @lib$+"WINLIB2"
BS_DEFPUSHBUTTON = &1
ES_AUTOHSCROLL = &80
ES_NUMBER = &2000
LB_ADDSTRING = &180
LB_RESETCONTENT = 388
LB_GETCURSEL = &188
WS_CHILD = &40000000
WS_GROUP = &20000
WS_VISIBLE = &10000000
dlg%=FN_newdialog("Dialogue box", 20, 20, 160, 128, 8, 1000)

PROC_listbox(dlg%, "", 104, 82, 40, 64, 48, -2) : REM *************** -2 FOR NO SORT

PROC_pushbutton(dlg%, "OK", 1, 12, 108, 56, 14, WS_GROUP OR BS_DEFPUSHBUTTON)
PROC_pushbutton(dlg%, "Empty listbox", 110, 92, 108, 56, 14, 0)

PROC_showdialog(dlg%)
ON CLOSE PROC_closedialog(dlg%):QUIT
ON ERROR PROC_closedialog(dlg%):PRINT'REPORT$:END

SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 0"
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 1"
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 2"
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, "Listbox item 3"

n% = 1

Click%=0
ON SYS Click% = @wparam% : RETURN
REPEAT
WAIT 1
click%=0
SWAP Click%, click%

IF click% = 110 THEN
SYS "SendDlgItemMessage", !dlg%, 104, LB_RESETCONTENT, 0, 0

REM ***** UPDATE THE LIST WITH NEW ENTRIES

FOR m% = 1 TO 6
SYS "SendDlgItemMessage", !dlg%, 104, LB_ADDSTRING, 0, STR$(n%)
n%+=1
NEXT

ENDIF


UNTIL click%=1 OR click%=2 OR !dlg%=0


IF click%=1 THEN
PRINT "OK pressed, settings were:"'

DIM text% 255

SYS "SendDlgItemMessage", !dlg%, 104, LB_GETCURSEL, 0, 0 TO sel%
PRINT "Listbox selection index was ";sel%

ELSE
PRINT "Cancel pressed"
ENDIF
PROC_closedialog(dlg%)
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
73
Ian, G3NRW
g3nrw@...

***** TS-590 Family Resources Page: http://g3nrw.net/TS-590

On 21/06/2017 22:21, Richard Russell wrote:
On Wed, Jun 21, 2017 at 12:13 pm, Ian_Wade_G3NRW wrote:

I had expected that RESETCONTENT would clear the original list
items from the display and then reset the list count, such that
next time around the first ADDSTRING entry would be first in the
list. What have I missed?

I don't think you've missed anything, your description of the action of LB_RESETCONTENT agrees with that at MSDN: "/Removes all items from a list box/". The fault is therefore likely to be in your own code. It would be worth checking that you have correctly initialised the LB_RESETCONTENT constant to the correct numeric value - it should be 388 (decimal) - but if that isn't the problem please create a minimal cut-down program that illustrates the effect and post it here (a complete self-contained program please, not just a snippet listed out of context).

I've listed below a trivial adaptation of the DLGDEMO example program to demonstrate that emptying the list box works (at least it does here).

Richard.

{SNIP]

Join bb4w@groups.io to automatically receive all group messages.