Thread: HELP regarding m_pCtrlSite

  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    205

    HELP regarding m_pCtrlSite

    Hi,
    I just noticed an error occuring constantly namely:
    First-chance exception at 0x00fd9a11 (mfc71d.dll) in IViewRemote.exe: 0xC0000005: Access violation reading location 0xcdcdcdcd.

    I tracked it down to a function:
    Code:
    void CWnd::SetWindowText(LPCTSTR lpszString)
    {
    	ASSERT(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
    
    	if (m_pCtrlSite == NULL)
    		::SetWindowText(m_hWnd, lpszString);
    	else
    		m_pCtrlSite->SetWindowText(lpszString);
    }
    It seems that the function works when m_pCtrlSite is not set, it works properly but when it is, the program causes an exception and crashes. I would really appreciate some insight into why that would happen. Thanks a lot,
    Amish

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Post the code that initializes m_pCtrlSite.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    The problem is my code does not touch m_pCtrlSite at all so I don't know where or when it is being set. The piece of code above is found in winocc.cpp. Thanks for any help,
    Amish

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    I see.

    Describe your application especially the window that causes the crash. Have you looked at the stack during debugging?

    Kuphryn

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Try call AfxEnableControlContainer() in your app's InitInstance

  6. #6
    Registered User
    Join Date
    Dec 2004
    Posts
    205
    I have an MDI application with two views. Each view opens up a modeless dialog which contains various buttons and controls. One such control is a static text that is supposed to be updated as video is stored on the hard disk. To do that, the following function calls are made:
    Code:
    static CWnd* pLabel = NULL;
    pLabel = CWnd::FromHandle(hwnd)->GetDlgItem(IDC_FREE_LABEL);
    CString	freeLabel;
    CString percentLabel;
    freeLabel.LoadString(IDS_MSG_FREE_PCT);
    percentLabel.Format("%d", freePercentage);
    freeLabel = percentLabel + freeLabel;
    pLabel->SetWindowText(freeLabel);
    The SetWindowText(freeLabel) causes the program to crash. I did try going up the call stack but it just points me to the function containing the aboce code. Thanks a lot,
    Amish

  7. #7
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    persistent m_pCtrlSite ASSERTION solution

    I am developing an MFC dialog with VC6 and started receiving
    this nasty assertion after adding a slider control. I went back to
    previous versions but the app continued to bomb out on the destruction
    of other dialog controls when exiting app. The program hangs on checking
    the m_pCtrlSite != NULL conditional in one of the windows containers.

    I fixed the problem by just adding a do-nothing destructor to the main
    dialog class:

    CA2D_ConsoleDlg::~CA2D_ConsoleDlg()
    {
    return;
    }


    Don't know if this is Kosher, but it seems to work.

    /curleyj

Popular pages Recent additions subscribe to a feed