A
Andrew Moore
Hi All,
I have a managed C++ class that makes calls into the Win32 API. I
specifically am trying to take a Handle from a .NET form and convert it to a
HWND to pass to a Win32 functions. The code works properly but I get the
following compiler warning:
warning C4312: 'reinterpret_cast' : conversion from 'int' to 'HWND' of
greater size.
My code looks like the following:
void MyCPlusPlusFunc(System::IntPtr hwnd)
{
::MessageBox(reinterpret_cast<HWND> (hwnd.ToInt32()), "Some text",
"Caption",
MB_ICONEXCLAMATION | MB_APPLMODAL);
}
void CSharpFunc()
{
System.Windows.Forms.Form f;
MyCPlusPlusFunc(f.Handle);
}
The size of int and HWND are both 4 bytes. Is there a way to get this to
work without the compiler warnings?
Thanks for your help.
Andrew
c:\Arena3D\v1.0.0.260(AVI)\AVIGenerator\AVIGenerator.h(217) : warning C4312:
'reinterpret_cast' : conversion from 'int' to 'HWND' of greater size
I have a managed C++ class that makes calls into the Win32 API. I
specifically am trying to take a Handle from a .NET form and convert it to a
HWND to pass to a Win32 functions. The code works properly but I get the
following compiler warning:
warning C4312: 'reinterpret_cast' : conversion from 'int' to 'HWND' of
greater size.
My code looks like the following:
void MyCPlusPlusFunc(System::IntPtr hwnd)
{
::MessageBox(reinterpret_cast<HWND> (hwnd.ToInt32()), "Some text",
"Caption",
MB_ICONEXCLAMATION | MB_APPLMODAL);
}
void CSharpFunc()
{
System.Windows.Forms.Form f;
MyCPlusPlusFunc(f.Handle);
}
The size of int and HWND are both 4 bytes. Is there a way to get this to
work without the compiler warnings?
Thanks for your help.
Andrew
c:\Arena3D\v1.0.0.260(AVI)\AVIGenerator\AVIGenerator.h(217) : warning C4312:
'reinterpret_cast' : conversion from 'int' to 'HWND' of greater size