TrackPopupMenu Markup |
Post Reply |
Author | |
BobWansink
Groupie Joined: 24 January 2008 Status: Offline Points: 59 |
Post Options
Thanks(0)
Posted: 11 March 2009 at 7:44am |
Hi,
we've added a Contextmenu to our markupcode. Example: <TextBlock MouseRightButtonDown="ShowMenu">bla</TextBlock> with function ShowMenu: CMenu men; men.CreatePopupMenu(); men.AppendMenu(MF_STRING, 100, "Bla"); men.TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,pt.x,pt.y,this); // x and y are fixed, not GetCursorPos(); I want the menu to display at a specific location. If I click outside the menu with the left mousebutton, the menu disappears. Rightclicking outside the menu DOESN'T makes the menu disappear, but the ShowMenu function is immediately excecuted. This means the menu is . What can i do to make the menu disappear on both buttons? I think this has something to do with RightMouseButtonDown being excecuted again, even though the mouse has moved away from the element that called it. I've tried pArgs->SetHandled(), but that was to no avail. I'd appreciate any help. Thanks! |
|
Product: Xtreme ToolkitPro (MFC) version 13.0.0
Platform: Windows (32bit) - XP - Vista Language: Visual C++ |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Need to test. Show related code.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
BobWansink
Groupie Joined: 24 January 2008 Status: Offline Points: 59 |
Post Options
Thanks(0)
|
// XAML
<Border Style="{StaticResource TabButtonBorder}"> <Border Style="{StaticResource TabButton}"> <StackPanel Orientation="Horizontal"> <Image Style="{StaticResource ImageStyle}" Source="file://images/nieuweversie.png"/> <TextBlock MouseRightButtonDown="ShowContextMenu" Margin="5,7,16,0">Boe</TextBlock> </StackPanel> </Border> </Border> // // class ProjectCentrumXAMLPanel : public ZXAMLPanel // class ZXAMLPanel : public ZPanel, public CXTPMarkupContext void ProjectCentrumXAMLPanel::RightClickOnElement(CXTPMarkupObject * pSender, CXTPMarkupMouseButtonEventArgs* pArgs) { CXTPMarkupBorder * pEl = (CXTPMarkupBorder *) pSender; pArgs->SetHandled(); this->makeContextMenu(pEl); } void ZXAMLPanel::makeContextMenu(CXTPMarkupInputElement * pEl) { CRect r1(0,0,0,0); this->GetWindowRect(r1); elementDatRechterMuisMenuOpriep = pEl; CRect r = this->GetClientBoundingRect(pEl); CPoint pt(r1.left+r.left, r1.top+r.bottom); CMenu menu; menu.CreatePopupMenu(); UINT flags = MF_STRING; menu.AppendMenu(flags,1100,"Bob"); menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,pt.x,pt.y,this); } BEGIN_MESSAGE_MAP(ZXAMLPanel, CWnd) ON_COMMAND_RANGE(1000, 2000, processContextMenu) END_MESSAGE_MAP() // ZXAMLPanel virtual afx_msg void processContextMenu(UINT nID); void ZXAMLPanel::processContextMenu(UINT nID) { return; } void ProjectCentrumXAMLPanel::processContextMenu(UINT nID) { if (nID == 1100) this->OpenBestand(elementDatRechterMuisMenuOpriep, 0); if (nID == 1101) this->VerwijderBestand(elementDatRechterMuisMenuOpriep, 0); if (nID == 1102) this->OpslaanVersie(elementDatRechterMuisMenuOpriep, 0); if (nID == 1103) this->NieuweVersie(elementDatRechterMuisMenuOpriep, 0); if (nID == 1104) this->HernoemBestand(elementDatRechterMuisMenuOpriep, 0); if (nID == 1105) this->ArchiveerBestand(elementDatRechterMuisMenuOpriep, 0); if (nID == 1106) this->BackupBestand(elementDatRechterMuisMenuOpriep, 0); this->elementDatRechterMuisMenuOpriep = NULL; return; } |
|
Product: Xtreme ToolkitPro (MFC) version 13.0.0
Platform: Windows (32bit) - XP - Vista Language: Visual C++ |
|
BobWansink
Groupie Joined: 24 January 2008 Status: Offline Points: 59 |
Post Options
Thanks(0)
|
Hmm. I've managed to solve this problem via a work-around. Instead of using MouseLeftButtonDown or MouseRightButtonDown, I've started using MouseLeftButtonUp and MouseRightButtonUp. I'd still like to know what's wrong in the above code, in case I need something like this again.
|
|
Product: Xtreme ToolkitPro (MFC) version 13.0.0
Platform: Windows (32bit) - XP - Vista Language: Visual C++ |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hi,
Guess its something in our code - your looks fine :)
|
|
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 |