panel.bmap per paramenter zuweisen

Posted By: Martek

panel.bmap per paramenter zuweisen - 05/01/08 21:41

Hallo allezusammen,

ich tüfltel schon eine geraume Weile an einer funktion die einen Panel erstellen soll.
Diese funktion hat einen Paramenter, das das Bild des Panels bestimmt.
Ich bekomme es aber einfach nicht gebacken, dies zum laufen zu bringen.
Hier sind meine bisherigen Versuche die alle nicht funktioniert haben:
 Code:
function add_item_small(char* bild)
{
	pan_create("flags = visible; bmap = bild;",5);
}

function add_item_small(BMAP* bild)
{
	pan_create("flags = visible; bmap = bild;",5);
}


Ich habe Bild einmal als: "item1.bmp" angegeben und einmal als item1_bmp.

Vielleicht könnt ihr mir da ja weiterhelfen
Mfg, Martek
Posted By: Uhrwerk

Re: panel.bmap per paramenter zuweisen - 05/01/08 22:24

"flags = visible; bmap = bild;" is a char array constant as you put it into "s and therefore variables within won't be recognized by the compiler. You can do it like this:
 Code:
function add_item_small(char* bild)
{
	STRING* s = str_create(""); // use a string to put things together
	str_cpy(s,"flags = visible; bmap = ");
	str_cat(s,bild);
	str_cat(s,";");
	pan_create(s,5); // Now you can create the panel
	ptr_remove(s); // dont forget to free the string.
}


Posted By: Joey

Re: panel.bmap per paramenter zuweisen - 05/01/08 22:43

 Code:
function add_item_small(char* bild)
{
    const char *panInfo = "flags = visible; bmap = ";
    char *arg = (char*)malloc(sizeof(char) * (strlen(panInfo) + strlen(bild) + 2));
    str_cpy(arg, panInfo);
    str_cat(arg, bild);
    str_cat(arg, ";\0");
    pan_create(arg, 5);
}


ich hab den code nicht getestet. du solltest allerdings dringend ein tutorial über lite-c lesen...

joey.

edit: och menno. schon wieder der.
© 2023 lite-C Forums