Hi Me
The macro MAKEINTATOM yields to
(LPTSTR)((ULONG_PTR)((WORD)(225)))
Which is not quite the same, but might work in the context you mentioned.
(I'm using it with the Win32 API function LoadImage.)
The code was given and I didn't want to change it, but you're right, this is
the recommended way to do it.
Although the documentation says to use the macro MAKEINTRESOURCE which
yields to:
(LPSTR)((ULONG_PTR)((WORD)(225)))
Both LPSTR and LPTSTR are defined as char *.
Eric
"Me" <> wrote in message
news: oups.com...
> Eric wrote:
>> Hello all,
>> I've got this line of given code (cannot change this; wizard-generated,
>> but
>> value may change someday):
>> #define IDB_BUTTON 225
>>
>> Somewhere in the code I found / need this:
>> ....somefunction("#225")....
>>
>> This string in the function call is the same number like in the define,
>> but
>> the constant wasn't used. Because for future changes and for readability
>> I
>> wanted to create this string with a preprocessor macro like this:
>> ....somefunction(MYMACRO(IDB_BUTTON))....
>>
>> I didn't get such a macro to work. I tried:
>> #define MYMACRO(num) "#" #num
>> but this only yields to
>> ....somefunction("#" "IDB_BUTTON")....
>> I also tried with the token-pasting operator (##) etc.
>>
>> Is this possible at all?
>
> Yes (see the other responses to this thread) but if you're programming
> Windows like I suspect you are, you don't even need to do this, you can
> just use the MAKEINTATOM(IDB_BUTTON) macro provided in windows.h which
> does something more efficient based on a feature of the OS.
>
|