Hi guys,
I want a function to loop through a Gui buttons checking if one of them has a given graphic.
If so, switch the graphic with a second given graphic, for a sort of 'what-to-do-notepad-GUI'
with a better look than a GUI list box.
Here's my code
function Assegna_appunto(int imagineA, int imagineB)
{
int i=0;
Button *bottone[30]; //Max number of buttons allowed in one GUI
while(i<=gBlocco.ControlCount)
{
if(bottone[i].Graphic==imagineA)
{
gBlocco.Visible=true;Wait(40);
bottone[i].NormalGraphic=imagineB;Wait(40);
gBlocco.Visible=false;
}
else i++;
}
}
But when the game calls the function I receive a 'null pointer referenced'.
What exactly am I doing wrong?
Thanks in advance.
EDIT:
Meanwhile I brainstormed and came up with this working code:
function Assegna_appunto(int immagineA, int immagineB)
{
int i;
while(i<gBlocco.ControlCount)
{
if(gBlocco.Controls[i].AsButton.Graphic==immagineA)
{
gBlocco.Visible=true;Wait(40);
gBlocco.Controls[i].AsButton.NormalGraphic=immagineB;Wait(80);
gBlocco.Visible=false;
return;
}
else i++;
}
}
Cheers