|
Generally speaking, in MFC, the CWnd object pointer cannot be passed across threads. Because each thread has its own internal map, the map records the HWND and the corresponding CWnd object. When a CWnd object is created, its HWND and CWnd object pointers will be recorded in the map of the thread, but the maps of other threads are not recorded.
When passing CWnd pointers across threads and calling certain functions of CWnd, these functions will perform a validity check, that is, check the map, because there is no corresponding record in the map, an error will be reported. Usually this error is AsserValid(this)
Therefore, to pass parameters across threads in MFC, it is better to pass the handle HWND instead of the CWnd object pointer. |
|