View Full Version : ListBox component
rickh57
10-15-2006, 06:18 PM
I'm trying to use the listbox component. I'm having problems populating it using ListBox_LoadFromList, ListBox_Add, and ListBox_LoadFromFile. None of these seem to add items. Below is some of the code that I've tried. (This is using version 1.05 Lite) What am I doing wrong? The VisitorPlayers component is the only thing on the form.
#include "swapi.ppl"
proc populateBox
ShowMessage("populateBox(): Entry");
list(l$);
for(i$, 0, 5)
playerName$ = "Player #" + i$;
Add(l$);
l$ = playerName$;
end;
ListBox_LoadFromList(VisitorPlayers$, l$);
ShowMessage("Number of items is " + ListBox_Count(VisitorPlayers$));
ShowMessage("populateBox(): Exit");
end;
proc populateBox2
ShowMessage("populateBox2(): Entry");
for(i$, 0, 5)
playerName$ = "Player #" + i$;
ListBox_Add(VisitorPlayers$, playerName$);
end;
ShowMessage("Number of items is " + ListBox_Count(VisitorPlayers$));
ShowMessage("populateBox2(): Exit");
end;
proc populateBox3
file$ = "c:\\Source\\ppl\\listbox.txt";
ShowMessage("populateBox3(): Entry, file is " + file$);
ListBox_LoadFromFile(VisitorPlayers$, file$);
ShowMessage("Number of items is " + ListBox_Count(VisitorPlayers$));
ShowMessage("populateBox3(): Exit");
end;
func VistorPlayers_OnCreate(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
// populateBox;
// populateBox2;
populateBox3;
return (true);
end;
kornalius
10-15-2006, 09:05 PM
Hi Rick,
Make sure VisitorPlayers$ is global and that it is containing a valid value. The ListBox functions should work no problem. I will do a quick little test a monday to make sure and I'll get back to you.
rickh57
10-17-2006, 06:47 PM
How do I make sure that the VisitorPlayer$ contains a valid value? I've used the swapi library with editboxes and it worked fine without any extra validation code. (I did the Global(VisitorPlayer$) but that made no difference).
kornalius
10-17-2006, 07:35 PM
Is this only on PocketPC or PC too?
I tried it here and it worked fine.
PointOfLight
10-17-2006, 08:08 PM
I tried this on the PC side and it worked fine. In addition to Kornalius' question, did you happen to change any of the LBS_ properties?
rickh57
10-17-2006, 09:07 PM
This is on the PC (so far). I didn't change any LBS_ properties...
kornalius
10-17-2006, 09:09 PM
Send us your whole program. We cannot see what is wrong with the code you sent so far. It looks alright to us.
The whole form would be great to have (.frm file). Did you use the visual form builder or you've built the form and controls yourself manually by coding?
rickh57
10-18-2006, 04:13 AM
I created it using the visual form builder. Attached is the form. (in a zip archive)[br]1161141191_71_FT783_tester.zip
bmanske
10-18-2006, 05:56 PM
Rick,</p>
The main reason that this doesn't work is that you used "VisitorPlayers$" in your code, but on the form you named the control with a missing "i" so it says "VistorPlayers".</p>
I'm attaching the new version of the form.* I ended up changing the structure a little while I was searching for the problem and I thought maybe you'd like to see how I do things.* </p>
The first thing I suspected was your use of the OnCreate event for the ListBox.* I believe the control has to be fully created befor you can populate it, but I didn't confirm this.* I took the code from that event and put it on the creation section of the form.* This is code that runs after the controls are created.</p>
Then I took the code from the On Create event that had your procedures and I put them in the Initialization section of the form.* This is code that can be used on the form but isn't really in a handler.* When making larger programs I usually put this code in another file and just use an include in the initialization section.</p>
Then I found the name problem...</p>
Then things got interesting... Kornalius, here is a bug for you... When creating the form, the default menu entry*(File-Exit) is created as a Func.* You had deleted this so I tried to add this handler back in and the handler was created as a Proc.* Once I changed it to a Func it worked.</p>
Kornalius, can you check the menu handler creation for "Proc" and change it to "Func"?</p>
Brad</p>[br]1161190446_5_FT783_tester.zip [/html]
PointOfLight
10-18-2006, 06:06 PM
bmanske, you can populate elements in their OnCreate event. When I did my ListBox test I used the OnCreate event to simulate what rickh57 was doing, and it worked fine.
rickh57
10-18-2006, 06:11 PM
Thanks for your help... I'd think after all my years of development that I would have noticed the difference. B) Having some type of lint or syntax checker to find these type of errors would be nice in some future version of PPL! :D
kornalius
10-18-2006, 06:43 PM
Hi Brad,
The Proc Menu... has been fixed in a previous version of the PIDE. It is Func now.
Does VFB still uses Proc?
kornalius
10-18-2006, 07:02 PM
In version 1.04 to be exact.
bmanske
10-18-2006, 09:07 PM
Kornalius, Woops! I've still got 1.03... sorry!
Thanks Eric, I was unsure on this.
kornalius
10-18-2006, 09:32 PM
Btw Brad, I just found out a little problem with the menu editor code. So technically it's not 100% fixed yet. It will be in 1.06 promessed.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.