Codejock Forums Homepage
Forum Home Forum Home > General > XAML Snippets
  New Posts New Posts RSS Feed - TrackPopupMenu Markup
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

TrackPopupMenu Markup

 Post Reply Post Reply
Author
Message
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post Topic: TrackPopupMenu Markup
    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++
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2009 at 2:27am
Hi,
 
Need to test. Show related code.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2009 at 3:47am
// 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++
Back to Top
BobWansink View Drop Down
Groupie
Groupie
Avatar

Joined: 24 January 2008
Status: Offline
Points: 59
Post Options Post Options   Thanks (0) Thanks(0)   Quote BobWansink Quote  Post ReplyReply Direct Link To This Post Posted: 12 March 2009 at 6:51am
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++
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 13 March 2009 at 2:08am
Hi,
 
Guess its something in our code - your looks fine :)
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.234 seconds.