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 » CExtToolControlBar conflict Collapse All
Subject Author Date
Luis Alberto Pereira Mar 29, 2004 - 12:26 PM

Dears,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>


<o:p> </o:p>


I’m having problems with CExtToolControlBar. In my application I have three (3) and I suppose that is happening any conflict between all. I can’t display all three at same time.<o:p></o:p>


<o:p> </o:p>


ControlBar:<o:p></o:p>


<o:p> </o:p>


IDR_MAINFRAME<o:p></o:p>


IDR_INTERFDB (buttons: ID_CHECKDB, ID_EXECDB)<o:p></o:p>


IDR_MANUGRID (buttons: ID_MANUGRID_INS, ID_MANUGRID_DEL, ID_MANUGRID_UP, ID_MANUGRID_DOWN)<o:p></o:p>


<o:p> </o:p>


The IDs buttons of IDR_MANUGRID did not appear in Events of CMainframe Properties window.<o:p></o:p>


<o:p> </o:p>


Please, Can you help me to solve this problem ?<o:p></o:p>


<o:p> </o:p>


Follow de code of mainframe .h and .cpp.<o:p></o:p>


<o:p> </o:p>


class CMainFrame : public CFrameWnd<o:p></o:p>


{<o:p></o:p>


public:<o:p></o:p>


       CMainFrame();<o:p></o:p>


protected: <o:p></o:p>


       DECLARE_DYNAMIC(CMainFrame)<o:p></o:p>


<o:p> </o:p>


// Attributes<o:p></o:p>


protected:<o:p></o:p>


       WINDOWPLACEMENT m_dataFrameWP;<o:p></o:p>


 //__PROFUISAPPWIZ_KEY_PERS_POS_MAINFRM<o:p></o:p>


public:<o:p></o:p>


<o:p> </o:p>


// Operations<o:p></o:p>


public:<o:p></o:p>


       CChildView    m_wndView;<o:p></o:p>


// Overrides<o:p></o:p>


public:<o:p></o:p>


       virtual BOOL DestroyWindow();<o:p></o:p>


       virtual BOOL PreTranslateMessage(MSG* pMsg);<o:p></o:p>


 //__PROFUISAPPWIZ_KEY_USE_MCB<o:p></o:p>


       virtual void ActivateFrame(int nCmdShow = -1);<o:p></o:p>


 //__PROFUISAPPWIZ_KEY_PERS_POS_MAINFRM<o:p></o:p>


<o:p> </o:p>


       virtual BOOL PreCreateWindow(CREATESTRUCT& cs);<o:p></o:p>


       virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);<o:p></o:p>


<o:p> </o:p>


// Implementation<o:p></o:p>


public:<o:p></o:p>


       virtual ~CMainFrame();<o:p></o:p>


#ifdef _DEBUG<o:p></o:p>


       virtual void AssertValid() const;<o:p></o:p>


       virtual void Dump(CDumpContext& dc) const;<o:p></o:p>


#endif<o:p></o:p>


<o:p> </o:p>


protected:  // control bar embedded members<o:p></o:p>


<o:p> </o:p>


       CExtMenuControlBar    m_wndMenuBar;<o:p></o:p>


    //__PROFUISAPPWIZ_KEY_USE_MCB<o:p></o:p>


       //CStatusBar  m_wndStatusBar;<o:p></o:p>


       CExtStatusControlBar  m_wndStatusBar;<o:p></o:p>


       CExtToolControlBar    m_wndToolBar;<o:p></o:p>


       CExtToolControlBar    m_wndToolBarDB;<o:p></o:p>


       CExtToolControlBar    m_wndToolBarGrids;<o:p></o:p>


       CExtControlBar               m_wndResizableBarEmpty;<o:p></o:p>


       //__PROFUISAPPWIZ_KEY_RCB1<o:p></o:p>


       //__PROFUISAPPWIZ_KEY_RCB2<o:p></o:p>


       //__PROFUISAPPWIZ_KEY_RCB3<o:p></o:p>


       //__PROFUISAPPWIZ_KEY_RCB4<o:p></o:p>


       //__PROFUISAPPWIZ_KEY_RCB5<o:p></o:p>


// Generated message map functions<o:p></o:p>


protected:<o:p></o:p>


       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);<o:p></o:p>


       afx_msg void OnSetFocus(CWnd *pOldWnd);<o:p></o:p>


       DECLARE_MESSAGE_MAP()<o:p></o:p>


       afx_msg void OnUpdateControlBarMenu(CCmdUI* pCmdUI);<o:p></o:p>


       afx_msg BOOL OnBarCheck(UINT nID);<o:p></o:p>


public:<o:p></o:p>


       afx_msg void OnViewLikeOffice2003();<o:p></o:p>


       afx_msg void OnUpdateViewLikeOffice2003(CCmdUI *pCmdUI);<o:p></o:p>


       afx_msg void OnViewLikeOffice2k();<o:p></o:p>


       afx_msg void OnUpdateViewLikeOffice2k(CCmdUI *pCmdUI);<o:p></o:p>


       afx_msg void OnViewLikeOfficeXp();<o:p></o:p>


       afx_msg void OnUpdateViewLikeOfficeXp(CCmdUI *pCmdUI);<o:p></o:p>


       afx_msg void OnCheckdb();<o:p></o:p>


       afx_msg void OnExecdb();<o:p></o:p>


<o:p> </o:p>


       CADODatabase* m_pADODB;<o:p></o:p>


       CExtSafeString Obtem_String_Conexao(void);<o:p></o:p>


       afx_msg void OnViewToolbarGrids();<o:p></o:p>


       afx_msg void OnViewToolbarInterfdb();<o:p></o:p>


<o:p> </o:p>


       afx_msg void OnUpdateViewToolbarGrids(CCmdUI *pCmdUI);<o:p></o:p>


       afx_msg void OnUpdateViewToolbarInterfdb(CCmdUI *pCmdUI);<o:p></o:p>


};<o:p></o:p>


<o:p> </o:p>


// CMainFrame<o:p></o:p>


<o:p> </o:p>


IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)<o:p></o:p>


<o:p> </o:p>


BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)<o:p></o:p>


       ON_WM_CREATE()<o:p></o:p>


       ON_WM_SETFOCUS()<o:p></o:p>


       ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)<o:p></o:p>


       ON_COMMAND_EX(ID_VIEW_RESIZABLEBAR_EMPTY, OnBarCheck )<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_RESIZABLEBAR_EMPTY, OnUpdateControlBarMenu)<o:p></o:p>


       ON_COMMAND(ID_VIEW_LIKE_OFFICE_2003, OnViewLikeOffice2003)<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_LIKE_OFFICE_2003, OnUpdateViewLikeOffice2003)<o:p></o:p>


       ON_COMMAND(ID_VIEW_LIKE_OFFICE_XP, OnViewLikeOfficeXp)<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_LIKE_OFFICE_XP, OnUpdateViewLikeOfficeXp)<o:p></o:p>


       ON_COMMAND(ID_VIEW_LIKE_OFFICE_2K, OnViewLikeOffice2k)<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_LIKE_OFFICE_2K, OnUpdateViewLikeOffice2k)<o:p></o:p>


       ON_COMMAND(ID_CHECKDB, OnCheckdb)<o:p></o:p>


       ON_COMMAND(ID_EXECDB, OnExecdb)<o:p></o:p>


       ON_COMMAND_EX(ID_VIEW_TOOLBAR_GRIDS, OnViewToolbarGrids)<o:p></o:p>


       ON_COMMAND_EX(ID_VIEW_TOOLBAR_INTERFDB, OnViewToolbarInterfdb)<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR_GRIDS, OnUpdateViewToolbarGrids)<o:p></o:p>


       ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR_INTERFDB, OnUpdateViewToolbarInterfdb)<o:p></o:p>


END_MESSAGE_MAP()<o:p></o:p>


<o:p> </o:p>


static UINT indicators[] =<o:p></o:p>


{<o:p></o:p>


       ID_SEPARATOR,           // status line indicator<o:p></o:p>


       ID_INDICATOR_CAPS,<o:p></o:p>


       ID_INDICATOR_NUM,<o:p></o:p>


       ID_INDICATOR_SCRL,<o:p></o:p>


};<o:p></o:p>


<o:p> </o:p>


// CMainFrame construction/destruction<o:p></o:p>


<o:p> </o:p>


CMainFrame::CMainFrame()<o:p></o:p>


: m_pADODB(NULL)<o:p></o:p>


{<o:p></o:p>


       ::memset( &m_dataFrameWP, 0, sizeof(WINDOWPLACEMENT) );<o:p></o:p>


       m_dataFrameWP.showCmd = SW_HIDE;<o:p></o:p>


       // TODO: add member initialization code here<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


CMainFrame::~CMainFrame()<o:p></o:p>


{<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)<o:p></o:p>


{<o:p></o:p>


<o:p> </o:p>


       if (CFrameWnd::OnCreate(lpCreateStruct) == -1)<o:p></o:p>


              return -1;<o:p></o:p>


<o:p> </o:p>


       if( ! m_wndView.Create(<o:p></o:p>


                     this,<o:p></o:p>


                     CRect( 0, 0, 0, 0 ),<o:p></o:p>


                     AFX_IDW_PANE_FIRST<o:p></o:p>


                     )<o:p></o:p>


              )<o:p></o:p>


       {<o:p></o:p>


              TRACE0("Failed to create view window\n");<o:p></o:p>


              return -1;<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


       CWinApp * pApp = ::AfxGetApp();<o:p></o:p>


       ASSERT( pApp != NULL );<o:p></o:p>


       ASSERT( pApp->m_pszRegistryKey != NULL );<o:p></o:p>


       ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );<o:p></o:p>


       ASSERT( pApp->m_pszProfileName != NULL );<o:p></o:p>


       ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );<o:p></o:p>


       ASSERT( pApp->m_pszProfileName != NULL );<o:p></o:p>


<o:p> </o:p>


       HICON hIcon = pApp->LoadIcon( IDR_MAINFRAME );<o:p></o:p>


       ASSERT( hIcon != NULL );<o:p></o:p>


       SetIcon( hIcon, TRUE );<o:p></o:p>


       SetIcon( hIcon, FALSE );<o:p></o:p>


       <o:p></o:p>


       VERIFY(<o:p></o:p>


              g_CmdManager->ProfileSetup(<o:p></o:p>


              __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


              GetSafeHwnd()<o:p></o:p>


              )<o:p></o:p>


       );<o:p></o:p>


       VERIFY(<o:p></o:p>


              g_CmdManager->UpdateFromMenu(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     IDR_MAINFRAME<o:p></o:p>


                     )<o:p></o:p>


              );<o:p></o:p>


       VERIFY(<o:p></o:p>


              g_CmdManager->UpdateFromToolBar(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     IDR_MAINFRAME<o:p></o:p>


                     )<o:p></o:p>


              );<o:p></o:p>


       VERIFY(<o:p></o:p>


              g_CmdManager->UpdateFromToolBar(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     IDR_INTERFDB<o:p></o:p>


                     )<o:p></o:p>


              );<o:p></o:p>


       if( !m_wndMenuBar.Create(<o:p></o:p>


                     NULL,<o:p></o:p>


                     this,<o:p></o:p>


                     ID_VIEW_MENUBAR<o:p></o:p>


                     )<o:p></o:p>


              )<o:p></o:p>


    {<o:p></o:p>


        TRACE0("Failed to create menubar\n");<o:p></o:p>


        return -1;      // failed to create<o:p></o:p>


    }<o:p></o:p>


<o:p> </o:p>


       if( !m_wndToolBar.Create(<o:p></o:p>


                     _T("Barra Ferramentas Arquivos"),<o:p></o:p>


                     this,<o:p></o:p>


                     /*ID_VIEW_TOOLBAR*/ AFX_IDW_TOOLBAR<o:p></o:p>


                     )<o:p></o:p>


              ||<o:p></o:p>


              !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)<o:p></o:p>


              )<o:p></o:p>


       {<o:p></o:p>


              TRACE0("Failed to create toolbar\n");<o:p></o:p>


              return -1;      // fail to create<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


   /*CExtCmdItem * pCmdItem;<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_VIEW_LIKE_OFFICE_2K<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = _T("Office &2000");<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_VIEW_LIKE_OFFICE_XP<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = _T("Office &XP");<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_VIEW_LIKE_OFFICE_2003<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = _T("Office XP 200&3");<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_USE_PAINT_MANAGER_COLORS<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText;<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_USE_BK_DEFAULT<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = _T("&Default");<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_USE_BK_DIALOG<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = _T("D&ialog");<o:p></o:p>


<o:p> </o:p>


       pCmdItem =<o:p></o:p>


              g_CmdManager->CmdGetPtr(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     ID_USE_BK_IMAGE<o:p></o:p>


                     );<o:p></o:p>


       ASSERT( pCmdItem != NULL );<o:p></o:p>


       pCmdItem->m_sToolbarText = _T("&Bitmap");<o:p></o:p>


    */<o:p></o:p>


<o:p> </o:p>


       if( !m_wndToolBarGrids.Create(<o:p></o:p>


                     _T("Barra Ferramentas Grids"),<o:p></o:p>


                     this,<o:p></o:p>


                     /*ID_VIEW_TOOLBAR_GRIDS*/ AFX_IDW_TOOLBAR <o:p></o:p>


                     )<o:p></o:p>


              ||<o:p></o:p>


              !m_wndToolBarGrids.LoadToolBar(IDR_MANUGRID)<o:p></o:p>


              )<o:p></o:p>


       {<o:p></o:p>


              TRACE0("Failed to create toolbar interface DB\n");<o:p></o:p>


              return -1;      // fail to create<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


       if( !m_wndToolBarDB.Create(<o:p></o:p>


                     _T("Barra Ferramentas Interface DB"),<o:p></o:p>


                     this,<o:p></o:p>


                     /*ID_VIEW_TOOLBAR_INTERFDB*/ AFX_IDW_TOOLBAR <o:p></o:p>


                     )<o:p></o:p>


              ||<o:p></o:p>


              !m_wndToolBarDB.LoadToolBar(IDR_INTERFDB)<o:p></o:p>


              )<o:p></o:p>


       {<o:p></o:p>


              TRACE0("Failed to create toolbar interface DB\n");<o:p></o:p>


              return -1;      // fail to create<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


       if (!m_wndStatusBar.Create(this) ||<o:p></o:p>


              !m_wndStatusBar.SetIndicators(indicators,<o:p></o:p>


                sizeof(indicators)/sizeof(UINT)))<o:p></o:p>


       {<o:p></o:p>


              TRACE0("Failed to create status bar\n");<o:p></o:p>


              return -1;      // fail to create<o:p></o:p>


       }<o:p></o:p>


       m_wndResizableBarEmpty.SetInitDesiredSizeVertical(<o:p></o:p>


              CSize( 200, 400 )<o:p></o:p>


              );<o:p></o:p>


       m_wndResizableBarEmpty.SetInitDesiredSizeHorizontal(<o:p></o:p>


              CSize( 400, 200 )<o:p></o:p>


              );<o:p></o:p>


<o:p> </o:p>


       if(    !m_wndResizableBarEmpty.Create(<o:p></o:p>


                     NULL, // _T("Optional control bar caption"),<o:p></o:p>


                     this,<o:p></o:p>


                     ID_VIEW_RESIZABLEBAR_EMPTY,<o:p></o:p>


                     WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_GRIPPER<o:p></o:p>


                           |CBRS_TOOLTIPS<o:p></o:p>


                           |CBRS_FLYBY<o:p></o:p>


                           |CBRS_SIZE_DYNAMIC<o:p></o:p>


                           |CBRS_HIDE_INPLACE<o:p></o:p>


                     )<o:p></o:p>


              )<o:p></o:p>


       {<o:p></o:p>


              TRACE0("Failed to create m_wndResizableBarEmpty\n");<o:p></o:p>


              return -1;           // fail to create<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


       // TODO: Delete these lines if you don’t want the dockable entity<o:p></o:p>


       m_wndMenuBar.EnableDocking( CBRS_ALIGN_ANY );<o:p></o:p>


       m_wndToolBar.EnableDocking( CBRS_ALIGN_ANY );<o:p></o:p>


       m_wndToolBarGrids.EnableDocking( CBRS_ALIGN_ANY );<o:p></o:p>


       m_wndToolBarDB.EnableDocking( CBRS_ALIGN_ANY );<o:p></o:p>


       m_wndResizableBarEmpty.EnableDocking( CBRS_ALIGN_ANY );<o:p></o:p>


<o:p> </o:p>


       //VERBOSE<o:p></o:p>


       if( !CExtControlBar::FrameEnableDocking(this) )<o:p></o:p>


       {<o:p></o:p>


              ASSERT( FALSE );<o:p></o:p>


              return -1;<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


       // Enable autohide feature for resizable control bars<o:p></o:p>


    //VERBOSE<o:p></o:p>


       if( !CExtControlBar::FrameInjectAutoHideAreas(this) )<o:p></o:p>


       {<o:p></o:p>


              ASSERT( FALSE );<o:p></o:p>


              return -1;<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


       if( !CExtControlBar::ProfileBarStateLoad(<o:p></o:p>


                     this,<o:p></o:p>


                     pApp->m_pszRegistryKey,<o:p></o:p>


                     pApp->m_pszProfileName,<o:p></o:p>


                     pApp->m_pszProfileName,<o:p></o:p>


                     &m_dataFrameWP<o:p></o:p>


                     )<o:p></o:p>


              )<o:p></o:p>


       {<o:p></o:p>


              DockControlBar( &m_wndMenuBar );<o:p></o:p>


              DockControlBar( &m_wndToolBar );<o:p></o:p>


              DockControlBar( &m_wndToolBarGrids );<o:p></o:p>


              DockControlBar( &m_wndToolBarDB );<o:p></o:p>


<o:p> </o:p>


              m_wndResizableBarEmpty.FloatControlBar( CPoint( 300, 200 ) );<o:p></o:p>


              //m_wndHelpBar.DockControlBar( AFX_IDW_DOCKBAR_RIGHT, 1, this );<o:p></o:p>


       }<o:p></o:p>


<o:p> </o:p>


static UINT statBasicCommands[] =<o:p></o:p>


{<o:p></o:p>


 //(PROJTYPE_MDI || !NODOCVIEW)<o:p></o:p>


 //!NODOCVIEW<o:p></o:p>


       ID_APP_EXIT,<o:p></o:p>


       ID_APP_ABOUT,<o:p></o:p>


       ID_EDIT_COPY, <o:p></o:p>


       ID_EDIT_CUT, <o:p></o:p>


       ID_EDIT_PASTE, <o:p></o:p>


       ID_EDIT_UNDO, <o:p></o:p>


       ID_VIEW_TOOLBAR, <o:p></o:p>


       ID_VIEW_TOOLBAR_INTERFDB,<o:p></o:p>


       ID_VIEW_TOOLBAR_GRIDS,<o:p></o:p>


 //TOOLBAR<o:p></o:p>


       ID_VIEW_RESIZABLEBAR_EMPTY,<o:p></o:p>


       ID_VIEW_LIKE_OFFICE_2003,<o:p></o:p>


       ID_VIEW_LIKE_OFFICE_XP,<o:p></o:p>


       ID_VIEW_LIKE_OFFICE_2K,<o:p></o:p>


       ID_USE_PAINT_MANAGER_COLORS,<o:p></o:p>


       ID_USE_BK_DEFAULT,<o:p></o:p>


       ID_USE_BK_DIALOG,<o:p></o:p>


       ID_USE_BK_IMAGE,<o:p></o:p>


       //ID_CHECKDB,<o:p></o:p>


       //ID_EXECDB,<o:p></o:p>


<o:p> </o:p>


       //(CRecordView || CDaoRecordView || COleDBRecordView)<o:p></o:p>


 //HELP<o:p></o:p>


       0 // end of commands list<o:p></o:p>


}; // statBasicCommands array<o:p></o:p>


<o:p> </o:p>


       VERIFY(<o:p></o:p>


              g_CmdManager->SetBasicCommands(<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     statBasicCommands<o:p></o:p>


                     )<o:p></o:p>


              );<o:p></o:p>


<o:p> </o:p>


       CExtControlBar::ProfileBarStateLoad(<o:p></o:p>


              this,<o:p></o:p>


              pApp->m_pszRegistryKey,<o:p></o:p>


              __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


              __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


              &m_dataFrameWP<o:p></o:p>


              );<o:p></o:p>


       <o:p></o:p>


       g_CmdManager->SerializeState(<o:p></o:p>


              __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


              pApp->m_pszRegistryKey,<o:p></o:p>


              __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


              false<o:p></o:p>


              );<o:p></o:p>


<o:p> </o:p>


       return 0;<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


BOOL CMainFrame::DestroyWindow() <o:p></o:p>


{<o:p></o:p>


       CWinApp * pApp = ::AfxGetApp();<o:p></o:p>


       ASSERT( pApp != NULL );<o:p></o:p>


       ASSERT( pApp->m_pszRegistryKey != NULL );<o:p></o:p>


       ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );<o:p></o:p>


       ASSERT( pApp->m_pszProfileName != NULL );<o:p></o:p>


       ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );<o:p></o:p>


<o:p> </o:p>


       VERIFY(<o:p></o:p>


              CExtControlBar::ProfileBarStateSave(<o:p></o:p>


                     this,<o:p></o:p>


                     pApp->m_pszRegistryKey,<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME,<o:p></o:p>


                     __PROF_UIS_PROJECT_CMD_PROFILE_NAME<o:p></o:p>


                     )<o:p></o:p>


              );<o:p></o:p>


       <o:p></o:p>


       g_CmdManager->ProfileWndRemove( GetSafeHwnd() );<o:p></o:p>


              <o:p></o:p>


       return CFrameWnd::DestroyWindow();<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::ActivateFrame(int nCmdShow) <o:p></o:p>


{<o:p></o:p>


       if( m_dataFrameWP.showCmd != SW_HIDE )<o:p></o:p>


       {<o:p></o:p>


              SetWindowPlacement( &m_dataFrameWP );<o:p></o:p>


              CFrameWnd::ActivateFrame( m_dataFrameWP.showCmd );<o:p></o:p>


              m_dataFrameWP.showCmd = SW_HIDE;<o:p></o:p>


              return;<o:p></o:p>


       }<o:p></o:p>


       CFrameWnd::ActivateFrame(nCmdShow);<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)<o:p></o:p>


{<o:p></o:p>


       if( !CFrameWnd::PreCreateWindow(cs) )<o:p></o:p>


              return FALSE;<o:p></o:p>


       // TODO: Modify the Window class or styles here by modifying<o:p></o:p>


       //  the CREATESTRUCT cs<o:p></o:p>


<o:p> </o:p>


       cs.dwExStyle &= ~WS_EX_CLIENTEDGE;<o:p></o:p>


       cs.lpszClass = AfxRegisterWndClass(0);<o:p></o:p>


       return TRUE;<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


// CMainFrame diagnostics<o:p></o:p>


<o:p> </o:p>


#ifdef _DEBUG<o:p></o:p>


void CMainFrame::AssertValid() const<o:p></o:p>


{<o:p></o:p>


       CFrameWnd::AssertValid();<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::Dump(CDumpContext& dc) const<o:p></o:p>


{<o:p></o:p>


       CFrameWnd::Dump(dc);<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


#endif //_DEBUG<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


// CMainFrame message handlers<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnSetFocus(CWnd* /*pOldWnd*/)<o:p></o:p>


{<o:p></o:p>


       // forward focus to the view window<o:p></o:p>


       m_wndView.SetFocus();<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)<o:p></o:p>


{<o:p></o:p>


       // let the view have first crack at the command<o:p></o:p>


       if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))<o:p></o:p>


              return TRUE;<o:p></o:p>


<o:p> </o:p>


       // otherwise, do default handling<o:p></o:p>


       return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


 //CONTAINER || CONTAINER_SERVER<o:p></o:p>


BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) <o:p></o:p>


{<o:p></o:p>


       if( m_wndMenuBar.TranslateMainFrameMessage(pMsg) )<o:p></o:p>


              return TRUE;<o:p></o:p>


       return CFrameWnd::PreTranslateMessage(pMsg);<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnUpdateControlBarMenu(CCmdUI* pCmdUI)<o:p></o:p>


{<o:p></o:p>


       CExtControlBar::DoFrameBarCheckUpdate(<o:p></o:p>


              this,<o:p></o:p>


              pCmdUI,<o:p></o:p>


              false<o:p></o:p>


              );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


BOOL CMainFrame::OnBarCheck(UINT nID)<o:p></o:p>


{<o:p></o:p>


       return<o:p></o:p>


              CExtControlBar::DoFrameBarCheckCmd(<o:p></o:p>


                     this,<o:p></o:p>


                     nID,<o:p></o:p>


                     false<o:p></o:p>


                     );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnViewLikeOffice2003()<o:p></o:p>


{<o:p></o:p>


       if( g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) )<o:p></o:p>


              return;<o:p></o:p>


       VERIFY(<o:p></o:p>


              g_PaintManager.InstallPaintManager( new CExtPaintManagerOffice2003 )<o:p></o:p>


              );<o:p></o:p>


       RecalcLayout();<o:p></o:p>


       RedrawWindow(<o:p></o:p>


              NULL,<o:p></o:p>


              NULL,<o:p></o:p>


              RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE<o:p></o:p>


                     | RDW_FRAME | RDW_ALLCHILDREN<o:p></o:p>


              );<o:p></o:p>


       CExtControlBar::stat_RedrawFloatingFrames( this );<o:p></o:p>


       CExtControlBar::stat_RecalcBarMetrics( this );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnUpdateViewLikeOffice2003(CCmdUI *pCmdUI)<o:p></o:p>


{<o:p></o:p>


              pCmdUI->Enable();<o:p></o:p>


       pCmdUI->SetRadio(<o:p></o:p>


              g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) )<o:p></o:p>


                     ? TRUE<o:p></o:p>


                     : FALSE<o:p></o:p>


              );<o:p></o:p>


<o:p> </o:p>


}<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


void CMainFrame::OnViewLikeOffice2k()<o:p></o:p>


{<o:p></o:p>


       if( !g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) ) )<o:p></o:p>


              return;<o:p></o:p>


       VERIFY(<o:p></o:p>


              g_PaintManager.InstallPaintManager( new CExtPaintManager )<o:p></o:p>


              );<o:p></o:p>


       RecalcLayout();<o:p></o:p>


       RedrawWindow(<o:p></o:p>


              NULL,<o:p></o:p>


              NULL,<o:p></o:p>


              RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE<o:p></o:p>


                     | RDW_FRAME | RDW_ALLCHILDREN<o:p></o:p>


              );<o:p></o:p>


       CExtControlBar::stat_RedrawFloatingFrames( this );<o:p></o:p>


       CExtControlBar::stat_RecalcBarMetrics( this );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnUpdateViewLikeOffice2k(CCmdUI *pCmdUI)<o:p></o:p>


{<o:p></o:p>


       pCmdUI->Enable();<o:p></o:p>


       pCmdUI->SetRadio(<o:p></o:p>


              g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) )<o:p></o:p>


                     ? FALSE<o:p></o:p>


                     : TRUE<o:p></o:p>


              );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnViewLikeOfficeXp()<o:p></o:p>


{<o:p></o:p>


       if(           g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) )<o:p></o:p>


              &&     (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) )<o:p></o:p>


              )<o:p></o:p>


              return;<o:p></o:p>


       VERIFY(<o:p></o:p>


              g_PaintManager.InstallPaintManager( new CExtPaintManagerXP )<o:p></o:p>


              );<o:p></o:p>


       RecalcLayout();<o:p></o:p>


       RedrawWindow(<o:p></o:p>


              NULL,<o:p></o:p>


              NULL,<o:p></o:p>


              RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE<o:p></o:p>


                     | RDW_FRAME | RDW_ALLCHILDREN<o:p></o:p>


              );<o:p></o:p>


       CExtControlBar::stat_RedrawFloatingFrames( this );<o:p></o:p>


       CExtControlBar::stat_RecalcBarMetrics( this );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnUpdateViewLikeOfficeXp(CCmdUI *pCmdUI)<o:p></o:p>


{<o:p></o:p>


       pCmdUI->Enable();<o:p></o:p>


       pCmdUI->SetRadio(<o:p></o:p>


              (      g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerXP) )<o:p></o:p>


              &&     (! g_PaintManager->IsKindOf( RUNTIME_CLASS(CExtPaintManagerOffice2003) ) )<o:p></o:p>


              )      ? TRUE<o:p></o:p>


                     : FALSE<o:p></o:p>


              );<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnCheckdb()<o:p></o:p>


{<o:p></o:p>


    CExtSafeString strConnection = Obtem_String_Conexao();<o:p></o:p>


       m_pADODB = new CADODatabase();<o:p></o:p>


       m_pADODB->SetConnectionString(strConnection);<o:p></o:p>


       if (m_pADODB->Open())<o:p></o:p>


       AfxMessageBox("Abriu", MB_OK|MB_ICONINFORMATION );<o:p></o:p>


       m_pADODB->Close();<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnExecdb()<o:p></o:p>


{<o:p></o:p>


       // TODO: Add your command handler code here<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


<o:p> </o:p>


CExtSafeString CMainFrame::Obtem_String_Conexao(void)<o:p></o:p>


{<o:p></o:p>


       CExtGridCell* pCell = m_wndView.m_arrGrids[0].GridCellGet(0,0);<o:p></o:p>


       CExtSafeString strTextCell;<o:p></o:p>


       pCell->TextGet(strTextCell);<o:p></o:p>


       return (strTextCell.IsEmpty() ? _T("") : strTextCell);<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnViewToolbarGrids()<o:p></o:p>


{<o:p></o:p>


       // TODO: Add your command handler code here<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnViewToolbarInterfdb()<o:p></o:p>


{<o:p></o:p>


       // TODO: Add your command handler code here<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnUpdateViewToolbarGrids(CCmdUI *pCmdUI)<o:p></o:p>


{<o:p></o:p>


       // TODO: Add your command update UI handler code here<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


void CMainFrame::OnUpdateViewToolbarInterfdb(CCmdUI *pCmdUI)<o:p></o:p>


{<o:p></o:p>


       // TODO: Add your command update UI handler code here<o:p></o:p>


}<o:p></o:p>


<o:p> </o:p>


Thanks, <o:p></o:p>

Technical Support Mar 30, 2004 - 6:02 AM

Hello,

We found an error in your source code. Please take a look at the m_wndToolBar.Create(:, m_wndToolBarGrids.Create(:, and m_wndToolBarDB.Create(: lines inside the CMainFrame::OnCreate() method. All your toolbars have the same dialog control identifier, which is set to AFX_IDW_TOOLBAR. This is an invalid approach for creating multiply control bars inside the frame window. Please use three different identifiers for your bars. You can add three different commands like ID_VIEW_TOOLBAR, ID_VIEW_TOOLBAR_GRIDS and ID_VIEW_TOOLBAR_INTERFDB to the main frame’s menu resource and use them as toolbar identifiers. We see you have tried to do this. The ID_VIEW_TOOLBAR constant is absolutely equal to AFX_IDW_TOOLBAR. So MFC handles the show/hide command for your first toolbar automatically. To make the show/hide command work for your grid-toolbar and db-toolbar, you should add the following lines to the message map of the CMainFrame class:

 
ON_COMMAND_EX(ID_VIEW_TOOLBAR_GRIDS, OnBarCheck )
ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR_GRIDS,
 OnUpdateControlBarMenu)
ON_COMMAND_EX(ID_VIEW_TOOLBAR_INTERFDB, OnBarCheck )
ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR_INTERFDB,
 OnUpdateControlBarMenu)

If your frame window uses a menu bar with identifier ID_VIEW_MENUBAR, then you should also put similar lines onto the message map:
 
ON_COMMAND_EX(ID_VIEW_MENUBAR, OnBarCheck )
ON_UPDATE_COMMAND_UI(ID_VIEW_MENUBAR, OnUpdateControlBarMenu)