![]() |
Subclassing CXTPRibbonBar |
Post Reply ![]() |
Author | |
Rhogan ![]() Newbie ![]() ![]() Joined: 16 March 2007 Location: United Kingdom Status: Offline Points: 26 |
![]() ![]() ![]() ![]() ![]() Posted: 15 May 2007 at 12:52pm |
I would like to create a subclass of CXTPRibbonBar with its own message map so it can create itself and handle the message processing. Yes, I can have my main window do all this, but I prefer to work things in this manner. I have most things working, but not having used MFC for a few years, I forget how to get my message map working. I could post my code here, but perhaps it is better if some tech would just post some brief tips. Here is some of my code. Please advise on how to get things working so the message map works and constructor will create the ribbon groups without giving an exception:
class _XTP_EXT_CLASS CRibbon: public CXTPRibbonBar { DECLARE_DYNCREATE(CRibbon) DECLARE_MESSAGE_MAP() public: CRibbon(); int OnCreate(LPCREATESTRUCT lpCreateStruct); bool Init(); protected: // message map functions afx_msg void OnRibbonTabChanged(NMHDR*, LRESULT*); }; IMPLEMENT_DYNCREATE(CRibbon, CXTPRibbonBar) BEGIN_MESSAGE_MAP(CRibbon, CXTPRibbonBar) ON_NOTIFY(TCN_SELCHANGE, XTP_ID_RIBBONCONTROLTAB, OnRibbonTabChanged) END_MESSAGE_MAP() CRibbon::CRibbon() { TRACE("CRibbon constructor\n"); // unable to create ribbon elemtns here else exception } int CRibbon::OnCreate(LPCREATESTRUCT lpCreateStruct) { // this function is never called; surprising if (CXTPRibbonBar::OnCreate(lpCreateStruct) == -1) return -1; // I notice source uses SetupHook() here; do I need it? return 0; } // my main window calls pRibbon->Init() after // creating object since constructor cannot create // elements without giving exception bool CRibbon::Init() { CMainFrame* pMainFrame = (CMainFrame*) AfxGetMainWnd(); CXTPCommandBars* pBars = pMainFrame->GetCommandBars(); // start creating everything... } |
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
OnCreate never called because you didn't add ON_WM_CREATE() in message map.
e.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
Rhogan ![]() Newbie ![]() ![]() Joined: 16 March 2007 Location: United Kingdom Status: Offline Points: 26 |
![]() ![]() ![]() ![]() ![]() |
![]() ![]() |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |