Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > preprocessor q: impossible macro?

Reply
Thread Tools

preprocessor q: impossible macro?

 
 
Eric
Guest
Posts: n/a
 
      07-19-2005
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.
>



 
Reply With Quote
 
 
 
 
Eric
Guest
Posts: n/a
 
      07-19-2005
Hi Heinz

Thanks for your feedback. See my answer to "Me" above.
You're right, I'll take the MAKEINTRESOURCE macro to resolve this problem.

Eric

"Heinz Ozwirk" <> wrote in message
news:42dcb8c6$0$20133$...
> "Eric" <> schrieb im Newsbeitrag
> news:dbgt23$f33$...
>> 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")....

>
> If those defines and functions are what I think they are, you should have
> a look at MAKEINTRESOURCE in your compiler's/API's documentation.
>
> Heinz
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
impossible to delete file because it is impossible to take ownership Devvie Nuis Computer Support 21 04-20-2009 02:07 AM
Making the simple impossible and the impossible unthinkable... xfx.publishing@gmail.com Perl Misc 5 06-30-2006 11:50 AM
preprocessor q: impossible macro? Eric C Programming 21 07-19-2005 12:47 PM
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57