I am trying to make a Visual C++ 2008 program that plots some data in a Window. I have read from various places the correct way to do this is to override WndProc. So I made a Windows Forms Application in Visual C++ 2008 Express Edition, and I added this code to Form1.h, but it won't compile:
public:
[System::Security::Permissions::PermissionSet(System::Security::Permissions::SecurityAction::Demand, Name="FullTrust")]
virtual void WndProc(Message %m) override
{
switch(m.Msg)
{
case WM_PAINT:
{
HDC hDC;
PAINTSTRUCT ps;
hDC = BeginPaint(m.HWnd, &ps);
// i'd like to insert GDI code here
EndPaint(m.Wnd, &ps);
return;
}
}
Form::WndProc(m);
}
When I try to compile this in Visual C++ 2008 Express Edition, this error occurs: error C2664: 'BeginPaint' : cannot convert parameter 1 from 'System::IntPtr' to 'HWND'
When I try using this->Handle instead of m.HWnd the same error occurs.
When I try casting m.HWnd to (HWND), this error occurs: error C2440: 'type cast' : cannot convert from 'System::IntPtr' to 'HWND'
Maybe I need to cast the m.HWnd to a pin_ptr or something.