Click here to Skip to main content
15,890,186 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Write REG_MULTI_SZ value in registry Pin
Richard MacCutchan4-Oct-11 1:19
mveRichard MacCutchan4-Oct-11 1:19 
QuestionHow to disable warning popup in ActiveX Pin
Cpp_Com19-Sep-11 18:49
Cpp_Com19-Sep-11 18:49 
AnswerRe: How to disable warning popup in ActiveX Pin
KingsGambit19-Sep-11 20:19
KingsGambit19-Sep-11 20:19 
GeneralRe: How to disable warning popup in ActiveX Pin
Cpp_Com20-Sep-11 19:07
Cpp_Com20-Sep-11 19:07 
GeneralRe: How to disable warning popup in ActiveX Pin
KingsGambit20-Sep-11 20:36
KingsGambit20-Sep-11 20:36 
GeneralRe: How to disable warning popup in ActiveX Pin
Cpp_Com20-Sep-11 23:38
Cpp_Com20-Sep-11 23:38 
AnswerRe: How to disable warning popup in ActiveX Pin
Abhi Lahare3-Oct-11 6:24
Abhi Lahare3-Oct-11 6:24 
QuestionCan't call DestroyWindow in CView::OnActivateView when activated with Aero preview Pin
Member 823191212-Sep-11 15:33
Member 823191212-Sep-11 15:33 
I'm getting some very strange behavior in an MDI MFC application with tabbed views I'm working on that I can reproduce easily in any new MDI application I make (that uses tabbed views), and I can't seem to fix it. I'm using Visual Studio 2010. I made a sample application to demonstrate my problem. In my CView (in my example called CNewTestView) I override CView::OnActivateView. I can't seem to call DestroyWindow in OnActivateView, but ONLY when the view is activated by switching to it through the Windows 7 Aero Preview thumbnails. ie. When I switch to a non-active view by either clicking a tab or by pressing CTRL+Tab there are no problems at all, but when I hover the mouse over the application icon in the taskbar and then switch views by clicking on the non-active one then the problem shows up. In the application, I create 2 tabs by pressing Ctrl+N.

As an example, I made a member variable of type CEdit called CNewTestView::m_edit, in a new MFC project with tabbed MDI views, and no other code at all added or modified. Here's the code for OnActivateView:

C#
void CNewTestView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
    if (bActivate)
    {
	if (m_edit.GetSafeHwnd())
		m_edit.DestroyWindow();

	m_edit.Create(WS_VISIBLE | WS_BORDER | WS_CHILD, CRect(0,0,100,20), this, 1234);
    }

    CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}


I get an assertion in CWnd::DestroyWindow on line 1047 when the HWND of the CEdit is being looked up in the HWND map returned by the call to afxMapHWND. Here's the code in wincore.cpp where the assertion occurs:

C#
// Note that 'this' may have been deleted at this point,
        //  (but only if pWnd != NULL)
        if (pWnd != NULL)
        {
            // Should have been detached by OnNcDestroy
#ifdef _DEBUG
            ASSERT(pMap->LookupPermanent(hWndOrig) == NULL);
#endif
        }


Note that for the assertion all I get is a buzz noise to indicate the assertion, but the debugger doesn't actually break at the assertion. If I compile a Release version I still have a problem (basically I can't recreate the window, and so the application doesn't work properly). If instead I slightly delay the call to DestroyWindow, eg. if I destroy the window in CView::OnTimer after setting a timer in OnActivateView or in a message handler after calling PostMessage then there's no problem at all. Unfortunately I can't do this, since in my real application I'm developing there seems to be other calls resulting from OnActivateView that, after a long line of calls, eventually results in a call to CWnd::DestroyWindow, and the application has gotten large enough that it would be very time consuming to implement the PostMessage call to work with no assertions at all. Does anyone know what's going on?

In the example I gave above I did not add anything else at all to the empty application other than what I mentioned in this email.

Martin
AnswerRe: Can't call DestroyWindow in CView::OnActivateView when activated with Aero preview Pin
Member 823191214-Sep-11 3:22
Member 823191214-Sep-11 3:22 
GeneralRe: Can't call DestroyWindow in CView::OnActivateView when activated with Aero preview Pin
MicroVirus14-Sep-11 3:32
MicroVirus14-Sep-11 3:32 
QuestionHow to create a ActiveX document server to render a txt file Pin
shelok10-Sep-11 17:17
shelok10-Sep-11 17:17 
AnswerRe: How to create a ActiveX document server to render a txt file Pin
Richard MacCutchan10-Sep-11 21:09
mveRichard MacCutchan10-Sep-11 21:09 
GeneralRe: How to create a ActiveX document server to render a txt file Pin
shelok10-Sep-11 23:19
shelok10-Sep-11 23:19 
QuestionHow to Check the iterator is valid? Pin
jbiaojerry7-Sep-11 23:45
jbiaojerry7-Sep-11 23:45 
AnswerRe: How to Check the iterator is valid? Pin
MicroVirus8-Sep-11 4:07
MicroVirus8-Sep-11 4:07 
AnswerRe: How to Check the iterator is valid? Pin
Stephen Hewitt12-Sep-11 6:18
Stephen Hewitt12-Sep-11 6:18 
GeneralRe: How to Check the iterator is valid? Pin
jbiaojerry18-Sep-11 14:00
jbiaojerry18-Sep-11 14:00 
GeneralRe: How to Check the iterator is valid? Pin
darrendavis30-Sep-11 7:15
darrendavis30-Sep-11 7:15 
QuestionStreambuf problems Pin
Cold_Fearing_Bird6-Sep-11 20:33
Cold_Fearing_Bird6-Sep-11 20:33 
AnswerRe: Streambuf problems [modified] Pin
Orjan Westin6-Sep-11 23:24
professionalOrjan Westin6-Sep-11 23:24 
QuestionHow to use the hook function of Windows FileOpen dialog Pin
clever1015-Sep-11 21:13
clever1015-Sep-11 21:13 
AnswerRe: How to use the hook function of Windows FileOpen dialog Pin
MicroVirus6-Sep-11 1:35
MicroVirus6-Sep-11 1:35 
GeneralRe: How to use the hook function of Windows FileOpen dialog Pin
clever10110-Sep-11 1:07
clever10110-Sep-11 1:07 
QuestionMemory leak problem. Pin
sirtimid3-Sep-11 8:39
sirtimid3-Sep-11 8:39 
AnswerRe: Memory leak problem. Pin
Stephen Hewitt4-Sep-11 1:33
Stephen Hewitt4-Sep-11 1:33 

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.