Reputation: 3736
I am working on a MFC project with Kinect that uses a FPS counter. This is a static text. I want this FPS counter to be editted by a method which is also responsible for make the kinect images. So in my main I pass the HWND on to my kinect object like this:
kinect->initialize(this->GetSafeHwnd());
In my kinect object this thing gets saved:
this->hwnd = hWnd;
and then this piece of code to initialize the Static Text I want to use:
CStatic * MFC_ecFPSCOLOR;
MFC_ecFPSCOLOR = (CStatic *) GetDlgItem(hWnd, TC_FPSCOLOR);
And then I want to use it:
MFC_ecFPSCOLOR->SetWindowTextW(L"TEST");
And here it goes wrong:
Unhandled exception at 0x54431C19 (mfc110ud.dll) in KinectMain.exe: 0xC0000005: Access violation reading location 0x0031004C.
Can someone point me in the right direction?
Upvotes: 0
Views: 876
Reputation: 308402
You're using the wrong version of GetDlgItem
, it returns a handle and not a CWnd*
. The cast is hiding the error from you.
Upvotes: 3