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 13

Programmatically calling Toolbar buttons

This is a discussion on Programmatically calling Toolbar buttons within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, I was wondering if there was a way to programmatically the toolbar buttons. I want to make my own ...

  1. #1
    Kevin_Williams is offline Junior Member Yellow Belt
    Join Date
    Nov 2006
    Posts
    20

    Programmatically calling Toolbar buttons

    Hi,
    I was wondering if there was a way to programmatically the toolbar buttons.
    I want to make my own custom toolbar instead of using mappoint's navigation and drawing toolbars.
    TIA

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

    Re: Programmatically calling Toolbar buttons

    Hi,

    You can send messages for it. There is an article somewhere on this site. Try a search on 'accessing hidden features' or something similar.

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

  4. #4
    Kevin_Williams is offline Junior Member Yellow Belt
    Join Date
    Nov 2006
    Posts
    20

    Re: Programmatically calling Toolbar buttons

    thanks for the quick response
    i tried downloading the zip files, but it seems like the URL is no longer valid...

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

    Re: Programmatically calling Toolbar buttons

    Hi,

    This article points the things out: Extending the MapPoint ActiveX Control - Pt. I - MapPoint Articles - MP2K Magazine

    I dont know about the Url. Can you maybe try to contact the author?

  6. #6
    Kevin_Williams is offline Junior Member Yellow Belt
    Join Date
    Nov 2006
    Posts
    20

    Re: Programmatically calling Toolbar buttons

    Thanks WilFried
    I read Extending the MapPoint ActiveX Control - Pt. I and Extending the MapPoint ActiveX Control - Pt. II and I think I understand how it works.

    I'm trying to implement this in C#.
    I saw your code in the "Access some hidden features" thread and it was pretty helpful.

    I think I have all the pieces, but I'm not sure how to FindChildWindow in C#...

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

    Re: Programmatically calling Toolbar buttons

    Hi,

    I think it is just a class method to return the windows handle. I think you can use FindWindow. It take the classname and windowcaption, both are optional, it returns the handle. In C# like this:

    Code:
    [DllImport("User32.dll")]
    public static extern IntPtr FindWindow(string ClassName, string WindowName);

  8. #8
    Kevin_Williams is offline Junior Member Yellow Belt
    Join Date
    Nov 2006
    Posts
    20

    Re: Programmatically calling Toolbar buttons

    thanks so much for all your help Wilfried
    i got most of the stuff i wanted to work

    i pretty much used the Extending the MapPoint ActiveX control guide to understand the concept.
    from there, i did my code in C#

    these are the class method i used
    [DllImport("user32.dll", EntryPoint = "FindWindowA")]
    private static extern IntPtr FindWindow(string className, string windowTitle);
    [DllImport("user32.dll")]
    private static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, IntPtr windowTitle);
    [DllImport("user32.dll")]
    private static extern Boolean PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
    i found the map point handle as mentioned in the article (i'm using mappoint 2006)
    private const uint WM_COMMAND = 0x111;
    IntPtr hwnd;
    IntPtr mapPointHwnd ;

    hwnd = FindWindow(null, Resources.APP_TITLE);
    hwnd = FindWindowEx(hwnd, IntPtr.Zero, "ATL:10024320", IntPtr.Zero);
    hwnd = FindWindowEx(hwnd, IntPtr.Zero, "ATL:100240A0", IntPtr.Zero);
    mapPointHwnd = FindWindowEx(hwnd, IntPtr.Zero, "AfxFrameOrView70", IntPtr.Zero);
    i used spy++ to find the WM_COMMANDs and used PostMessage to invoke the command i wanted in my program
    // this invokes the scribble draw tool
    PostMessage(mapPointHwnd, WM_COMMAND, 58205, 0);

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

    Re: Programmatically calling Toolbar buttons

    Hi,

    thx for feedback it sure will benefit other user.

  10. #10
    faniemeiring is offline Junior Member White Belt
    Join Date
    Mar 2007
    Posts
    5

    Re: Programmatically calling Toolbar buttons

    A small change to Kevin's code made it work for me.
    If the map control is contained on any other component than the form (or window) itself it did not work for me:

    Code:
    hwnd = FindWindow(null, Resources.APP_TITLE);

    This line of code finds the handle to the form your control is contained on and can be replaced by:
    Code:
    hwnd = myForm.Handle;

    SO: if your control is on anything other than the form you can use:
    Code:
     hwnd = myPanel.Handle;

    or
    Code:
     hwnd = myToolStripContainer1.ContentPanel.Handle; //in my case

    Then the rest is as Kev had it before:

    Code:
    hwnd = FindWindowEx(hwnd, IntPtr.Zero, "ATL:10024320", IntPtr.Zero);
     hwnd = FindWindowEx(hwnd, IntPtr.Zero, "ATL:100240A0", IntPtr.Zero);
     mapPointHwnd = FindWindowEx(hwnd, IntPtr.Zero, "AfxFrameOrView70", IntPtr.Zero);

    Thanks for all the posts and code to solve this. It makes life easier...

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. Creating a new toolbar
    By alt-088 in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 11-14-2004, 07:38 AM
  2. Drawing an Oval Using The Toolbar - QueryCircle?
    By Steve Wenck in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-16-2004, 01:49 PM
  3. Cancel Mouse Buttons in Mappoint using VB.NET
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 02-27-2004, 06:20 AM
  4. 911 outbound calling
    By LLurie in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 04-21-2003, 10:41 AM
  5. VBA calling MP2k2
    By rkehn in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 01-15-2003, 12:47 PM

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