Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Toolbar control problem !!!
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Toolbar control problem !!!

 Post Reply Post Reply
Author
Message
scs7309 View Drop Down
Newbie
Newbie
Avatar

Joined: 05 January 2007
Location: Korea, South
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote scs7309 Quote  Post ReplyReply Direct Link To This Post Topic: Toolbar control problem !!!
    Posted: 09 January 2007 at 2:39am
My propose is GUI_OneNote Toolbar looks like below.
 
 
 
Below is my test program screenshot.
This program toolbar has CXTPControlFontComboBox, CXTPControlSizeComboBox and two CXTPControlPopupColor controls. 
 
 
But inserted controls(CXTPControlFontComboBox, CXTPControlSizeComboBox and two CXTPControlPopupColor controls)
never activated !!!!!
what's wrong??? what's problem???
Please help me !!!!!
 
 
 
Here is my code.
 
MainFrm.h
 
class CMainFrame : public CXTPMDIFrameWnd, CXTPOffice2007FrameHook
{
 DECLARE_DYNAMIC(CMainFrame)
public:
 CMainFrame();
// Attributes
public:
// Operations
public:
// Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CMainFrame)
 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
 //}}AFX_VIRTUAL
// Implementation
public:
 virtual ~CMainFrame();
#ifdef _DEBUG
 virtual void AssertValid() const;
 virtual void Dump(CDumpContext& dc) const;
#endif
protected:  // control bar embedded members
 CXTPStatusBar m_wndStatusBar;
// Generated message map functions
protected:
 //{{AFX_MSG(CMainFrame)
 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
 afx_msg int OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl);
 //}}AFX_MSG
 
 DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MAINFRM_H__F4F24561_D850_4A9C_A3A1_D3EB1CD55BD4__INCLUDED_)
 
 
 
MainFrm.cpp
 
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  return -1;
 if (!m_wndStatusBar.Create(this) ||
  !m_wndStatusBar.SetIndicators(indicators,
  sizeof(indicators)/sizeof(UINT)))
 {
  TRACE0("Failed to create status bar\n");
  return -1;      // fail to create
 }
 // Initialize command bars.  Command bars must be created and initialized
 // after all standard MFC control bars have been created.
 if (!InitCommandBars())
  return -1;
 CXTPPaintManager::SetTheme(xtpThemeOffice2007);
 // Get a pointer to the command bars object.
 CXTPCommandBars *pCommandBars = GetCommandBars();
 // create the menubar.
 CXTPCommandBar *pMenuBar = pCommandBars->SetMenu(_T("Menu"), IDR_MAINFRAME);
 pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage);
 // create the general toolbar.
 CXTPToolBar *pGeneralToolbar = (CXTPToolBar *)pCommandBars->Add(_T("General"), xtpBarTop);
 if(!pGeneralToolbar || !pGeneralToolbar->LoadToolBar(IDR_MAINFRAME))
 {
  TRACE0("Failed to create toolbar\n");
  return -1;
 }
 return 0;
}
 
int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{
 if (lpCreateControl->bToolBar == FALSE)
  return FALSE;
 else
 {
  CXTPToolBar* pToolBar = DYNAMIC_DOWNCAST(CXTPToolBar, lpCreateControl->pCommandBar);
  if (!pToolBar)
   return FALSE;

  if (lpCreateControl->nID == ID_COMBO_FONTNAME && pToolBar->GetBarID() == IDR_MAINFRAME)
  {
   CXTPControlComboBox* pComboFont = new CXTPControlFontComboBox();
   pComboFont->SetDropDownListStyle(FALSE);
   
   lpCreateControl->pControl = pComboFont;
   return TRUE;
  }
  if (lpCreateControl->nID == ID_COMBO_FONTSIZE && pToolBar->GetBarID() == IDR_MAINFRAME)
  {
   CXTPControlComboBox* pComboSize = new CXTPControlSizeComboBox();
   pComboSize->SetDropDownListStyle();
   
   lpCreateControl->pControl = pComboSize;
   return TRUE;
  }
  if (lpCreateControl->nID == ID_COMBO_FONTCOLOR && pToolBar->GetBarID() == IDR_MAINFRAME)
  {
   CXTPControlPopupColor* pPopupColorText = new CXTPControlPopupColor();
   CXTPPopupBar* pColorBar = (CXTPPopupBar*)CXTPPopupToolBar::CreateObject();
   pColorBar->GetControls()->Add(new CXTPControlButtonColor(), ID_TEXT_AUTO);
   pColorBar->GetControls()->Add(new CXTPControlColorSelector(), ID_SELECTOR_TEXT);
   pColorBar->GetControls()->Add(new CXTPControlButtonColor(), ID_TEXT_MORE);
   pPopupColorText->SetCommandBar(pColorBar);
   pColorBar->InternalRelease();
   pColorBar->SetTearOffPopup(_T("Text Color"), IDR_COLORTEXT_POPUP, 0);
   pColorBar->EnableCustomization(FALSE);
   lpCreateControl->pControl = pPopupColorText;
   return TRUE;
  }
  if (lpCreateControl->nID == ID_COMBO_BGCOLOR && pToolBar->GetBarID() == IDR_MAINFRAME)
  {
   CXTPControlPopupColor* pPopupColorBack = new CXTPControlPopupColor();
   CXTPPopupBar* pColorBar = (CXTPPopupBar*)CXTPPopupToolBar::CreateObject();
   pColorBar->GetControls()->Add(new CXTPControlButtonColor(), ID_BACK_NONE);
   pColorBar->GetControls()->Add(new CXTPControlColorSelector(), ID_SELECTOR_BACK);
   pColorBar->GetControls()->Add(new CXTPControlButtonColor(), ID_BACK_MORE);
   pPopupColorBack->SetCommandBar(pColorBar);
   pColorBar->InternalRelease();
   pColorBar->SetTearOffPopup(_T("Back Color"), IDR_COLORBACK_POPUP, 0);
   pColorBar->EnableCustomization(FALSE);
   lpCreateControl->pControl = pPopupColorBack;
   return TRUE;
  }
 }
 
 return FALSE;
}
Back to Top
scs7309 View Drop Down
Newbie
Newbie
Avatar

Joined: 05 January 2007
Location: Korea, South
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote scs7309 Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2007 at 2:45am

My program source is here.

Please help me !!!
 
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 09 January 2007 at 3:08am

They are not activated because you didn't add handlers for them.

 
Copy code from GUI_OneNoteView.cpp  
 
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.