Manipulating a ListBox from getelementID

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Manipulating a ListBox from getelementID

Post by utimagus »

Ok...I want to add an item to a listbox from an IGUIEnvironment element->getelementfromID(ID,false). How could I go about this?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

A listbox can only hold strings, not 3d nor gui elements !!!
But what you're trying to do ???
Maybe an array could help you ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
KG
Posts: 35
Joined: Wed Jun 07, 2006 12:00 am

Post by KG »

Did you try typecasting the IGUIElement as an IGUIListBox? I've never had to do that before, but I think it might work.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Check that the element returned is indeed a list box, cast it to an IGUIListBox and then call the correct list box function...

Code: Select all

IGUIElement* found= element->getElementFromID(ID, false);
if (found->getType() == EGUIET_LIST_BOX)
{
  IGUIListBox* listBox = (IGUIListBox*)found;
  listBox->addItem("hello world!");
}
If you compiled the Irrlicht library with RTTI enabled, you could use a dynamic_cast, something like this.

Code: Select all

IGUIListBox* listBox = dynamic_cast<IGUIListBox*>(element->getElementFromID(ID, false));
if (listBox)
{
  listBox->addItem("hello world!");
}
Travis
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Oh, I thought he want's to get an element and add this element to a listbox... :oops:
I was wondering why someone would do this... :lol:

Yes, a type cast should solve the problem...
Also with element->getType() you can check for EGUIET_LIST_BOX if the element really is a listbox (as Travis mentioned)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Post by utimagus »

wow..i can not believe i did not think of that... it is so elementary... oh well... but hey do you by any chance have an already compiled irrlicht.dll with your extensions by any chance? i couldn't seem to locate one on your site and am not too keen on recompiling.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well, I have not uploaded a precompiled dll, because IrrExtensions was designed for easily recompiling the dll !!! ;)

Another reason is that you can choose what extensions, lib type and drivers you want to use !!!
So you can create 100s of different dlls with it...
Also there is a difference between using GCC and MSVC (what will double the ammount of possible dll types) !!!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Post by utimagus »

I ask for it because when I try to run your extensions program it either tells me it can't find the includes (though they are with the source as per the instructions for v1.1) OR it tells me they are the wrong version (when trying with v1.2). Which is why I would like a copy of it all with all the new extension additions if possible. If not I guess I will need to figure out why this is not cooperating.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well, if you really don't get it to work I can upload a dll temporarly for you... ;)

But I think you made an common mistake with it...
You'll have to copy the include folder into the source folder (source\Irrlicht) !!!
Some people had this problem, too...
But everybody got it to work after they knew this...

In older Irrlicht versions the include folder was already there, but now you'll have to copy it there...
All this is also described in the IrrExtensions help file...

Now, give it a last try, and if you don't get it tell me if you want the dll with sound (Audiere) or not !!!
But remember if sound was included to the dll, then all your projects need to link against Audiere, too (even you don't need sound in the project)...
And if no sound was included to the dll, then the AVI-Player extension has no sound support...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Acki I think you should implement a different error for when it cant find include folder...
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Post by utimagus »

I second the error report and maybe the instructions, however the folder copy did work so I should be set and thanks again for making these extensions. Now i jsut need to figure out how to extract the slightly illegal .devpak and does this work on v1.2
Last edited by utimagus on Sun Jan 28, 2007 11:05 pm, edited 1 time in total.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

A DevPack is nothing more than a TAR archive...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Post by utimagus »

where do i place the contents of the devpack? in the source folder?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

No, you need 3 things from the archive:

1st the includes - copy them to your compilers include directory, and/or add the path to your compiler settings

2nd the libs - copy them to your compilers libs directory, and/or add the path to your compiler settings

3rd the dlls - copy them to your windows system folder (c:\windows\system32) or directly into the folder of every Irlicht project you make

This is the procedure for every sdk you want to install (like Audiere, Newton, and so on)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
utimagus
Posts: 17
Joined: Fri May 26, 2006 2:55 pm

Post by utimagus »

now i just gotta figure out why vanilla irrlicht compiles with a mess load of errors there are about 20 sets of this set of errors:

c:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C2146: syntax error : missing ';' before identifier 'PVOID64'
c:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(222) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C2146: syntax error : missing ';' before identifier 'Buffer'
c:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
c:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winnt.h(5940) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int


not sure why
Post Reply