Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Assert's from CExtPaintManager::CExtPaintManager() and CExtComboBoxBase::OnFilterPopupListClose() Collapse All
Subject Author Date
MUKESH GUPTA Jan 21, 2011 - 7:23 AM

We were using ProfUIS version 2.54 and have recently upgraded to the latest version 2.91.I built all the static and dll targets of 2.91 on VS2008.

I am facing 2 problems :

1. I am getting the following assert fired at line 264 and line 267 from ProfUIS291\Src\ExtPaintManager.cpp

VERIFY( m_bmpFilterApplied.LoadBMP_Resource( MAKEINTRESOURCE( IDB_EXT_BITMAP_FILTER_APPLIED ) ) ); // Line 264
VERIFY( m_bmpFilterUnApplied.LoadBMP_Resource( MAKEINTRESOURCE( IDB_EXT_BITMAP_FILTER_UNAPPLIED ) ) ); // Line 267


Here is the call stack

>    ProfUIS291md-RDE.dll!CExtPaintManager::CExtPaintManager() Line 264 + 0x35 bytes    C++
    ProfUIS291md-RDE.dll!CExtPaintManagerXP::CExtPaintManagerXP() Line 366 + 0x16 bytes    C++
    ProfUIS291md-RDE.dll!CExtPaintManager::CExtPaintManagerAutoPtr::InstallPaintManager(CExtPaintManager * pPaintManager=0x00000000) Line 1064 + 0x2f bytes    C++
    ProfUIS291md-RDE.dll!CExtPaintManager::CExtPaintManagerAutoPtr::InitPaintManagerInstance() Line 1022    C++
    ProfUIS291md-RDE.dll!CExtPaintManager::CExtPaintManagerAutoPtr::GetPM() Line 1027    C++
    ProfUIS291md-RDE.dll!CExtTabWnd::PmBridge_GetPM() Line 839 + 0x18 bytes    C++
    ProfUIS291md-RDE.dll!CExtTabWnd::_GetTabWndFont(CFont * pFont=0x0012b384, bool bSelected=false, unsigned long dwOrientation=0) Line 1042 + 0x13 bytes    C++
    ProfUIS291md-RDE.dll!CExtTabWnd::TAB_ITEM_INFO::Measure(CDC * pDcMeasure=0x0012b78c) Line 245 + 0x1d bytes    C++
    ProfUIS291md-RDE.dll!CExtTabWnd::_RecalcLayoutImpl() Line 2578 + 0x16 bytes    C++
    ProfUIS291md-RDE.dll!CExtTabWnd::UpdateTabWnd(bool bImmediate=true) Line 2147 + 0x12 bytes    C++
    ProfUIS291md-RDE.dll!CExtTabWnd::OnSize(unsigned int nType=0, int cx=236, int cy=27) Line 5029    C++

I debugged ProfUIS and found that the dll is not able to find the bitmap resource IDB_EXT_BITMAP_FILTER_APPLIED and IDB_EXT_BITMAP_FILTER_UNAPPLIED. But when i open up the ProfUIS291md-RDE.dll in VS2008 and check its content i can see the bitmaps with id 30590 (for IDB_EXT_BITMAP_FILTER_APPLIED) and 30591 (for IDB_EXT_BITMAP_FILTER_UNAPPLIED) present inside "Bitmap" resource folder.

Strangely if i go about defining __STATPROFUIS_WITH_DLLMFC__ in my project under Project->Properties->Resources->General->Preprocessor Definations and below code in my *.rc2 file it is able to find the resource and hence no assert.

// Add manually edited resources here...
#if ( !(defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__) )
#include <Resources/Resource.rc>
#endif

I think the above should be required only from ProfUSI static libraries and not dynamic libraries as static libraries cannot have resources.

Another observation is that no assert is fired in projects that are using ProfUIS291md.dll and they are able to find the resources.

What is going wrong here?

2. A second more important problem :

We had an .ocx that was using ProfUIS254ynd.lib(ascii static library).Now we have modified the project setting of .ocx to use MBCS character set and in additon use dynamic library ProfUIS291md-RDE.dll.Please note that i have also defined _PROF_UIS_FOR_REGULAR_DLL preprocessor symbol in project settings of .ocx.

We have a popup list that is part of the ocx and when we click on it , it is firing the following asserts and eventually crashing.

Assert is fired from file ProfUIS291\Src\ExtComboBox.cpp line 2101

void CExtComboBoxBase::OnFilterPopupListClose()
{
    ASSERT_VALID( this );
    if(        m_pPopupListWnd->GetSafeHwnd() != NULL
        &&    ::IsWindow( m_pPopupListWnd->m_hWnd )
        &&    m_pPopupListWnd->IsWindowVisible()
        )

        /////
        /////
}

Internally ASSERT_VALID( this ) call’s below code from from C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\wincore.cpp

        if(pMap)
        {
            ASSERT( (p = pMap->LookupPermanent(m_hWnd)) != NULL ||
                    (p = pMap->LookupTemporary(m_hWnd)) != NULL);
        }


Here is the call stack

>    mfc90d.dll!CWnd::AssertValid() Line 906 + 0x43 bytes    C++
    mfc90d.dll!AfxAssertValidObject(const CObject * pOb=0x0464d03c, const char * lpszFileName=0x06a45490, int nLine=2101) Line 107    C++
    ProfUIS291md-RDE.dll!CExtComboBoxBase::OnFilterPopupListClose() Line 2105    C++
    ProfUIS291md-RDE.dll!CExtComboBoxBase::OnHookSpyPreTranslateMessage(tagMSG * pMSG=0x0012fcf4) Line 1985 + 0x16 bytes    C++
    ProfUIS291md-RDE.dll!CExtHookSpy::HSLL_OnCallWindowProcIn(bool & bCallNextHook=true, long & lResult=0, int nCode=0, bool bMessageSentByCurrentThread=false, tagCWPSTRUCT * pMessageData=0x0012fde0) Line 1602 + 0x13 bytes    C++
    ProfUIS291md-RDE.dll!CExtHookSpy::HookSpyItem_t::SHS_HookCallWindowProcIn(int nCode=0, unsigned int wParam=0, long lParam=1244640) Line 1242 + 0x2a bytes    C++

Please guide me whats going wrong above.

Technical Support Jan 28, 2011 - 7:23 AM

The regular DLL initializes Prof-UIS state managing using the following line of code:

CExt_ProfUIS_ModuleState::InitExtension( AfxGetStaticModuleState() );
You can also make EXE module using the same state managing mechanism:
CExt_ProfUIS_ModuleState::InitExtension( AfxGetAppModuleState() );
The EXE module typically never needs to manage MFC state switching. But this can help to fix errors related to MFC state switching in loaded MFC regular DLLs.

MUKESH GUPTA Jan 27, 2011 - 8:03 AM

1. I will get back to you with a sample application.

2. I tried the code changes that you recommended in OnHookSpyPreTranslateMessage() method but the asserts are still firing.

When i debugged in __PROF_UIS_MANAGE_STATE; macro i found that in the below code g_pExternalModuleState is always NULL and so the m_pAfxState is never initialized with new AFX_MAINTAIN_STATE2.

Refer ..\ProfUISDLL\ProfUISDLL.cpp

CExt_ProfUIS_ModuleState::CExt_ProfUIS_ModuleState()
{
    m_pAfxState = NULL;
    if( g_pExternalModuleState != NULL )
        m_pAfxState = new AFX_MAINTAIN_STATE2( g_pExternalModuleState );
}


Moreover the function CExt_ProfUIS_ModuleState::InitExtension which initializes g_pExternalModuleState is called for those dll that do not have __PROF_UIS_FOR_REGULAR_DLL defined like ProfUIS291md.dll and for these dll also it is called with NULL parameter,which means g_pExternalModuleState will always be NULL.

Refer ..\ProfUISDLL\ProfUISDLL.cpp

void CExt_ProfUIS_ModuleState::InitExtension(
    AFX_MODULE_STATE * pExternalModuleState // = NULL
    )
{
    new CDynLinkLibrary( the_ProfUIS_ExtensionModule );
    g_pExternalModuleState = pExternalModuleState;
}
For ProfUIS291md-RDE.dll , InitExtension() is never called and so g_pExternalModuleState is always NULL.

With the change you sent is our real intent is to execute m_pAfxState = new AFX_MAINTAIN_STATE2( g_pExternalModuleState ); ?

Am i missing something or do i need to do something extra?

Regards.

Technical Support Jan 26, 2011 - 1:18 PM

1) This problem requires a test project which reproduces it.

2) This issue can be fixed by updating the following method:

bool CExtComboBoxBase::OnHookSpyPreTranslateMessage(
    MSG * pMSG
    )
{
__PROF_UIS_MANAGE_STATE;
    ASSERT( pMSG != NULL );
    if(        m_hWnd != NULL
        &&    ::IsWindow( m_hWnd )
        &&    ( GetStyle() & WS_VISIBLE ) != 0
        &&    (    pMSG->hwnd == m_hWnd 
            || ::IsChild( m_hWnd, pMSG->hwnd )
            || ::GetParent( m_hWnd ) == pMSG->hwnd
            )
        )
    {
        if(        pMSG->message == WM_ACTIVATEAPP    
            ||    pMSG->message == WM_CANCELMODE
            ||    pMSG->message == WM_SETFOCUS
            ||    pMSG->message == WM_KILLFOCUS
            ||    pMSG->message == WM_SYSCOMMAND
            ||    pMSG->message == WM_STYLECHANGING
            ||    pMSG->message == WM_STYLECHANGED
            ||    pMSG->message == WM_CLOSE
            ||    pMSG->message == WM_DESTROY
            ||    pMSG->message == WM_NCDESTROY
            ||    pMSG->message == WM_ENABLE
            ||    pMSG->message == WM_SIZE
            ||    pMSG->message == WM_NEXTDLGCTL
            ||    pMSG->message == WM_LBUTTONDOWN
            ||    pMSG->message == WM_RBUTTONDOWN
            ||    pMSG->message == WM_MBUTTONDOWN
            ||    CExtPopupMenuWnd::IsMenuTracking()
            ||    CExtControlBar::_DraggingGetBar() != NULL
            ||    (    (    pMSG->message == WM_WINDOWPOSCHANGING
                    ||    pMSG->message == WM_WINDOWPOSCHANGED
                    )
                    && ( ((LPWINDOWPOS)pMSG->lParam)->flags&(SWP_NOMOVE|SWP_NOSIZE) ) == 0
                )
            ||    (    ( pMSG->message == WM_ACTIVATE || pMSG->message == WM_MOUSEACTIVATE )
                &&    (! ::IsChild( m_hWnd, pMSG->hwnd ) ) 
                )
            )
        {
            OnFilterPopupListClose();
            return true;
        }
    }
    return CExtHookSpy::OnHookSpyPreTranslateMessage( pMSG );
}

MUKESH GUPTA Jan 27, 2011 - 8:21 AM

1. I will get back to you with a sample application.

2. I tried the code changes that you recommended in OnHookSpyPreTranslateMessage() method but the asserts are still firing.

When i debugged in __PROF_UIS_MANAGE_STATE; macro i found that in the below code g_pExternalModuleState is always NULL and so the m_pAfxState is never initialized with new AFX_MAINTAIN_STATE2.

Refer ..\ProfUISDLL\ProfUISDLL.cpp

CExt_ProfUIS_ModuleState::CExt_ProfUIS_ModuleState()
{
m_pAfxState = NULL;
if( g_pExternalModuleState != NULL )
m_pAfxState = new AFX_MAINTAIN_STATE2( g_pExternalModuleState );
}


Moreover the function CExt_ProfUIS_ModuleState::InitExtension which initializes g_pExternalModuleState is called for those dll that do not have __PROF_UIS_FOR_REGULAR_DLL defined like ProfUIS291md.dll and for these dll also it is called with NULL parameter,which means g_pExternalModuleState will always be NULL.

Refer ..\ProfUISDLL\ProfUISDLL.cpp

void CExt_ProfUIS_ModuleState::InitExtension(
AFX_MODULE_STATE * pExternalModuleState // = NULL
)
{
new CDynLinkLibrary( the_ProfUIS_ExtensionModule );
g_pExternalModuleState = pExternalModuleState;
}
For ProfUIS291md-RDE.dll , InitExtension() is never called and so g_pExternalModuleState is always NULL.

With the change you sent is our real intent is to execute m_pAfxState = new AFX_MAINTAIN_STATE2( g_pExternalModuleState ); ?

Am i missing something or do i need to do something extra?

Regards.