Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 20

By Right-click displaying context menu on map

This is a discussion on By Right-click displaying context menu on map within the MapPoint Desktop Discussion forums, part of the Map Forums category; Right-click on a pushpin shows up a context menu. I want to display my own context menu by right-click on ...

  1. #1
    Banu is offline Junior Member White Belt
    Join Date
    Feb 2006
    Posts
    6

    By Right-click displaying context menu on map

    Right-click on a pushpin shows up a context menu. I want to display my own context menu by right-click on a pushpin instead of the default context menu. Any help will be appreciated.

    Thanks

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Install an event handler in BeforeClick event. 1 of the arguments is Cancel. If you set this to True the popupmenu will never popup.

    If you wants to popup your own menu, then do it outside the event handler. If you do not and a user does not click within 10 seconds you will have the Server Busy popup from mappoint. This is because a popup menu is nothing more than a modal form.

  3. #3
    ayla is offline Junior Member White Belt
    Join Date
    Jan 2006
    Posts
    4
    Hi Wilfried,
    I have exactly the same problem as Banu. I followed your suggestion of creating an event handler for Beforeclick mappoint event and forcing the argument Cancel to be TRUE. But unfortunately, the default mappoint context menu appears.
    Do you may be know the reason for this behaviour? Or how I can solve it in another way.
    Thank you very much,

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    I just tryed the following:

    Code:
        private void MP_BeforeClick_1(object sender, AxMapPoint._IMappointCtrlEvents_BeforeClickEvent e)
        {
            if (e.button == 2)
                e.cancel = true;
    I I have no popup if I click right mouse butten. Did you do something different ?

  5. #5
    ayla is offline Junior Member White Belt
    Join Date
    Jan 2006
    Posts
    4
    Hi,
    here you have my code, I think I am doing exactly the same, don't I?
    I debugged teh routine and every time that I right-clicked on the map, the function is executed the if clause is true but the default mappoint message
    still appears.


    void CMyAppView::OnBeforeClickMapMp(long Button, long Shift, long X, long Y, BOOL FAR* Cancel)
    {
    if(Button == MY_MOUSE_RIGHT_CLICK)
    {
    //mappoint popup menu will never popup
    *Cancel = TRUE;

    }
    }


    Thank you for your help!

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    You do indeed exacly the same. Hmm thinking...

    Unless there is a bug in the TRUE. "Normally" 0 is false, and antithing that is not 0 is true. I recall my one of the Delphi versions (I think 2) where Borland wrote a bug in such a way that they interpreted -1 as True, 0 as false, but any other number was also false. This was leading to problems interfacing with win32 API and also with other apps (COM/DLL) of course.

    So what if there is such a bug ? Is this C ? Then you can try it, because in C you can assign almost anything to anithing:

    *Cancel = -1;
    *Cancel = (!0);
    *Cancel = 0xFFFF;
    ... or other combinations ...

  7. #7
    Banu is offline Junior Member White Belt
    Join Date
    Feb 2006
    Posts
    6
    Hi Wilfried,

    I can successfully hide mappoint's menu, but having problem with showing my menu. The syntax to show a context menu is

    Show(Control control, Point pos)

    What do I pass for control, MapPoint application is not a control. How do I tell menu to pop up on the mappoint window.

    Thanks

  8. #8
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    is this C# ?

    Then you have a lots of overload method. Try:

    Code:
    PopupMenu.Show(MousePosition);

  9. #9
    Banu is offline Junior Member White Belt
    Join Date
    Feb 2006
    Posts
    6
    Yes, it is C# 2005. Under my MSDN library I don't see any class by PopupMenu name. Is it a third party tool? By further search I found "DataDynamics.SharpUI.Toolbars.PopupMenu" class. Is this same class you are talking about. If not then can you tell me the name of namespace, PopupMenu class lies under.

  10. #10
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    PopupMenu was the name I given it. Sorry to be confusing

    No tirth party. I also use VS2005. it is in:
    System.Windows.Forms.ContextMenuStrip.

    And the ContexMenuStrip is in the toolbox in Menu's and toolbars. I think it is default there as I just upgraded from Beta2 to full version and I see it there.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Disable Context menu
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 12
    Last Post: 12-23-2008, 01:05 PM
  2. Click events of context menu are not firing....
    By Learner in forum MapPoint Desktop Discussion
    Replies: 6
    Last Post: 05-12-2008, 03:33 PM
  3. Custom context menu
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 09-10-2004, 11:15 PM
  4. Extending MapPoint - How about the Context Menu Enhancements
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-10-2004, 10:38 AM
  5. VB.NET & overriding the map point context menu...
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 09-05-2002, 09:25 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96