PDA

View Full Version : what is "listbox"? (UI)



Lionheart008
08-09-2008, 13:20
dear thinbasic friends:-)

good morning and I am fit again;-) the cold is flying away to the south of germany :-D

I have found the "listbox" example (scriptexamples/UI) and have the little problem, that I would like to clear the listbox items (what listed items these are?) with a) a separetely button... b) or this button should make another thing...

c) but first of all... how does the list view function?

=> d) how can I clear (Clear Items, clear String...) the selected entry of the listbox?

e) I can type in words and make the "set" button, then in the listbox I can see my entry, very nice:-)


'---Now test the message
SELECT CASE Msg

case %WM_INITDIALOG '---Message fired at the very beginning when dialog is initialized
'---This can be the right place to initialize dialog or create controls
CONTROL ADD listbox , hDlg, %List01 , vList() , 5, 20, 200, 100, 0, 0
CONTROL ADD listbox , hDlg, %List02 , vList() , 5, 20, 300, 150, 0, 0
CONTROL ADD textbox , hDlg, %Text01 , "" , 5, 5, 200, 12
CONTROL ADD textbox , hDlg, %Text02 , "add here something stupid" , 5, 5, 200, 12
control add button , hDlg, %Butt01 , "Set" , 210, 5, 30, 12
control add button , hDlg, %Butt02 , "clear" , 250, 5, 40, 14

CASE %WM_COMMAND


- Clear the item listbox, but how??? I have done nothing else than "copy" the first function of the button 01 ;-)))


case %Butt02

'---Get the text from a textbox and place into a string
control get text hdlg, %Text02 to tmpStr

'---Get the window unique ID of the control
CONTROL HANDLE hDlg, %List02 TO ID_List01

'---Get the number of items present into listbox
MaxItems = sendmessage(ID_List02, %LB_GETCOUNT, 0, 0)

'---Get current selected item (remember it start at zero position)
'CurItem = sendmessage(ID_List01, %LB_GETCURSEL, 0, 0) + 1
listbox get selected hDlg, %List02 to CurItem

'---Now delete selected item ...
sendmessage(ID_List02, %LB_DELETESTRING, CurItem - 1, 0)

'---...and insert new text in same position
sendmessage(ID_List02, %LB_INSERTSTRING, CurItem - 1, strptr(tmpStr))

end select

CASE %WM_SYSCOMMAND
SELECT CASE wParam
CASE %SC_CLOSE
CASE %SC_CLEAR
EXIT WHILE
END SELECT
first part of questions here done... want to understand how the listbox run...

best regards, lionheart after stressy dog walking ;-)

Petr Schreiber
08-09-2008, 13:47
Hi LionHeart,

a) Clear listbox items:


LISTBOX RESET hDlg, %List01



b) Not sure what you mean, could you explain more? :-[

c) Not sure what you mean, could you explain more? :-[ Listbox is not the same as Listview

d) Delete selected item
Selected one


LOCAL nPos AS LONG

...

LISTBOX GET SELECTED hDlg, %List01 TO nPos
LISTBOX DELETE hDlg, %List01, nPos



Hope it helped,
Petr

Lionheart008
08-09-2008, 14:37
dear petr, great... :-) yes, that's what I am looking for !

- sorry, I have deleted one file, or changed the name in a hurry... "list box" and "list view" has had the same content code lines in my file, my mistake... uaargh! :o

Now I have the new "list view" file copied from my thinbasic laptop folder... and make up my mind to create a new exercise... thanks, a little icecream pot for you :-D

bye, see you, lionheart

Michael Hartlef
08-09-2008, 14:55
Hi Lionheart008,

I'm glad the flew left. I hope that it didn't cross west germany allready as I sit in Leverkusen. Don't need to catch the flew here. ;D

Michael

Lionheart008
08-09-2008, 16:30
hi petr, hi michael:-)

for petr, yes, it runs! with deleting the list, great, it's important for me to learn with this one::)

michael: thank you for good wishes, but the cold came by a damned virus, I haven't sent it to leverkusen (must laugh!) , I have sent it directly way to south europe or africa... it might be better weather with more hot sun and it will destroy the virus came from russia or east europe...

I sit in bad-sooden-allendor, not so exciting little town, but nice people here

bye, Lionheart