It is safe, because WPARAM
is defined as:
typedef UINT_PTR WPARAM;
and _PTR suffix means the type is big enough to hold a pointer.
while HWND is:
typedef HANDLE HWND;
where HANDLE is:
typedef void *HANDLE;
so size of void* and UINT_PTR are always the same. If you would store it in 64bit application and try read in 32 bit application, then you would get in trouble.
if you are still concenred if that is safe to do such casts, you can search Visual Studio sources (in C:\Program Files (x86)\Microsoft Visual Studio 8\ folder), and you will find lots of lines with reinterpret_cast<LPARAM>(...)
and reinterpret_cast<WPARAM>(...)
.