guess no one here knows about this
I AM HAVING PROBLEMS WILLING A STRUCTURE WITH CHAR* [] and getting them back to text. When i put it in MessageBoxA() it Compiles but then it crashed at that location. When in PrintRightText() it just dont draw Anything.
Structures HERE
[PHP]struct sItem
{
char* Name;
char** Options;
int* Value;
bool Selectable;
sItem(char* NAME, char** OPTIONS, int* VALUE, bool SELECTABLE)
{
Name=NAME;
Options=OPTIONS;
Value=VALUE;
Selectable=SELECTABLE;
}
~sItem()
{}
};
typedef struct {
char* Name;
int noItems;
int totHeight;
sItem** Items;
int Selected;
} sTab;
[/PHP]
The Adding FUNCTIONS
[PHP]
void cMenu::AddTab(char* name, bool selected)
{
TABS[noTabs]->Name = name;
TABS[noTabs]->Selected = selected;
TABS[noTabs]->noItems = noTempitems;
TABS[noTabs]->totHeight = temptotHeight;
TABS[noTabs]->Items = tempItems;
noTempitems=temptotHeight=0;
this->tempItems=(sItem **)malloc(10);
for (int i=0; i<10; i++) this->tempItems[i]=(sItem *)malloc(sizeof(sItem));
noTabs++;
totHeight=(noTabs*30);
}
void cMenu::AddItem(char* Item_Name, char** Options, int* DefaultValue)
{
tempItems[noTempitems]=new sItem(Item_Name, Options, DefaultValue, true);
noTempitems++;
temptotHeight=(noTempitems*16);
}[/PHP]
FILL THE STRUCTURES HERE
[php]char* Options[] = {"WEE", "WEE1", "WEE2"};
pMenu->AddText("TEXTXY" , "HEY IT IS WORKING");
pMenu->AddItem("Item 2", Options, &A[1]);
pMenu->AddItem("Item 3", Options, &A[2]);
pMenu->AddTab("Tab 1", true);
[/PHP]
AND NOT THE DRAW STUFFY
[PHP]for (int i=0; i<this->noTabs;i++)
{
for (int o=0; o<(this->TABS[i]->noItems) ;o++)
{
int val=(this->TABS[i]->Items[o]->Value)?(*this->TABS[i]->Items[o]->Value):0;
if (this->TABS[i]->Items[o]->Options){
char* texy = this->TABS[i]->Items[o]->Options[val];
PrintRightText(pFont,posi0+3, posi1+(o*15), 0xffccccff, texy);
}
}
}[/PHP]
I just like programming, that is all.
Current Stuff:
- GPU Programmer (Cuda)
- Client/Server (Cloud Server)
- Mobile App Development
guess no one here knows about this
I just like programming, that is all.
Current Stuff:
- GPU Programmer (Cuda)
- Client/Server (Cloud Server)
- Mobile App Development
thats cuz nobody wants to help mpgh anymore LOL
there are local and global variables. using local variables is not very useful cause they are gone after the function call
i said be careful with pointers in another thread. i would use memcpy/strcpy to copy the names/text values/etc into the structure.
btw:
this only allocates memory for 10 bytes not for 10 itemsCode:this->tempItems=(sItem **)malloc(10);
Last edited by Gordon`; 01-16-2011 at 10:17 PM.
why06 (01-17-2011)
Good eye Gordon!
I see you try to allocate memory for them here, but this does not work. Your only returning a pointer to the allocated memory.
So all you ended up doing is saving pointers in those 10 bytes you allocated.Code:for (int i=0; i<10; i++) this->tempItems[i]=(sItem *)malloc(sizeof(sItem));
To delare an an array of sItem simply do it like any other data type
so for sItems it would beCode:int* intArray; intArray = new int[20]; //will create array of 20 ints
Now itemArray will point to that allocated memory.Code:sItem* itemArray; itemArray = new sItem[some_number_here];
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
topblast (01-17-2011)
I i will do that to make it little more safe, but menu Options still not working
I just like programming, that is all.
Current Stuff:
- GPU Programmer (Cuda)
- Client/Server (Cloud Server)
- Mobile App Development