Handle maps
-
Hi, I'm having trouble with handle maps. I've been reading some information about the topic but I don't see how it applies to the problem I'm having. Basically I have a class that represents a camera. It's a wrapper for API calls to set properties and capture images. The camera class also has a modeless dialog box as one of its members to display camera properties to the user. The dialog is created and exists for the lifetime of the camera class and there are function to show/hide it. For some reason the following fails
bool MultipleCameraWrapper::SetShutter(int nShutter) { ... //update the dialog this->m_pConfigDlg->m_nShutter = nShutter; this->m_pConfigDlg->UpdateData(FALSE); //FAIL! }
More specifically CHandleMap* pMap = afxMapHWND(); returns NULL inside UpdateData(). Can someone tell me why and how to fix it? -
Hi, I'm having trouble with handle maps. I've been reading some information about the topic but I don't see how it applies to the problem I'm having. Basically I have a class that represents a camera. It's a wrapper for API calls to set properties and capture images. The camera class also has a modeless dialog box as one of its members to display camera properties to the user. The dialog is created and exists for the lifetime of the camera class and there are function to show/hide it. For some reason the following fails
bool MultipleCameraWrapper::SetShutter(int nShutter) { ... //update the dialog this->m_pConfigDlg->m_nShutter = nShutter; this->m_pConfigDlg->UpdateData(FALSE); //FAIL! }
More specifically CHandleMap* pMap = afxMapHWND(); returns NULL inside UpdateData(). Can someone tell me why and how to fix it?Are you calling it from a different thread than the one that created it? Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Are you calling it from a different thread than the one that created it? Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Well then that's the problem. MFC stores handles in Thread Local Storage, so they aren't available from another thread. It's not a good idea to update the UI from another thread anyway (http://www.codeproject.com/csharp/begininvoke.asp[^]. I'd suggest posting a message to the UI instead (using PostMessage) and handling the message there. Regards Senthil _____________________________ My Blog | My Articles | WinMacro