![]() |
Call CXTPControlGallery from abutton |
Post Reply
|
| Author | |
cpede
Senior Member
Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683 |
Post Options
Thanks(0)
Quote Reply
Topic: Call CXTPControlGallery from abuttonPosted: 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
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
cpede
Senior Member
Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683 |
Post Options
Thanks(0)
Quote Reply
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
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
cpede
Senior Member
Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683 |
Post Options
Thanks(0)
Quote Reply
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
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
Posted: 11 March 2008 at 6:41am |
|
Hi,
Do you call EnsureVisible after pPopupBar->GetControls()->Add(pGallery); line ?
|
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
cpede
Senior Member
Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683 |
Post Options
Thanks(0)
Quote Reply
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); |
|
![]() |
|
cpede
Senior Member
Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683 |
Post Options
Thanks(0)
Quote Reply
Posted: 11 March 2008 at 8:50am |
|
Using xtpThemeOffice2007 instead of xtpThemeOffice2003 throws an assertion in ASSERT(pImageArrowGlyphs); when TrackPopupMenu is called.
-cpede
|
|
![]() |
|
Oleg
Senior Member
Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
Quote Reply
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 |
|
![]() |
|
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 |