Multi column listbox?

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Bad_Wolf
Posts: 19
Joined: Thu 05 Jul 2018, 06:00

Multi column listbox?

Post by Bad_Wolf »

Hi everybody again,

I seem to run into another problem today (the second one). I like to have a 5 column listbox but by using PROC_listbox(.....) I only have one column.

Is it possible to have multi columns in a listbox created with PROC_newdialog?

Thank you again for your time spent on my request.

Chris
Zaphod
Posts: 78
Joined: Sat 23 Jun 2018, 15:51

Re: Multi column listbox?

Post by Zaphod »

Well you could try what the manual tells you and use the LBS_MULTICOLUMN style!

Z
Bad_Wolf
Posts: 19
Joined: Thu 05 Jul 2018, 06:00

Re: Multi column listbox?

Post by Bad_Wolf »

Hello Zaphod,

Thank you very much for your reply which is very much appreciated.

I already tried your suggestion to use the "LBS_MULTICOLUMN" style but I receive an error that the variable does not exists. Then I replaced it with the value &100200 and I get a small column.

To make things more clearly I copied part of the code here :

Code: Select all

ID_output_list% = 21 REM *** Output list ***
      Xpos% = 10:Ypos% = 135 Cx% =540: Cy% = 180
      PROC_listbox(dlg%,"", ID_output_list%, Xpos%, Ypos%, Cx%, Cy%, &100200)
      REM *** End of dialog definition ***


      PROC_showdialog(dlg%)
      LB_ADDSTRING = 384
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_ADDSTRING, 0, "Listbox item 0"
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_ADDSTRING, 0, "Listbox item 1"
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_ADDSTRING, 0, "Listbox item 2"
This code comes straight out of the manual. I have 3 rows for each item. However, I want those 3 items in one row. I can't find anything how to do this.

Can you please help me again, how I can have the desired result?

Thank you again for your time spent on solving my problem, it is very much appreciated.

Chris
Bad_Wolf
Posts: 19
Joined: Thu 05 Jul 2018, 06:00

Re: Multi column listbox?

Post by Bad_Wolf »

Hi again,

I looked again to find a solution for my listbox column problem and luckily I find a working solution.

This is again part of the code :

Code: Select all

 ID_output_list% = 21 REM *** Output list ***
      Xpos% = 10:Ypos% = 135 Cx% =540: Cy% = 180
      PROC_listbox(dlg%,"", ID_output_list%, Xpos%, Ypos%, Cx%, Cy%, LBS_USETABSTOPS-LBS_SORT)
      REM *** End of dialog definition ***


      PROC_showdialog(dlg%)
      ntabs% = 2 REM *** Amount of columns you need ***
      DIM tabs{pos%(ntabs%-1)}
      tabs.pos%(0) = 80 : tabs.pos%(1) = 160 REM *** Here you setup the column positions ***
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_SETTABSTOPS, ntabs%, tabs{}

      tab$ = CHR$9
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_ADDSTRING, 0, "Loeki" + tab$ + "Lizzy"  + tab$ + "Chris"
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_ADDSTRING, 0, "Karabo"  + tab$ + "Marie" + tab$ + "Carla"
      SYS "SendDlgItemMessage", !dlg%, ID_output_list%, LB_ADDSTRING, 0, "Mpho" + tab$ + "Tsitsi" + tab$ + "One"

You also have to initialise the following variables :

Code: Select all

LB_ADDSTRING = 384
      LB_SETTABSTOPS = 402
      LBS_SORT = 2
      LBS_USETABSTOPS = &80
This gives me a listbox of 3 columns in one row.

I was looking in the wrong direction because I was thinking "spreadsheet" like, where every column in a row has their own cell. In fact in BBC basic, if you have 3 columns it is one big row divided in columns by the position of the tab stops.

This solutions will do for me.

Chris
Zaphod
Posts: 78
Joined: Sat 23 Jun 2018, 15:51

Re: Multi column listbox?

Post by Zaphod »

Glad you found a solution and the Tabbed one is the one I usually use.
To find and define the value of windows constants you need to run the "Add Windows Constants" utility that you will find on the Utilities menu most likely. You will find that LBS_MULTICOLUMN=512.

The only problem with tabbed input method is if part of the input string data is too long you will get pushed to the next tab position and the data may not be in the right column, beware.

Z
Bad_Wolf
Posts: 19
Joined: Thu 05 Jul 2018, 06:00

Re: Multi column listbox?

Post by Bad_Wolf »

Hello Zaphod,

Thank you very much for your replay and your warning about the tabbed solution for the multi column listbox.

The utility you mentioned "Add Windows Constants" doesn't work on my laptop. I always receive the error message "No room" after which it just exit. That was also the reason I didn't find out the correct value.

True when a column is too long, the tab positions shift. Most of my columns have the same length only the last column is the widest.

Wish you a very nice day and all the best.

Chris