Joe said:
I need to cast the correct way
No, you probably don't.
HMENU mymenu;
int stuff;
...
stuff=(int)(long)(HMENU)mymenu;
...
Currently it work, but my compiler is issueing warnings. In above
example the mymenu -variable never exceed values 0 - 32000 allthough
it is a HMENU type.
Furthermore I am getting warnings from comparisons:
...
if ( (HMENU)(int)stuff==(int)(long)(HMENU)mymenu )
...
Again it works but is non-standard casting. I'd like to get rid of warning
though.
Close your eyes; you won't see the warning.

}
What warning is your compiler giving you? Don't summarize or
paraphrase it; copy-and-paste the *exact* warning message.
*Most* casts are unnecessary. Programmers (too) often add casts to
silence compiler warnings. This is like putting a piece of tape over
the red warning light on your car's dashboard; the warning is gone,
but the problem is still there.
I have no idea what an HMENU is. If it's an arithmetic type, you can
do this:
HMENU mymenu;
int stuff;
... /* presumably mymenu is assigned a value */
stuff = mymenu;
Looking at your assignment:
stuff=(int)(long)(HMENU)mymenu;
mymenu is already of type HMENU, so casting it (i.e., explicitly
converting it) to HMENU is useless. Converting from HMENU to long
might be a sensible thing to do, but converting from HMENU to long to
int doesn't make much sense; you might as well convert directly from
HMENU to int. Finally, stuff is of type int, so if HMENU is an
arithmetic type, it will be converted implicitly; the cast is not
necessary.
If HMENU is *not* of an arithmetic type, then it may be of a pointer
type. Converting a pointer to an integer is allowed, and generally
requires an explicit cast operator, but it's rarely a good idea.
*If* that's what you really want to do, then the way to do it is:
stuff = (int)mymenu;
but the result is implementation-specific, and likely to be
meaningless.
However HMENU is defined, you should consider carefully whether you
want to assign an HMENU value to an int object. I suspect that HMENU
is intended to be an abstract type, with whatever software package
provides the time providing all the operations you need to perform on
it. What are you planning to do with "stuff" after you assign the
value of mymenu to it?
I think you're probably committing a classic new programmer's mistake.
You're trying to pound a nail with a screwdriver, and the handles keep
breaking, so you ask how to strengthen a screwdriver's handle. We can
suggest various ways to do that, but we can be a *lot* more helpful if
you ask us how to pound a nail.
A bit of Googling indicates that HMENU is probably a Windows-specific
typedef. If you want to know how to work with HMENUs, consult your
documentation or post to a Windows-specific newsgroup.