Type casting is basic C/C++.
You can nearly always write (TYPE)variable, except in situations where the two types have got nothing to do with each other. Like when trying to convert a custom class to an int.
In C++, there are the cast operators:
static_cast, const_cast, dynamic_cast and reinterpret_cast.
Use static_cast<TYPE>(variable) for simple casts, like casting a float to an int. Use const_cast<TYPE> (const TYPE variable) to cast away the const. This is not recommended, because const variables are not supposed to be changed. Use dynamic_cast to cast pointers to classes of a class hirarchy, like dynamic_cast<baseclass*>(childclass*) (downcast), dynamic_cast<childclass*>(baseclass*) (upcast) or dynamic_cast<baseclass1*>(baseclass2*) (crosscast).
Use reinterpret_cast to cast pointes to completly other pointers, or pointers to long or long to pointers etc.

Your question:
HWND is defined as:
struct HWND__ { int unused; };
typedef HWND__ *HWND;
Therefor you have to explicitly cast HWND to int.
To convert a handle (HWND, HDC and all the others) to a string, use
char buf[8];
itoa(buf, (long)hwnd, 16); // hexadecimal output
or (C++ clean)
itoa(buf, reinterpret_cast<long>(hwnd), 16); // also hexadecimal

I like the many types windows has, because you always know what a variable stands for.