Print Page | Close Window

Call CXTPControlGallery from abutton

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=9809
Printed Date: 14 November 2025 at 7:21pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Call CXTPControlGallery from abutton
Posted By: cpede
Subject: Call CXTPControlGallery from abutton
Date Posted: 06 March 2008 at 10:28am
Is it possible to create and show a CXTPControlGallery directly from a button, or e.g. from a verb link in a property editor? It would be great if it is possible to just launch this control without the need of a menu or ribbon.
-cpede



Replies:
Posted By: Oleg
Date Posted: 07 March 2008 at 3:11pm
Hi,
its just 4 additional lines to create CXTPPopupBar, add gallery to it and run it with CXTPCommandBars::TrackPopupMenu.


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


Posted By: cpede
Date Posted: 07 March 2008 at 3:43pm
Maybe you could give me a little more insight in how to do it.
I cannot create the
CXTPControlGalleryItems::CreateItems(GetCommandBars()...
because I don have access to GetCommandBars ?
 
And how to attach it to a TrackPopupMenu ?
 
Thanks,
 
-cpede


Posted By: Oleg
Date Posted: 08 March 2008 at 6:52am
Hi,
You don't have CommandBars at all?
here sample for this case:
 
 
void CDialogSampleDlg::OnButton1()
{
 CXTPCommandBars* pCommandBars = (CXTPCommandBars*)CXTPCommandBars::CreateObject();
 pCommandBars->SetSite(this);
 pCommandBars->SetTheme(xtpThemeOffice2003);
 CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(pCommandBars);
 CPoint point;
 GetCursorPos(&point);
 CXTPControlGalleryItems* pItems = CXTPControlGalleryItems::CreateItems(pCommandBars, 100);
 pItems->SetItemSize(CSize(0, 20));
 CXTPControlGalleryItem* pItem = pItems->AddLabel(0);
 pItem->SetCaption(_T("Lines"));
 pItems->AddItem("Item");

 CXTPControlGallery* pGallery = new CXTPControlGallery();
 pGallery->SetItems(pItems);
 pPopupBar->GetControls()->Add(pGallery);
 pCommandBars->TrackPopupMenu(pPopupBar, TPM_NONOTIFY, point.x, point.y, this);
 
 
 pPopupBar->InternalRelease();
 pCommandBars->InternalRelease();
 
}


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


Posted By: cpede
Date Posted: 10 March 2008 at 5:43pm
Great it works!
 
One small issue, - how do I pre-select and scroll to a pre-selected item, before calling the TrackPopupMenu ?
 
It seems that SetSelectedItem works, but EnsureVisible is not working because of a missing GetParent ?
 
-cpede


Posted By: Oleg
Date Posted: 11 March 2008 at 6:41am
Hi,
Do you call EnsureVisible  after pPopupBar->GetControls()->Add(pGallery); line ?


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


Posted By: cpede
Date Posted: 11 March 2008 at 8:12am
Yes, it does the focus and selection. But if the item specified is not visible at startup, the control does not scroll into position.
 
pGallery->SetResizable();
pGallery->SetItemsMargin(0, 1, 0, 1);
pGallery->ShowLabels(FALSE);
pGallery->ShowBorders(TRUE);
pGallery->SetItems(pItems);
pPopupBar->GetControls()->Add(pGallery);
pGallery->SetSelectedItem(5);
pGallery->EnsureVisible(5);
UINT ret = pCommandBars->TrackPopupMenu(pPopupBar,
 TPM_NONOTIFY|TPM_RETURNCMD|TPM_LEFTALIGN|TPM_RIGHTBUTTON,
 point.x,point.y,pNode);


Posted By: cpede
Date Posted: 11 March 2008 at 8:50am
Using xtpThemeOffice2007 instead of xtpThemeOffice2003 throws an assertion in ASSERT(pImageArrowGlyphs); when TrackPopupMenu is called.
-cpede


Posted By: Oleg
Date Posted: 12 March 2008 at 2:10am

Hi,

You need add office2007 bitmaps to your  exe.

#include "Styles\Office2007Blue\Office2007Blue.rc"


-------------
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