Can anyone suggest a way to do MAKEINTRESOURCE ?

BlitzMax Forums/BlitzMax Programming/Can anyone suggest a way to do MAKEINTRESOURCE ?

skn3(Posted 2005) [#1]
MAKEINTRESOURCE

I have tried alot of things, with no luck.

Oh and I should say, I need to keep the string in C string format. Currently the function that the created string gets passed to is extern with a param type of $z (cstring).


skidracer(Posted 2005) [#2]
I would try changing the parameter type to byte ptr and then cast your short resource id like so, you might infact be able to leave the type as $z, dunno:

hicon=LoadIcon(hinstance,byte ptr(101))


skn3(Posted 2005) [#3]
I had tried byte ptr and it had worked. Unfortunatly it is not really a solution as it would mean you could not pass a bmax string to the function

"unable to convert String to byte ptr"

Also bmax doesn't autocast pointers so passing byte ptr to $z gets..

"unable to convert byte ptr to CString"


skn3(Posted 2005) [#4]
Wow I did better than I expected. I don't really use C much so it was like walkin around in the dark.

filename "makeintresource.c"
#ifdef __cplusplus
extern "C"{
#endif

//macros
#define MAKEINTRESOURCE(i) (char*)((long)((short)(i)))

//functions
void *bbMAKEINTRESOURCE( short resource ){
    return MAKEINTRESOURCE(resource);
}


Tell me if that is correct or not (It works perfectly just dunno if its doing any harm)

The bmax code to use it is:
Import "makeintresource.c"

Extern
	Function MAKEINTRESOURCE$z(resource:short) = "bbMAKEINTRESOURCE"
End Extern



skn3(Posted 2005) [#5]
.