Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Adding Ribbon to existing Project
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Adding Ribbon to existing Project

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

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Topic: Adding Ribbon to existing Project
    Posted: 22 May 2008 at 11:14am
Hello,
I have a MFC program that I would like to add a ribbon too.
I tried to cut and paste the code form the samples but no avail.
I am not a programmer by trade im a hardware engineer that got this dumped in my lap, so forgive me if Im asking dump questions:
 
This is the code I added
 
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
 }
 
 if (!InitCommandBars())
  return -1;
 CXTPCommandBars* pCommandBars = GetCommandBars();
 pCommandBars->SetTheme(xtpThemeRibbon);
 
 m_wndStatusBar.SetFont(pCommandBars->GetPaintManager()->GetIconFont());
 m_wndStatusBar.SetDrawDisabledText(FALSE);
 m_wndStatusBar.SetCommandBars(pCommandBars);
 m_wndStatusBar.GetStatusBarCtrl().SetMinHeight(22);
 m_wndStatusBar.GetPane(0)->SetMargins(8, 1, 2, 1);
 ////////////////////////////////////////////////////////////////////////// 
 // IMPORTANT:
 // Ribbon bitmaps resources by default located in application executable.
 //
 // You also can specify handle to find ribbon resources:
 //((CXTPOffice2007Theme*)XTPPaintManager())->SetImageHandle(hHandle);
 //HMODULE hModule = LoadLibrary(m_csStylesPath + _T("Office2007Blue.dll"));
 //((CXTPOffice2007Theme*)pCommandBars->GetPaintManager())->SetImageHandle(hModule);
 CXTPToolTipContext* pToolTipContext = GetCommandBars()->GetToolTipContext();
 pToolTipContext->SetStyle(xtpToolTipOffice2007);
 pToolTipContext->ShowTitleAndDescription();
 pToolTipContext->SetMargin(CRect(2, 2, 2, 2));
 pToolTipContext->SetMaxTipWidth(180);
 pToolTipContext->SetFont(pCommandBars->GetPaintManager()->GetIconFont());
 pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault);
 pCommandBars->GetCommandBarsOptions()->bToolBarAccelTips = TRUE;
 pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME);
 LoadIcons();
 if (!CreateRibbonBar())
 {
  TRACE0("Failed to create ribbon\n");
  return -1;
 }
 m_wndClient.Attach(this, FALSE);
 m_wndClient.GetToolTipContext()->SetStyle(xtpToolTipOffice2007);
 m_bShowWorkspace = FALSE;
 m_wndClient.ShowWorkspace(m_bShowWorkspace);

 LoadCommandBars(_T("CommandBars"));

 return 0;
};
 
Basically when compilled I get alot of errors
Did I miss something?
 
Thanks in advance
Derrek
Derrek
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: 22 May 2008 at 2:09pm

Hi,

you need to derive CMainFrame from CXTPFrameWnd...
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DerrekCurtis View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Posted: 22 May 2008 at 2:42pm
Hello,
Thanks for the reply,
Could you describe how to do this?
 
Thanks
Derrek
 
Derrek
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: 22 May 2008 at 3:02pm

Hi,

Open mainfrm.h and replace
CMainFrame : public CMDIFrameWnd to
 
CMainFrame : public CXTPMDIFrameWnd.
 
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DerrekCurtis View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Posted: 22 May 2008 at 3:21pm
 
Oleg,
I had already done that but I get the following errors I think I may be missing a lib or link
 
Derrek
 
 
 
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1198) : error C2065: 'm_wndStatusBar' : undeclared identifier
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1198) : error C2228: left of '.Create' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1199) : error C2228: left of '.SetIndicators' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1213) : error C2228: left of '.SetFont' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1214) : error C2228: left of '.SetDrawDisabledText' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1215) : error C2228: left of '.SetCommandBars' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1216) : error C2228: left of '.GetStatusBarCtrl' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1216) : error C2228: left of '.SetMinHeight' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1217) : error C2228: left of '.GetPane' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1217) : error C2227: left of '->SetMargins' must point to class/struct/union
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1241) : error C2065: 'LoadIcons' : undeclared identifier
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1243) : error C2065: 'CreateRibbonBar' : undeclared identifier
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1249) : error C2065: 'm_wndClient' : undeclared identifier
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1249) : error C2228: left of '.Attach' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1250) : error C2228: left of '.GetToolTipContext' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1250) : error C2227: left of '->SetStyle' must point to class/struct/union
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1253) : error C2228: left of '.ShowWorkspace' must have class/struct/union type
C:\projects\commandvideoWorkshop\Com_Video_Workshop\Oramadro\MainFrm.cpp(1658) : error C2084: function 'int __thiscall CMainFrame::OnCreate(struct tagCREATESTRUCTA *)' already has a body
Moredata.cpp
Derrek
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: 23 May 2008 at 1:32am
Hi,
Please hire developer :-)
read error descriptions, they have all information you need.
 
Think better solution for you take Ribbon MDI sample and rename it for your project.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DerrekCurtis View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2008 at 11:41am

Oleg,

I have fixed all the obvious errors but I have a few left:
        C:\Program Files\Codejock Software\MFC\Xtreme CommandBars v11.2.2\Source\Common/XTPMacros.h(98) : see previous definition of 'SAFE_RELEASE'
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1596) : error C2065: 'InitCommandBars' : undeclared identifier
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1599) : error C2065: 'GetCommandBars' : undeclared identifier
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1599) : error C2440: 'initializing' : cannot convert from 'int' to 'class CXTPCommandBars *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1619) : error C2227: left of '->GetToolTipContext' must point to class/struct/union
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1639) : error C2664: 'Attach' : cannot convert parameter 1 from 'class CMainFrame *const ' to 'class CXTPMDIFrameWnd *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1646) : error C2065: 'LoadCommandBars' : undeclared identifier
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1654) : error C2440: 'initializing' : cannot convert from 'int' to 'class CXTPCommandBars *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1675) : error C2440: 'initializing' : cannot convert from 'int' to 'class CXTPCommandBars *'
        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(1794) : error C2065: 'lpCreateStruct' : undeclared identifier
C:\projects\VideoWorkShop\winvideo\winvideo\MainFrm.cpp(2040) : error C2227: left of '->OnSetPreviewMode' must point to class/struct/union
 
What else should I be looking at.
 
Thanks
Derrek
Derrek
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: 27 May 2008 at 12:26pm
Hi,
Paste full MainFrm.h file
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DerrekCurtis View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Posted: 27 May 2008 at 12:56pm
Oleg,
I have done that and the errors are still there.
 
Derrek
Derrek
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: 28 May 2008 at 12:54am
Hi,
 
I mean paste to forum to check what you have there.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
DerrekCurtis View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Posted: 28 May 2008 at 2:33pm

Oleg,

I got the project to compile however I have a linking error now:
 
MainFrm.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall CMainFrame::Create(char const *,char const *,unsigned long,struct tagRECT const &,class CWnd *,unsigned int,struct CCreateContext *)" (?Create@CMainFrame@@UAEHPB
D0KABUtagRECT@@PAVCWnd@@IPAUCCreateContext@@@Z)
Release/OramaDro.exe : fatal error LNK1120: 1 unresolved externals
 
Any suggestions?
 
Thanks
Derrek
Derrek
Back to Top
Smucker View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 February 2008
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote Smucker Quote  Post ReplyReply Direct Link To This Post Posted: 28 May 2008 at 3:42pm
CXTPMDIFrameWnd::Create is inherited from CFrameWnd:

virtual BOOL Create(LPCTSTR lpszClassName,
    LPCTSTR lpszWindowName,
    DWORD dwStyle = WS_OVERLAPPEDWINDOW,
    const RECT& rect = rectDefault,
    CWnd* pParentWnd = NULL,        // != NULL for popups
    LPCTSTR lpszMenuName = NULL,
    DWORD dwExStyle = 0,
    CCreateContext* pContext = NULL);

I think you left out lpszMenuName (use NULL for no menu).


Product: Xtreme Toolkit Pro version 13.2 (Unicode, static build)

Platform: Windows 200x/XP/Vista/Win7 (32/64 bit)

Language: Visual C++ 9.0 (Studio 2008)

Back to Top
DerrekCurtis View Drop Down
Newbie
Newbie
Avatar

Joined: 20 May 2008
Status: Offline
Points: 7
Post Options Post Options   Thanks (0) Thanks(0)   Quote DerrekCurtis Quote  Post ReplyReply Direct Link To This Post Posted: 28 May 2008 at 3:52pm
Thanks,
Ill take a look at that is it in MainFrm.cpp?
 
Derrek
Derrek
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.