Print Page | Close Window

How to put a CXTPDatePickerControl in a RibbonBar

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=9290
Printed Date: 16 July 2025 at 8:18am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to put a CXTPDatePickerControl in a RibbonBar
Posted By: shineryu
Subject: How to put a CXTPDatePickerControl in a RibbonBar
Date Posted: 14 January 2008 at 12:04am
I want to put a CXTPDatePickerControl in a RibbonBar.
Please give me some idea!
 
if I create a DatePickerComboBox like the DatePicker Sample, how to put it in ribbonbar?
 
and is there any better idea?
 
sincerely



Replies:
Posted By: Oleg
Date Posted: 14 January 2008 at 5:32am
Hi,
Use CXTPControlCustom.


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


Posted By: shineryu
Date Posted: 14 January 2008 at 5:58am
thanks, oleg!
but I don't know how to use CXTPControlCustom!
 
i write my code like this:
 
 CXTPRibbonTab* pTab = pRibbonBar->AddTab(ID_TAB_CALENDAR);
 CXTPRibbonGroup* pGroup = pTab->AddGroup(ID_GROUP_CALENDAR);
 pGroup->SetControlsCentering(true);
 CXTPControlCustom* pDatePicker = new CXTPControlCustom();
 CXTPDatePickerControl* pDatePickerCtrl = new CXTPDatePickerControl();
 pDatePicker->SetControl(pDatePickerCtrl);
 pGroup->Add(pDatePicker, ID_DATE_PICKER);
 
it doesn't show the datepicker!
 
help me


Posted By: shineryu
Date Posted: 14 January 2008 at 6:56am
I think i find what is wrong.
I modified my code like this:
 
 pTab = pRibbonBar->AddTab(ID_TAB_CALENDAR);
 CXTPRibbonGroup* pGroup = pTab->AddGroup(ID_GROUP_CALENDAR);
 pGroup->SetControlsCentering(true);
 CXTPControlCustom* pDatePicker = new CXTPControlCustom();
 CXTPDatePickerControl* pDatePickerCtrl = new CXTPDatePickerControl();
 pDatePickerCtrl->Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 300, 128), pRibbonBar, ID_DATE_PICKER_CTRL);
 pDatePicker->SetControl(pDatePickerCtrl);
 pGroup->Add(pDatePicker, ID_DATE_PICKER);
 
then it shows on ribbon. but, because the height of CXTPDatePickerControl is bigger than the height of RibbonBar, it shows only the top of CXTPDatePickerControl. it's ugly!
 
who can give me a better idea?
thanks!


Posted By: Oleg
Date Posted: 14 January 2008 at 9:38am
Hi,
try DatePickerComboBox  instead of CXTPDatePickerControl


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


Posted By: shineryu
Date Posted: 15 January 2008 at 8:26am
thanks a lot.
 
but i don't like DatePickerComboBox, because it is not derived from CXTPControlComboBox.
Can u show me how to derive it from CXTPControlComboBox?
 
i find another choice. like this:
 
 pTab = pRibbonBar->AddTab(ID_TAB_CALENDAR);
 CXTPRibbonGroup* pGroup = pTab->AddGroup(ID_GROUP_CALENDAR);
 pGroup->SetControlsCentering(true);
 pControl = pGroup->Add(xtpControlSplitButtonPopup, ID_DATE_TEXT); // just static text to show date
 pControl->SetID(0);
 pControl->SetStyle(xtpButtonCaption);
 CXTPControlCustom* pDatePicker = new CXTPControlCustom();
 CXTPDatePickerControl* pDateCtrl = new CXTPDatePickerControl();
 pDateCtrl->Create(WS_TABSTOP | WS_CHILD, CRect(0, 0, 290, 400), pRibbonBar, ID_DATE_PICKER_CTRL);
  pDatePicker->SetControl(pDateCtrl);
  pDatePicker->SetFlags(xtpFlagManualUpdate);
 pControl->GetCommandBar()->GetControls()->Add(pDatePicker, ID_DATE_PICKER);

 
It's nice except one problem. after i clicked the down arrow, the DatePicker is shown as a drop list, and it's ok. but it doesn't disappear after i cliked a 'date'!


Posted By: Oleg
Date Posted: 15 January 2008 at 8:45am
Hello,
 
You have manually catch it and close popup - GetCommandBars()->ClosePopups().


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


Posted By: shineryu
Date Posted: 15 January 2008 at 10:16pm
thank u very much!
 
And, it will be very appreciate if u teach me how to "catch it menually".
 
Oleg !


Posted By: Oleg
Date Posted: 16 January 2008 at 3:19am
Here sample:
 
https://forum.codejock.com/uploads/20080116_031903_Ribbon.zip - Ribbon.zip


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


Posted By: shineryu
Date Posted: 16 January 2008 at 5:11am
Excellent!
Thank you very much!



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