OpenGL in a form and converting an IntPtr to a HWND
I've done quite a bit of OpenGL programming using Win32 calls to set everything up.
What I am trying to do now is setup a Form that has controls and an opengl display window.
I would also like to be able to make a MDI with an OpenGL window as well as several other types of windows in it.
Here is my problem.
I've created a form called OpenGLForm
I'm trying to doing some initializations of a window to get it ready for opengl like:
this->hDC = GetDC(this->Handle);
However, I get the error:
g:\Documents and Settings\tlann\My Documents\Visual Studio Projects\OpenGLForm\Form1.h(68): error C2664: 'GetDC' : cannot convert parameter 1 from 'System::IntPtr' to 'HWND'
I've done looking on the MSDN sight for a simple answer on converting a IntPtr to a HWND and looked through the documentation that comes with DotNet.
I haven't been able to find anything.
I next started looking throught the include files in
G:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include
to see what kind of type IntPtr and HWND is so I could possibly do some type of appropiate cast. However, I'm having a hard time finding out what the C++ types of HWND and IntPtr are.
Am I going in the complete wrong direction? Is there some simple function that should take care of this.
Instead of creating a Form should I be inheriting from a much basic class and building it up? I'm not quite sure if I'm going in the wrong direction or not.
Thanks for your help
hwnd was a long in times past, under .net i believe an oldstyle long is cast as a .net integer. next, intptr is a platform specific handle and is an OBJECT, not a Value (like hwnd....). you need to extract the Value from the Object. IntPtr has conversion features like (IntPtr.ToInt) to give back the desired 32bit integer to use for a handle in api calls.
i had the same headache and discovered it by accident.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center