Print Page | Close Window

OnCreateControl w/ CXTPToolbar base

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=3116
Printed Date: 21 December 2024 at 9:17am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: OnCreateControl w/ CXTPToolbar base
Posted By: craig
Subject: OnCreateControl w/ CXTPToolbar base
Date Posted: 27 October 2005 at 4:02pm

I have a class CFormatToolBar that derives from CXTPToolBar.  I'm trying to keep the creation of the controls in that toolbar contained within that class.  Is it possible to map the ON_XTP_CREATECONTROL() message in my derived class?  Right now, the OnCreateControl method isn't getting called, although the toolbar is loading ok.

E.g Will the following work in a CXTPToolBar derived class?

BEGIN_MESSAGE_MAP(CFormatToolBar, CXTPToolBar)ON_XTP_CREATECONTROL()
END_MESSAGE_MAP()

Thanks,

Craig

 




Replies:
Posted By: Oleg
Date Posted: 28 October 2005 at 3:57am

WM_XTP_CREATECONTROL sends only to parent CommandBars object (Frame).

You can catch it on frame and deliver to Toolbar object.

 



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: craig
Date Posted: 28 October 2005 at 1:59pm

ok.  That's what I'm doing currently.

--Craig

 



Posted By: craig
Date Posted: 28 October 2005 at 4:16pm

http://forum.codejock.com/uploads/craig/2005-10-28_161431_FormatToolBar.zip - 2005-10-28_161431_FormatToolBar.zip Well... it doesn't work.

 

This message appears in xtpcontrolcombobox.h in the following snippet:

AFX_INLINE int CXTPControlComboBox::AddString(CString str) {

return GetListBoxCtrl()->AddString(str);

}

 

I've attached the CFormatBar class files.

In CMainFrame I did the following to pass the messages on:

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)

ON_XTP_CREATECONTROL()

END_MESSAGE_MAP()

int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)

{

CXTPCommandBars* pCommandBars = GetCommandBars();

if (pCommandBars != NULL)

{

CXTPToolBar* pToolbar = pCommandBars->GetToolBar(IDR_FORMAT_TOOLBAR);

if (pToolbar)

{

CFormatToolBar* pFmtBar = (CFormatToolBar*) pToolbar;

return pFmtBar->OnCreateControl(lpCreateControl);

}

}

return FALSE;

}



Posted By: Oleg
Date Posted: 31 October 2005 at 1:40am

Don't use member variables

XTPControlComboBox m_fontSizeCombo;

create it dynamically:

CXTPControlComboBox* fontSizeCombo = new CXTPControlComboBox();

 

 



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: craig
Date Posted: 02 November 2005 at 3:03pm

Oleg,

OK... that sounds reasonable, but how can I get a hold of the control by ID?  E.g. by ID.

I see how to get a toolbar by ID, I can get a list of controls, but haven't been able to figure out how to get a control by its ID.  I need to modify this control in response to an event generated by a different control.

Thanks,

Craig

 



Posted By: Oleg
Date Posted: 04 November 2005 at 12:09am

Hello,

CXTPControl* pControl = pToolBar->GetControls()->FindControl(id);

but! don't forget that user can customize this toolbar and move button away.



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net