Gentlemen,
I had my application compiled using Prof_UI trial version 2.23. It was running OK except the location of my toolbars were not remembered properly. I looked into your website and realized that it was a bug and fix was available in V2.24+.
I recently purchased V2.25 and compiled my application with it in UNICODE. But, it gives an ASSERT fail when the following function is called:
if( !CExtCustomizeSite::EnableCustomization( this ) )
Any suggestions ? I have attached the entire code of OnCreate() function of MainFrame.cpp file. Your advice for the fix would be highly appreciated.
Thanks,
Saroj
--------------------------------------------------------------
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Create the splash window and display the activities while the system is busy loading
// configuration and other data
CSimpleSplashWnd _splash(
this, IDB_BITMAP_SPLASH );
_splash.SetStatusText(_T("Initializing Optiview System...Please wait..."));
HINSTANCE hInstResource = AfxFindResourceHandle(MAKEINTRESOURCE( IDR_MAINFRAME ), RT_GROUP_ICON );
ASSERT( hInstResource != NULL );
HICON hIcon = (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE( IDR_MAINFRAME ), IMAGE_ICON, 16, 16, 0 );
ASSERT( hIcon != NULL );
SetIcon( hIcon, FALSE );
CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );
hIcon = pApp->LoadIcon(IDR_MAINFRAME);
ASSERT( hIcon != NULL );
SetIcon( hIcon, TRUE );
ASSERT( pApp->m_pszRegistryKey != NULL );
ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );
ASSERT( pApp->m_pszProfileName != NULL );
ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );
ASSERT( pApp->m_pszProfileName != NULL );
g_CmdManager->ProfileSetup(pApp->m_pszProfileName, GetSafeHwnd() );
VERIFY(g_CmdManager->UpdateFromMenu(pApp->m_pszProfileName, IDR_MAINFRAME) );
VERIFY(g_CmdManager->UpdateFromMenu(pApp->m_pszProfileName, IDR_DRAWCLTYPE) );
VERIFY(g_CmdManager->UpdateFromMenu(pApp->m_pszProfileName, IDR_MENU_IMAGE_PROCESSING1) );
VERIFY(g_CmdManager->UpdateFromToolBar(pApp->m_pszProfileName, IDR_TOOLBAR_HELPER_ICONS) );
VERIFY(g_CmdManager->UpdateFromToolBar(pApp->m_pszProfileName, IDR_TOOLBAR_IMAGE_ROTATE) );
m_wndMenuBar.SetMdiWindowPopupName( _T("Window") );
if( !m_wndMenuBar.Create(NULL, this, ID_VIEW_MENUBAR) )
{
TRACE0("Failed to create menubar\n");
return -1; // failed to create
}
if( !m_wndToolBarStandard.Create(NULL, this, AFX_IDW_TOOLBAR ) || !m_wndToolBarStandard.LoadToolBar(IDR_MAINFRAME) )
{
TRACE0("Failed to create standard toolbar\n");
return -1; // fail to create
}
// Create the list tree view and add dummy values
// **********************************************************************
m_wndResizableBarTree.SetInitDesiredSizeVertical(CSize( 200, 400 ) );
m_wndResizableBarTree.SetInitDesiredSizeHorizontal(CSize( 400, 200 ) );
if( !m_wndResizableBarTree.Create(NULL, this, ID_VIEW_RESIZABLEBAR_TREE) )
{
TRACE0("Failed to create m_wndResizableBarTree\n");
return -1; // fail to create
}
if( !m_wndDockedCtrlTree.Create(
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL
| TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT
| TVS_INFOTIP | TVS_DISABLEDRAGDROP
| TVS_SINGLEEXPAND | TVS_SHOWSELALWAYS
,
CRect(0,0,0,0),
&m_wndResizableBarTree,
m_wndResizableBarTree.GetDlgCtrlID()
)
)
{
TRACE0("Failed to create m_wndDockedCtrlEdit\n");
return -1; // fail to create
}
m_wndDockedCtrlTree.SetFont( CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT)) );
for( int nTreeIdx0 = 0; nTreeIdx0 < 10; nTreeIdx0++ )
{
CString sTreeItemText;
sTreeItemText.Format( _T("Item 1-%d"), nTreeIdx0+1 );
HTREEITEM htiAtLevel0 = m_wndDockedCtrlTree.InsertItem( LPCTSTR(sTreeItemText) );
ASSERT( htiAtLevel0 != NULL );
for( int nTreeIdx1 = 0; nTreeIdx1 < 5; nTreeIdx1++ )
{
sTreeItemText.Format( _T("Item 2-%d"), nTreeIdx1+1 );
HTREEITEM htiAtLevel1 = m_wndDockedCtrlTree.InsertItem( LPCTSTR(sTreeItemText), htiAtLevel0 );
ASSERT( htiAtLevel1 != NULL );
for( int nTreeIdx2=0; nTreeIdx2<3; nTreeIdx2++ )
{
sTreeItemText.Format( _T("Item 3-%d"), nTreeIdx2+1 );
HTREEITEM htiAtLevel2 = m_wndDockedCtrlTree.InsertItem( LPCTSTR(sTreeItemText), htiAtLevel1 );
ASSERT( htiAtLevel2 != NULL );
htiAtLevel2;
}
// for( int nTreeIdx2=0; nTreeIdx2<5; nTreeIdx2++ )
}
// for( int nTreeIdx1=0; nTreeIdx1<5; nTreeIdx1++ )
}
// for( int nTreeIdx0=0; nTreeIdx0<10; nTreeIdx0++ )
// **********************************************************************
LPCTSTR strProfileName = g_CmdManager->ProfileNameFromWnd( GetSafeHwnd() );
ASSERT( strProfileName != NULL );
CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr( strProfileName, ID_OBJECT_FILLCOLOR );
ASSERT( pCmdItem != NULL );
pCmdItem->StateSetPersistentIcon();
pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;
pCmdItem->StateSetColor();
pCmdItem->StateSetColorBtnDefault();
pCmdItem->StateSetColorBtnCustom();
pCmdItem->StateSetNoRotateVL();
pCmdItem = g_CmdManager->CmdGetPtr( strProfileName, ID_OBJECT_LINECOLOR );
ASSERT( pCmdItem != NULL );
pCmdItem->StateSetPersistentIcon();
pCmdItem->m_nLParamUserData = (LPARAM)pCmdItem->m_nCmdID;
pCmdItem->StateSetColor();
pCmdItem->StateSetColorBtnDefault();
pCmdItem->StateSetColorBtnCustom();
pCmdItem->StateSetNoRotateVL();
pCmdItem = g_CmdManager->CmdGetPtr( strProfileName, ID_DOC_LINE_WIDTH );
ASSERT( pCmdItem != NULL );
pCmdItem->m_sMenuText = _T("Line &Width");
pCmdItem->StateSetPersistentIcon();
INT nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_DOC_LINE_WIDTH);
ASSERT( nBtnIdx >= 0 );
CMenu _line_menu;
VERIFY( _line_menu.LoadMenu(IDR_MENU_LW) );
VERIFY( m_wndToolBarStandard.SetButtonMenu( nBtnIdx, _line_menu.Detach() ) );
CExtBarButton * pTBB = m_wndToolBarStandard.GetButton(nBtnIdx);
ASSERT_VALID( pTBB );
pTBB->SetNoRotateVerticalLayout();
pTBB->SetSeparatedDropDown();
pTBB->SetAutoChangeID();
pTBB->SetCmdID(ID_LINE_WIDTH_1,
true); // set default effective command
#if (defined __EXT_MFC_NO_CUSTOMIZE)
nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_OBJECT_FILLCOLOR);
VERIFY( m_wndToolBarStandard.RemoveButton(nBtnIdx, FALSE) );
CString sNoFill;
VERIFY( sNoFill.LoadString( IDS_STRING_NO_COLOR_FILL ) );
m_pBtnColorFill =
new CExtBarColorButton( &m_wndToolBarStandard, ID_OBJECT_FILLCOLOR, 0, COLORREF(-1), RGB(0,0,0),
ID_OBJECT_FILLCOLOR,
true, true, (LPCTSTR)sNoFill, NULL,
CExtBarColorButton::e_def_icon_type_t::__DIT_CHAR );
m_pBtnColorFill->SetSeparatedDropDown();
VERIFY( m_wndToolBarStandard.InsertSpecButton(nBtnIdx, m_pBtnColorFill, FALSE) );
nBtnIdx = m_wndToolBarStandard.CommandToIndex(ID_OBJECT_LINECOLOR);
m_wndToolBarStandard.SetButtonCtrlVisibleVertically( nBtnIdx,
true );
VERIFY(m_wndToolBarStandard.RemoveButton(nBtnIdx, FALSE ));
CString sNoOutline;
VERIFY( sNoOutline.LoadString( IDS_STRING_NO_COLOR_OUTLINE ) );
m_pBtnColorOutline =
new CExtBarColorButton( &m_wndToolBarStandard, ID_OBJECT_LINECOLOR, 0, COLORREF(-1), RGB(0,0,0),
ID_OBJECT_LINECOLOR,
true, true, (LPCTSTR)sNoOutline, NULL,
CExtBarColorButton::e_def_icon_type_t::__DIT_FRAME
);
VERIFY( m_wndToolBarStandard.InsertSpecButton(nBtnIdx, m_pBtnColorOutline, FALSE) );
#endif // (defined __EXT_MFC_NO_CUSTOMIZE)
if( !m_wndToolBarCustom.Create(NULL, this, ID_VIEW_TOOLBAR2 ) || !m_wndToolBarCustom.InitContentExpandButton() )
{
TRACE0("Failed to create custom toolbar\n");
return -1; // fail to create
}
if(!AddImageProcessingToolBars1())
return(-1);
if( !m_wndToolBarImageProcessing2.Create(_T("Image Processing Tools #1"), this, AFX_IDW_TOOLBAR ) ||
!m_wndToolBarImageProcessing2.LoadToolBar(IDR_TOOLBAR_IMAGE_PROCESSING)
)
{
TRACE0("Failed to create image processing toolbar\n");
return -1; // fail to create
}
if( !m_wndToolBarImageProcessing3.Create(_T("Image Processing Tools #2"), this, AFX_IDW_TOOLBAR ) ||
!m_wndToolBarImageProcessing3.LoadToolBar(IDR_TOOLBAR_IMAGE_PROCESSING2)
)
{
TRACE0("Failed to create image processing toolbar\n");
return -1; // fail to create
}
if( !m_wndToolBarAnnotation.Create(_T("Annotation Tools1"), this, AFX_IDW_TOOLBAR ) ||
!m_wndToolBarAnnotation.LoadToolBar(IDR_TOOLBAR_ANNOTATION)
)
{
TRACE0("Failed to create Annotation Tool1 toolbar\n");
return -1; // fail to create
}
if( !m_wndToolBarAnnotation2.Create(_T("Annotation Tools2"), this, AFX_IDW_TOOLBAR ) ||
!m_wndToolBarAnnotation2.LoadToolBar(IDR_TOOLBAR_ANNOTATION2)
)
{
TRACE0("Failed to create Annotation Tool2 toolbar\n");
return -1; // fail to create
}
// Add drop down menu items on the Rotate menu button
// ******************************************************************************************
pCmdItem = g_CmdManager->CmdGetPtr( strProfileName, ID_IMAGE_ROTATE );
ASSERT( pCmdItem != NULL );
pCmdItem->m_sMenuText = _T("Image &Rotate");
pCmdItem->StateSetPersistentIcon();
INT nBtnRotateIdx = m_wndToolBarImageProcessing2.CommandToIndex(ID_IMAGE_ROTATE);
ASSERT( nBtnRotateIdx >= 0 );
CMenu _rotate_menu;
VERIFY( _rotate_menu.LoadMenu(IDR_MENU_IMAGE_ROTATE) );
VERIFY( m_wndToolBarImageProcessing2.SetButtonMenu( nBtnRotateIdx, _rotate_menu.Detach() ) );
CExtBarButton * pTBBRotate = m_wndToolBarImageProcessing2.GetButton(nBtnRotateIdx);
ASSERT_VALID( pTBBRotate );
pTBBRotate->SetNoRotateVerticalLayout();
pTBBRotate->SetSeparatedDropDown();
pTBBRotate->SetAutoChangeID();
pTBBRotate->SetCmdID(ID_IMAGE_ROTATE,
true); // set default effective command to be 0 degree
// ******************************************************************************************
// Add drop down menu items on the Rotate menu button
// ******************************************************************************************
pCmdItem = g_CmdManager->CmdGetPtr( strProfileName, ID_IMAGE_PSEUDO_COLOR );
ASSERT( pCmdItem != NULL );
pCmdItem->m_sMenuText = _T("Image &Rotate");
pCmdItem->StateSetPersistentIcon();
INT nBtnPsuedoColorIdx = m_wndToolBarImageProcessing2.CommandToIndex(ID_IMAGE_PSEUDO_COLOR);
ASSERT( nBtnPsuedoColorIdx >= 0 );
CMenu _PsuedoColor_menu;
VERIFY( _PsuedoColor_menu.LoadMenu(IDR_MENU_PSEUDO_COLOR) );
VERIFY( m_wndToolBarImageProcessing2.SetButtonMenu( nBtnPsuedoColorIdx, _PsuedoColor_menu.Detach() ) );
CExtBarButton * pTBBPsuedoColor = m_wndToolBarImageProcessing2.GetButton(nBtnPsuedoColorIdx);
ASSERT_VALID( pTBBPsuedoColor );
pTBBPsuedoColor->SetNoRotateVerticalLayout();
pTBBPsuedoColor->SetSeparatedDropDown();
pTBBPsuedoColor->SetAutoChangeID();
pTBBPsuedoColor->SetCmdID(ID_IMAGE_PSEUDO_COLOR,
true); // set default effective command to be 0 degree
// ******************************************************************************************
static struct
{
UINT m_nCmdID;
LPCTSTR m_sToolbarText;
}
custom_toolbar_cmds[] =
{
{ ID_OBJECT_MOVETOFRONT, _T("Move to front") },
{ ID_OBJECT_MOVETOBACK, _T("Move to back") },
{ ID_SEPARATOR, NULL },
{ ID_OBJECT_MOVEFORWARD, NULL },
{ ID_OBJECT_MOVEBACK, NULL },
};
for(INT nCustBarIdx = 0; nCustBarIdx < sizeof(custom_toolbar_cmds)/sizeof(custom_toolbar_cmds[0]); nCustBarIdx++ )
{
// add buttons to custom toolbar
UINT nCmdID = custom_toolbar_cmds[nCustBarIdx].m_nCmdID;
if( nCmdID != ID_SEPARATOR )
{
LPCTSTR sToolBarBtnText = custom_toolbar_cmds[nCustBarIdx].m_sToolbarText;
if( sToolBarBtnText != NULL )
{
CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr(strProfileName, nCmdID );
ASSERT( pCmdItem != NULL );
pCmdItem->m_sToolbarText = sToolBarBtnText;
}
// if( sToolBarBtnText != NULL )
HICON hIcon = (HICON)::LoadImage(hInstResource, MAKEINTRESOURCE( nCmdID ), IMAGE_ICON, 16, 16, 0);
if( hIcon != NULL )
{
VERIFY(g_CmdManager->CmdSetIcon( g_CmdManager->ProfileNameFromWnd(GetSafeHwnd()), nCmdID, hIcon,
false) );
}
// if( hIcon != NULL )
}
// if( nCmdID != ID_SEPARATOR )
m_wndToolBarCustom.InsertButton( -1, nCmdID, FALSE );
}
// add buttons to custom toolbar
m_wndPalette.m_bPaletteMode =
true;
if( !m_wndPalette.Create( NULL, this, ID_VIEW_PALETTE) || !m_wndPalette.LoadToolBar(IDR_TOOLBAR_HELPER_ICONS) )
{
TRACE0("Failed to create m_wndPalette toolbar\n");
return -1; // fail to create
}
m_wndPalette.GetButton(3)->SetWrap( CExtBarButton::__EVT_HORZ );
m_wndPalette.GetButton(8)->SetWrap( CExtBarButton::__EVT_HORZ );
m_wndPalette.GetButton(3)->SetWrap( CExtBarButton::__EVT_VERT );
m_wndPalette.GetButton(6)->SetWrap( CExtBarButton::__EVT_VERT );
m_wndPalette.GetButton(9)->SetWrap( CExtBarButton::__EVT_VERT );
m_wndPalette.GetButton(12)->SetWrap( CExtBarButton::__EVT_VERT );
m_wndPalette.GetButton(3)->SetWrap( CExtBarButton::__EVT_FLOAT );
m_wndPalette.GetButton(5)->SetWrap( CExtBarButton::__EVT_FLOAT );
m_wndPalette.GetButton(7)->SetWrap( CExtBarButton::__EVT_FLOAT );
m_wndPalette.GetButton(9)->SetWrap( CExtBarButton::__EVT_FLOAT );
m_wndPalette.GetButton(11)->SetWrap( CExtBarButton::__EVT_FLOAT );
m_wndStatusBar.m_bDrawPaneSeparatorsInsteadOfBorders =
true;
if( !m_wndStatusBar.Create(this, WS_CHILD|WS_VISIBLE|CBRS_BOTTOM|CBRS_HIDE_INPLACE) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators) / sizeof(UINT))
)
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarStandard.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarCustom.EnableDocking(CBRS_ALIGN_ANY);
m_wndPalette.EnableDocking(CBRS_ALIGN_ANY);
m_wndResizableBarTree.EnableDocking( CBRS_ALIGN_ANY );
m_wndToolBarImageProcessing1.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarImageProcessing2.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarImageProcessing3.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarAnnotation.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarAnnotation2.EnableDocking(CBRS_ALIGN_ANY);
// m_wndPanelDialog.EnableDocking(CBRS_ALIGN_ANY);
// ShowControlBar( &m_wndPanelDialog, FALSE, TRUE );
// m_dlgForPanelDialog.ShowSizeGrip( FALSE );
if( !CExtControlBar::FrameEnableDocking(this) )
{
ASSERT( FALSE );
return -1;
}
VERIFY(g_CmdManager->SetBasicCommands(pApp->m_pszProfileName, g_statBasicCommands) );
#if (!defined __EXT_MFC_NO_CUSTOMIZE)
VERIFY(CExtCustomizeSite::MenuInfoAdd(
this, _T("Default"), IDR_MAINFRAME, true, false, RUNTIME_CLASS(CMainFrame)) );
VERIFY(CExtCustomizeSite::MenuInfoAdd(
this, _T("Document"), IDR_DRAWCLTYPE, false, false, RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CView), RUNTIME_CLASS(CDocument)) );
VERIFY(CExtCustomizeSite::MenuInfoLoadAccelTable(_T("Default"), IDR_MAINFRAME) );
VERIFY(CExtCustomizeSite::MenuInfoLoadAccelTable(_T("Document"), IDR_MAINFRAME ) );
CExtCustomizeSite::MenuInfoGetByName( _T("Document") )
-> GetNode(
true )
-> SearchNodeElement( _T("&Window"), 1 )
-> ModifyFlags( __ECTN_TBB_APPEND_MDI_MENU );
CExtCustomizeSite::MenuInfoGetByName( _T("Document") )
-> GetNode(
false )
-> SearchNodeElement( _T("&Window"), 1 )
-> ModifyFlags( __ECTN_TBB_APPEND_MDI_MENU );
if( !CExtCustomizeSite::EnableCustomization( this ) )
{
ASSERT( FALSE );
return -1;
}
CExtCustomizeSite::CategoryUpdate( IDR_DRAWCLTYPE );
CExtCustomizeSite::CategoryUpdate( IDR_MENU_HELPER );
CExtCustomizeSite::CategoryUpdate( IDR_MAINFRAME );
CExtCustomizeCmdTreeNode * pObjectCategory = CExtCustomizeSite::CategoryGetTreeByName( _T("Object") );
ASSERT_VALID( pObjectCategory );
CExtCustomizeCmdTreeNode * pMenu = pObjectCategory->SearchNodeElement( ID_DOC_LINE_WIDTH );
ASSERT_VALID( pMenu );
VERIFY( pMenu->LoadMenuTree(
this, this, IDR_MENU_LW ) );
pMenu->ModifyFlags( __ECTN_TBB_SEPARATED_DROPDOWN | __ECTN_TBB_AUTOCHANGE_ID | __ECTN_TBB_NO_ROTATE_VL );
pMenu->SetCmdID(ID_LINE_WIDTH_1,
true); // set default effective command
/*
pMenu = pObjectCategory->SearchNodeElement( ID_OBJECT_FILLCOLOR );
ASSERT_VALID( pMenu );
pMenu->ModifyFlags( __ECTN_AUTO_POPUP );
pMenu = pObjectCategory->SearchNodeElement( ID_OBJECT_LINECOLOR );
ASSERT_VALID( pMenu );
pMenu->ModifyFlags( __ECTN_AUTO_POPUP );
*/
CExtCustomizeSite::CategoryMakeAllCmdsUnique();
CExtCustomizeSite::CategoryAppendAllCommands();
CExtCustomizeSite::CategoryAppendNewMenu();
CExtCustomizeSite::CustomizeStateLoad( pApp->m_pszRegistryKey, pApp->m_pszProfileName, pApp->m_pszProfileName );
#endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
// Initialize Vision System class
CString szMsg;
szMsg.LoadString(IDS_OPTIVIEW_MSG_CREATING_STATUS_DISPLAY_PANES);
_splash.SetStatusText(szMsg);
AddLabelStatusBar(1);
AddProgressBarPane(2);
AddAnimatePanInStatusBar(3);
szMsg.LoadString(IDS_OPTIVIEW_MSG_VISIONSYSTEM_INITIALIZE);
if(!InitializeVisionSystem())
return(-1);
if( !CExtControlBar::ProfileBarStateLoad(this, pApp->m_pszRegistryKey, pApp->m_pszProfileName, pApp->m_pszProfileName, &m_dataFrameWP) )
{
DockControlBar( &m_wndMenuBar );
DockControlBar( &m_wndToolBarStandard );
DockControlBar( &m_wndToolBarCustom );
DockControlBar( &m_wndPalette );
DockControlBar( &m_wndToolBarImageProcessing1 );
}
g_CmdManager->SerializeState(pApp->m_pszProfileName, pApp->m_pszRegistryKey, pApp->m_pszProfileName,
false );
#if (!defined __EXT_MFC_NO_TABMDI_CTRL)
if( !m_wndMdiTabs.Create( this ) )
{
ASSERT( FALSE );
return -1;
}
#endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
_splash.DestroyWindow();
return 0;
}