Click here to Skip to main content
15,896,063 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionreading from database Pin
aguest25-Apr-06 1:17
aguest25-Apr-06 1:17 
AnswerRe: reading from database Pin
sujtha25-Apr-06 1:30
sujtha25-Apr-06 1:30 
AnswerRe: reading from database Pin
David Crow25-Apr-06 4:50
David Crow25-Apr-06 4:50 
QuestionError loading my resources with imported dlls Pin
snir_ya25-Apr-06 0:49
snir_ya25-Apr-06 0:49 
AnswerRe: Error loading my resources with imported dlls Pin
voorugonda prashanth25-Apr-06 1:18
voorugonda prashanth25-Apr-06 1:18 
QuestionSIZING the Window Pin
RockyJames25-Apr-06 0:47
RockyJames25-Apr-06 0:47 
QuestionRe: SIZING the Window Pin
David Crow25-Apr-06 4:52
David Crow25-Apr-06 4:52 
QuestionAssert failed in wincore Pin
sujtha25-Apr-06 0:39
sujtha25-Apr-06 0:39 
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.
//
// It is dangerous to pass C++ objects from one thread to
// another, unless the objects are designed to be used in
// such a manner.
}
}

Any idea how to overcome this? Or any alternative how to show my dialog form on my newly created desktop and use my other events?

With best regards and thankx in advance.

AnswerRe: Assert failed in wincore Pin
voorugonda prashanth25-Apr-06 1:27
voorugonda prashanth25-Apr-06 1:27 
GeneralRe: Assert failed in wincore Pin
sujtha25-Apr-06 1:32
sujtha25-Apr-06 1:32 
AnswerRe: Assert failed in wincore Pin
Naveen25-Apr-06 1:35
Naveen25-Apr-06 1:35 
GeneralRe: Assert failed in wincore Pin
sujtha25-Apr-06 1:40
sujtha25-Apr-06 1:40 
GeneralRe: Assert failed in wincore Pin
Naveen25-Apr-06 1:50
Naveen25-Apr-06 1:50 
GeneralRe: Assert failed in wincore Pin
sujtha25-Apr-06 2:20
sujtha25-Apr-06 2:20 
QuestionList Control Pin
chybin25-Apr-06 0:31
chybin25-Apr-06 0:31 
AnswerRe: List Control Pin
YaronNir25-Apr-06 0:38
YaronNir25-Apr-06 0:38 
QuestionApplying filter Condition in data grid control in MFC VC++ Pin
Sriram P.S25-Apr-06 0:30
Sriram P.S25-Apr-06 0:30 
Questionhow i can capture the registry key name Pin
kiranin24-Apr-06 23:55
kiranin24-Apr-06 23:55 
AnswerRe: how i can capture the registry key name Pin
YaronNir25-Apr-06 0:03
YaronNir25-Apr-06 0:03 
GeneralRe: how i can capture the registry key name Pin
kiranin25-Apr-06 0:18
kiranin25-Apr-06 0:18 
Questionphysical memory based Pin
aaaan24-Apr-06 23:40
aaaan24-Apr-06 23:40 
AnswerRe: physical memory based Pin
Nick_Kisialiou25-Apr-06 8:48
Nick_Kisialiou25-Apr-06 8:48 
QuestionResolution of a bitmap in a .bmp file Pin
aasstt24-Apr-06 23:34
aasstt24-Apr-06 23:34 
AnswerRe: Resolution of a bitmap in a .bmp file Pin
YaronNir25-Apr-06 0:01
YaronNir25-Apr-06 0:01 
GeneralRe: Resolution of a bitmap in a .bmp file Pin
aasstt25-Apr-06 0:17
aasstt25-Apr-06 0:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.