My custom toolbars dos not saved!!!
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5067
Printed Date: 04 March 2025 at 8:23am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: My custom toolbars dos not saved!!!
Posted By: MVA790
Subject: My custom toolbars dos not saved!!!
Date Posted: 17 September 2006 at 6:56am
Hi dear xterm team, at first, congratulation to you for your nice components. however,I have a disasters error and i cant find out how can i fix it. in my MainFram and its onCreate function,I loaded my menues and toolbars and add them to my frame work aftre customizing all customizations will be applied on next execution except of my custom toolbars which are created by user at run time. Please help me. Thank you, Majid Vesal.
following code shows my functions:
int CKWMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if( CKWNeginConfig::Instance()->GetOwner() == ns_SystemOwner::en_SystemOwner_ENB || CKWNeginConfig::Instance()->GetOwner() == ns_SystemOwner::en_SystemOwner_CID ) m_pArm = NULL; else { m_pArm = new CPictureEx(); CRect rc; GetClientRect(&rc); m_pArm->Create( "", WS_CHILD|WS_VISIBLE, CRect(0,0,0,0), this ); if( m_pArm->Load( CKWNeginConfig::Instance()->GetAnimateFileName() ) ) m_pArm->Draw(); else { delete m_pArm; m_pArm = NULL; } }
if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; //Enable docking features EnableDocking(CBRS_ALIGN_ANY); //Get handle of main part of system's menu HMENU hmBaseMenu = GetMainPartOfMenu(); //Create template menu m_wndMenuBar.CreateMenu(); // Check template menu if ( ::IsMenu( hmBaseMenu ) ) { // loading template menu from given menu handle CMenu* pMenu = CMenu::FromHandle(hmBaseMenu ); m_wndMenuBar.m_hMenu = pMenu->m_hMenu ; } else { CString strTemp; strTemp.Format("در فعال کردن منوي زيرسيستم خطائي رخ داده است\r\nکد خطا: %d", GetLastError() ); } // Set timer for refreshing status bar SetTimer(IDE_DATETIME_REFRESH,60000,NULL); SetTimer(IDE_SHPOOL_REFRESH,1800000,NULL); // Creates status bar if (!m_wndStatusBar.Create(this)) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // Initialize Status Bar Control CDC *pDC = m_wndStatusBar.GetDC(); TEXTMETRIC aTextInfo; pDC->GetTextMetrics(&aTextInfo); // counts status bar panes const int nPanes = sizeof(STATUSINFOWIDTH)/sizeof(StatusInfo); int Width[nPanes]; long RightAlign = 0; //Loops on status bar panes and set their initial requirements. for(short idx = 0 ; idx<nPanes ; idx++) { //Add pane indicator m_wndStatusBar.AddIndicator(idx,idx); //set pane default text m_wndStatusBar.SetPaneText(idx,STATUSINFOWIDTH[idx].lpToolTipText); // set pane tool tip text,which will be shown when user move // mouse on it. m_wndStatusBar.GetPane(idx)->SetTooltip(STATUSINFOWIDTH[idx].lpToolTipText); // set panel width m_wndStatusBar.GetPane(idx)->SetWidth(STATUSINFOWIDTH[idx].sTextWidth*aTextInfo.tmAveCharWidth); } Width[nPanes-1]=-1; //inforce status bar to follow command bars theme. m_wndStatusBar.UseCommandBarsTheme(TRUE); // Initialize the command bars if (!InitCommandBars()) return -1;
// Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; // fail to create }
//Add the menu bar CXTPCommandBar* pMenuBar = pCommandBars->SetMenu( _T("منوي اصلي"), IDM_MENU_SYSTEM); if(pMenuBar == NULL) { TRACE0("Failed to create menu bar.\n"); return -1; // fail to create } // check menu bar creation if(pMenuBar == NULL) { TRACE0("Failed to create menu bar.\n"); return -1; // fail to create } pMenuBar->SetFlags(xtpFlagAddMDISysPopup);
// Create standard ToolBar CXTPToolBar* pToolBar = (CXTPToolBar*) pCommandBars->Add(_T("استاندارد"), xtpBarTop); // Load Standard tool bar if (!pToolBar || !pToolBar->LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; } //set bar id to new CTX bar pToolBar->SetBarID(nBaseBarID); // Enables animated selection change to menus and tool bars pToolBar->EnableAnimation(); // Set Theme CXTPPaintManager::SetTheme(xtpThemeOffice2003); // Set "Always Show Full Menus" option to the FALSE pCommandBars->GetCommandBarsOptions()->bAlwaysShowFullMenus = FALSE;
pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); // Enables animated selection change to menus and tool bars pMenuBar->EnableAnimation(); // Load New menu(code jock menu) from given standard menu pMenuBar->LoadMenu(&m_wndMenuBar);
//Loasd all tool bars of loaded applications. LoadAllCommandBars();
// Load previous menu customization data LoadCommandBars(_T("CommandBars")); // Load the previous state for tool bars and menus. SetApplicationTitle(); return 0; }
//------------------------------ //------------------------------------------------ // LoadAllCommandBars // This function loads command bars of subsystems // Which should be loaded. //------------------------------------------------ void CKWMainFrame::LoadAllCommandBars() { if(CKWNeginConfig::Instance()->IsLoadSysMenuNeeded()) for(short i=0; i < m_sSubSysCnt; i++ ) { try { // load sub systems HINSTANCE hInstance = LoadLibraryEx( m_psp->g_SubSystems.DllName ,NULL, DONT_RESOLVE_DLL_REFERENCES); // getting menu name LPCTSTR lpMenuName = MAKEINTRESOURCE( IDR_SUBSYSTEM ); // loading menu of current subsystem. HMENU systemMenu = LoadMenu( hInstance, lpMenuName ); //checking validation of current menu if( ::IsMenu(systemMenu )) { //Loading and assigning internal menu pointer CMenu* pMenu = CMenu::FromHandle(systemMenu); //checks pointer be valid if (pMenu) { //delete first menu item because it is loaded in main part //of menu. pMenu->DeleteMenu(0,MF_BYPOSITION); //creating tool bars CXTPToolBar* pToolBar = (CXTPToolBar*) //add new command bar to command bar collection GetCommandBars()->Add(_T(m_psp->g_SubSystems.Desc), xtpBarTop); // set bar id //Notice: command bar id is important for saving its change. pToolBar->SetBarID(nBaseBarID+i+1); if (!pToolBar || !pToolBar->LoadMenu(pMenu)) { TRACE0("Failed to create toolbar\n"); } else { //set visible to false //because we don't need to view all command bars. pToolBar->SetVisible(FALSE); //enables its animation mode. pToolBar->EnableAnimation(); //fill corresponded menu info stricture. tagMenuInfo menuInfo; menuInfo.pMenu = new CMenu(); menuInfo.OwnerName = m_psp->g_SubSystems.Desc; menuInfo.pMenu->Attach(pMenu->GetSafeHmenu()); // add to internal array. m_LoadedMenues.Add(menuInfo); } } } } catch (...) { AfxMessageBox( "...."); } } } //------------------------------------------------------------------------ // SwitchToMenu // This function switches active menu bar with given menu //------------------------------------------------------------------------ void CKWMainFrame::SwitchToMenu( char i_chSubSystemCode ) { // for all sub systems. for(short i=0; i < m_sSubSysCnt; i++ ) { // if sub system's id is equal to given id if( m_psp->g_SubSystems.Code != i_chSubSystemCode ) continue; //setting application title SetApplicationTitle(i); // loading selected subsystem HINSTANCE hInstance = LoadLibraryEx( m_psp->g_SubSystems.DllName ,NULL, DONT_RESOLVE_DLL_REFERENCES); // Loading menu HMENU systemMenu = LoadMenu(hInstance, MAKEINTRESOURCE( IDR_SUBSYSTEM ) ); if ( !IsMenu( systemMenu ) ) { CString strTemp; strTemp.Format("در فعال کردن منوي زيرسيستم خطائي رخ داده است\r\nکد خطا: %d", GetLastError() ); AfxMessageBox( strTemp, MB_ICONSTOP ); return; } // check if loading menu is needed if( !CKWNeginConfig::Instance()->IsLoadSysMenuNeeded() ) { //customize subsystem menu CMenu* pSubMenu = CMenu::FromHandle(systemMenu); CustomizeMenu( i_chSubSystemCode, pSubMenu ); if ( ::IsMenu( pSubMenu->GetSafeHmenu() ) ) { m_wndMenuBar.Attach(pSubMenu->m_hMenu); DrawMenuBar(); } else { CString strTemp; strTemp.Format("در فعال کردن منوي زيرسيستم خطائي رخ داده است\r\nکد خطا: %d", GetLastError() ); AfxMessageBox( strTemp, MB_ICONSTOP ); } return; } sp->g_chSubSystemCode = i_chSubSystemCode ; CMenu* pMenu = CMenu::FromHandle(GetMainPartOfMenu()); if (pMenu == NULL) { return; } CString strCaption1; pMenu->GetMenuString( 0, strCaption1, MF_BYPOSITION ); CMenu* pMnuPopUp1 = pMenu->GetSubMenu(0);
//--------------------------card CString strCaption2; CMenu* pMnuPopUp2; if( CKWNeginConfig::Instance()->IsSubSysMenuEnabled() ) { pMenu->GetMenuString( 1, strCaption2, MF_BYPOSITION ); pMnuPopUp2 = pMenu->GetSubMenu(1); } //--------------------------card CString strCaption3; pMenu->GetMenuString( pMenu->GetMenuItemCount()-2, strCaption3, MF_BYPOSITION ); CMenu* pMnuPopUp3 = pMenu->GetSubMenu(pMenu->GetMenuItemCount()-2);
CString strCaption4; pMenu->GetMenuString( pMenu->GetMenuItemCount()-1, strCaption4, MF_BYPOSITION ); CMenu* pMnuPopUp4 = pMenu->GetSubMenu(pMenu->GetMenuItemCount()-1);
CMenu* pSubMenu = CMenu::FromHandle(systemMenu);
if( !pSubMenu->InsertMenu( 0, MF_BYPOSITION|MF_POPUP|MF_STRING, (UINT)pMnuPopUp1->GetSafeHmenu(), strCaption1 ) || //--------------------------card ( CKWNeginConfig::Instance()->IsSubSysMenuEnabled() && !pSubMenu->InsertMenu( 1, MF_BYPOSITION|MF_POPUP|MF_STRING, (UINT)pMnuPopUp2->GetSafeHmenu(), strCaption2 ) ) || //--------------------------card !pSubMenu->InsertMenu( pSubMenu->GetMenuItemCount(), MF_BYPOSITION|MF_POPUP|MF_STRING, (UINT)pMnuPopUp3->GetSafeHmenu(), strCaption3 ) || !pSubMenu->InsertMenu( pSubMenu->GetMenuItemCount(), MF_BYPOSITION|MF_POPUP|MF_STRING, (UINT)pMnuPopUp4->GetSafeHmenu(), strCaption4 ) ) { CString strTemp; strTemp.Format("در فعال کردن منوي زيرسيستم خطائي رخ داده است\r\n" " خط: %ld", __LINE__ ); AfxMessageBox( strTemp, MB_ICONSTOP ); return; } //customize subsystem menu CustomizeMenu( i_chSubSystemCode, pSubMenu ); if ( ::IsMenu( pSubMenu->GetSafeHmenu() ) ) {
CXTPMenuBar* pMenuBar = GetCommandBars()->GetMenuBar(); if (!pMenuBar || !pMenuBar->LoadMenu(pSubMenu)) { TRACE0("Failed to create pMenuBar\n"); return; } pMenuBar->SetVisible(FALSE); pMenuBar->SetVisible(TRUE); pMenuBar->RefreshMenu(); pMenuBar->Redraw(); } else { CString strTemp; strTemp.Format("در فعال کردن منوي زيرسيستم خطائي رخ داده است\r\nکد خطا: %d", GetLastError() ); AfxMessageBox( strTemp, MB_ICONSTOP ); } ReloadSubSystemXML() ;
return; }
AfxMessageBox( "! با عرض پوزش اين گزينه فعلا پشتيباني نمي شود" ); sp->g_chSubSystemCode = 0 ; }
|
Replies:
Posted By: Oleg
Date Posted: 18 September 2006 at 4:01am
Hi,
In LoadAllCommandBars after you create toolbar and create its controls need to call
pToolBar->GetControls()->CreateOriginalControls(); to fix state for reset button.
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
Posted By: MVA790
Date Posted: 19 September 2006 at 2:29am
Hi dear Oleg, Thank you for your consideration, But unfortunatly i cant still save my custom toolbars(which are created at run time). I am looking forward your attention. Best regards;
|
Posted By: Oleg
Date Posted: 21 September 2006 at 1:55pm
Hi,
Do you enable customization? Do you catch XTP_ID_CUSTOMIZE ?
------------- Oleg, Support Team CODEJOCK SOFTWARE SOLUTIONS
|
|