Assert failed in wincore
-
Hi I have created an MFC application which on perticular event creates new desktop using CreateDesktop() functions and then switches to new desktop using SwitchDesktop() function. Also I have used SetThreadDesktop() function to set the current(newly created) desktop as the current one. Now I have inserted one new dialog from Menu Insert->Resources. And created new class for it, Say CMyDlg. Now after creating new desktop I switch to that new desktop and try to show my dialog over there in this way. // hDesk is my newly created desktop's Handle. bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); CWnd *MyWindow; MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg(MyWindow); dlg.DoModal(); Here it shows the new dialog form on my new desktop, but when I try to move my mouse or try to click any button that I have created, it shows assertions and fails. It shows following error.....saying error in WINCORE.cpp void CWnd::AssertValid() const { if (m_hWnd == NULL) return; // null (unattached) windows are valid // check for special wnd??? values ASSERT(HWND_TOP == NULL); // same as desktop if (m_hWnd == HWND_BOTTOM) ASSERT(this == &CWnd::wndBottom); else if (m_hWnd == HWND_TOPMOST) ASSERT(this == &CWnd::wndTopMost); else if (m_hWnd == HWND_NOTOPMOST) ASSERT(this == &CWnd::wndNoTopMost); else { // should be a normal window ASSERT(::IsWindow(m_hWnd)); // should also be in the permanent or temporary handle map CHandleMap* pMap = afxMapHWND(); ASSERT(pMap != NULL); CObject* p; ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL || (p = pMap->LookupTemporary(m_hWnd)) != NULL); ASSERT((CWnd*)p == this); // must be us // Note: if either of the above asserts fire and you are // writing a multithreaded application, it is likely that // you have passed a C++ object from one thread to another // and have used that object in a way that was not intended. // (only simple inline wrapper functions should be used) // // In general, CWnd objects should be passed by HWND from // one thread to another. The receiving thread can wrap // the HWND with a CWnd object by using CWnd::FromHandle. //
-
Hi I have created an MFC application which on perticular event creates new desktop using CreateDesktop() functions and then switches to new desktop using SwitchDesktop() function. Also I have used SetThreadDesktop() function to set the current(newly created) desktop as the current one. Now I have inserted one new dialog from Menu Insert->Resources. And created new class for it, Say CMyDlg. Now after creating new desktop I switch to that new desktop and try to show my dialog over there in this way. // hDesk is my newly created desktop's Handle. bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); CWnd *MyWindow; MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg(MyWindow); dlg.DoModal(); Here it shows the new dialog form on my new desktop, but when I try to move my mouse or try to click any button that I have created, it shows assertions and fails. It shows following error.....saying error in WINCORE.cpp void CWnd::AssertValid() const { if (m_hWnd == NULL) return; // null (unattached) windows are valid // check for special wnd??? values ASSERT(HWND_TOP == NULL); // same as desktop if (m_hWnd == HWND_BOTTOM) ASSERT(this == &CWnd::wndBottom); else if (m_hWnd == HWND_TOPMOST) ASSERT(this == &CWnd::wndTopMost); else if (m_hWnd == HWND_NOTOPMOST) ASSERT(this == &CWnd::wndNoTopMost); else { // should be a normal window ASSERT(::IsWindow(m_hWnd)); // should also be in the permanent or temporary handle map CHandleMap* pMap = afxMapHWND(); ASSERT(pMap != NULL); CObject* p; ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL || (p = pMap->LookupTemporary(m_hWnd)) != NULL); ASSERT((CWnd*)p == this); // must be us // Note: if either of the above asserts fire and you are // writing a multithreaded application, it is likely that // you have passed a C++ object from one thread to another // and have used that object in a way that was not intended. // (only simple inline wrapper functions should be used) // // In general, CWnd objects should be passed by HWND from // one thread to another. The receiving thread can wrap // the HWND with a CWnd object by using CWnd::FromHandle. //
do u got the solution?
-
do u got the solution?
-
Hi I have created an MFC application which on perticular event creates new desktop using CreateDesktop() functions and then switches to new desktop using SwitchDesktop() function. Also I have used SetThreadDesktop() function to set the current(newly created) desktop as the current one. Now I have inserted one new dialog from Menu Insert->Resources. And created new class for it, Say CMyDlg. Now after creating new desktop I switch to that new desktop and try to show my dialog over there in this way. // hDesk is my newly created desktop's Handle. bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); CWnd *MyWindow; MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg(MyWindow); dlg.DoModal(); Here it shows the new dialog form on my new desktop, but when I try to move my mouse or try to click any button that I have created, it shows assertions and fails. It shows following error.....saying error in WINCORE.cpp void CWnd::AssertValid() const { if (m_hWnd == NULL) return; // null (unattached) windows are valid // check for special wnd??? values ASSERT(HWND_TOP == NULL); // same as desktop if (m_hWnd == HWND_BOTTOM) ASSERT(this == &CWnd::wndBottom); else if (m_hWnd == HWND_TOPMOST) ASSERT(this == &CWnd::wndTopMost); else if (m_hWnd == HWND_NOTOPMOST) ASSERT(this == &CWnd::wndNoTopMost); else { // should be a normal window ASSERT(::IsWindow(m_hWnd)); // should also be in the permanent or temporary handle map CHandleMap* pMap = afxMapHWND(); ASSERT(pMap != NULL); CObject* p; ASSERT((p = pMap->LookupPermanent(m_hWnd)) != NULL || (p = pMap->LookupTemporary(m_hWnd)) != NULL); ASSERT((CWnd*)p == this); // must be us // Note: if either of the above asserts fire and you are // writing a multithreaded application, it is likely that // you have passed a C++ object from one thread to another // and have used that object in a way that was not intended. // (only simple inline wrapper functions should be used) // // In general, CWnd objects should be passed by HWND from // one thread to another. The receiving thread can wrap // the HWND with a CWnd object by using CWnd::FromHandle. //
-
The MSDN says The SetThreadDesktop function will fail if the calling thread has any windows or hooks on its current desktop (unless the hDesktop parameter is a handle to the current desktop). did u checked that ? nave
Instead of using this handle i used Current window handle ie CMyDlg dlg(AfxGetMainWnd()); or CMyDlg dlg(this); dlg.DoModal(); Same assertion occurs bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); CWnd *MyWindow; MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg(MyWindow); dlg.DoModal();
-
Instead of using this handle i used Current window handle ie CMyDlg dlg(AfxGetMainWnd()); or CMyDlg dlg(this); dlg.DoModal(); Same assertion occurs bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); CWnd *MyWindow; MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg(MyWindow); dlg.DoModal();
No.. thats not the problem... For u to display a dialog in another desktop...First create a new thread. Then write the above the code in that thread function...
bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); //no need of all this CWnd *MyWindow; ////no need of all this MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg; dlg.DoModal();
plz check if this is working..Also let me know the result nave -
No.. thats not the problem... For u to display a dialog in another desktop...First create a new thread. Then write the above the code in that thread function...
bRes = SetThreadDesktop(hDesk); hWnd = GetDesktopWindow(); //no need of all this CWnd *MyWindow; ////no need of all this MyWindow = CWnd::FromHandle(hWnd); CMyDlg dlg; dlg.DoModal();
plz check if this is working..Also let me know the result nave