This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Listbox Control functions


Listbox Control functions

Postby redshift » Jun 22, 2004 @ 11:46pm

There are some function i create to better uderstand the behaviour of the listbox.

Theses functions are the typical one used for dealing with a listbox, why not including them in the ppl ?
This could decrease the amount of code to write by the user again :-) (probably not all but at least some, renaming them as listbox_additem, ...)

Functions: AddItem, RemoveItem, ReplaceItem, Select, GetSelected, ClearList, Load from a list, load from a file.

Some more will follow probably.

Listbox Usage:


Load an item in a listbox:

func AddItem(listbox$, editbox$)
text$ = GetText(editbox$);
where$ = SendMessage(listbox$, LB_GETCOUNT, 0, 0);
SendMessage(listbox$, LB_ADDSTRING, where$, text$);
Return(true);
end;

AddItem(LISTBOX101$,EDIT105$);


Get current selected item from a listbox:

func GetSelItem(listbox$, editbox$)
where$ = SendMessage(listbox$, LB_GETCURSEL, 0, 0);
text$ = GetItem(listbox$, where$);
SetText(editbox$, text$);
Return(true);
end;

GetSelItem(LISTBOX101$,EDIT105$);


Delete an item from a listbox:

func DelItem(listbox$)
where$ = SendMessage(listbox$, LB_GETCURSEL, 0, 0);
SendMessage(listbox$, LB_DELETESTRING, where$, 0);
Return(true);
end;

DelItem(LISTBOX101$);


Update an item in a listbox:

func UpdateItem(listbox$, editbox$)
text$ = GetText(editbox$);
where$ = SendMessage(listbox$, LB_GETCURSEL, 0, 0);
SendMessage(listbox$, LB_DELETESTRING, where$, 0);
SendMessage(listbox$, LB_INSERTSTRING, where$, text$);
//SendMessage(listbox$, LB_SETCURSEL, where$, text$); ?? is that functionnal for a replace ??
Return(true);
end;

UpdateItem(LISTBOX101$,EDIT105$);


Select All item in list:

func SelAllItem(listbox$)
where$ = SendMessage(listbox$, LB_GETCOUNT, 0, 0);
i$=0;
Repeat
SendMessage(listbox$, LB_SETSEL, i$, i$);
i$++;
Until(i$>=where$);
SendMessage(listbox$, LB_SETSEL, 1, 0);
Return (true);
end;

SelAllItem(LISTBOX101$);


Load Listbox from a list:

func list_to_listbox(listbox$, list$)
i$=0;
scount$ = Count(list$);
while (i$ < scount$)
SendMessage(listbox$, LB_ADDSTRING, i$, list$);
Next(list$);
i$++;
end;
end;

list_to_listbox(LISTBOX101$, list$);


Clear listbox content:

func ClearList(listbox$)
SendMessage(listbox$, LB_RESETCONTENT, 0, 0);
end;

ClearList(LISTBOX101$);


Load Listbox from a file:

func file_to_listbox(listbox$, Filename$)
s$ = LoadStr(Filename$, i$);
List(slist$);
StrToList (s$, "\n", slist$);
i$=0;
scount$ = Count(slist$);
while (i$ < scount$)
SendMessage(listbox$, LB_ADDSTRING, i$, slist$);
Next(slist$);
i$++;
end;
end;

file_to_listbox(LISTBOX101$, "\\My Documents\\ListBox1.txt");
redshift
pm Member
 
Posts: 52
Joined: Jun 9, 2004 @ 9:52pm


Postby kornalius » Jun 23, 2004 @ 4:01pm

Hi RedShift,

Thanx a lot for your great work. Is it possible for you put all these functions into a .ppl library for example ListLib.ppl and send it to me? I will include it in the Listbox.ppl library file.

Regards,
Kornalius
User avatar
kornalius
pm Member
 
Posts: 1704
Joined: Dec 9, 2003 @ 6:04pm
Location: Montreal, Québec, Canada


Postby redshift » Jun 23, 2004 @ 4:26pm

redshift
pm Member
 
Posts: 52
Joined: Jun 9, 2004 @ 9:52pm


Postby redshift » Jun 24, 2004 @ 12:58am

Here are the combobox and the listbox functions libs.

Regards,
Attachments
PPL_Libs.zip
ComboBox & Listbox Functions Library
(1.43 KiB) Downloaded 270 times
redshift
pm Member
 
Posts: 52
Joined: Jun 9, 2004 @ 9:52pm


Return to Pocket Programming Language (PPL)


Sort


Forum Description

Discuss this new development tool.

Moderator:

kornalius

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron