MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Programmatically calling Toolbar buttons

This is a discussion on Programmatically calling Toolbar buttons within the MapPoint 2006/2009 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 ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack (2) Thread Tools Display Modes
  2 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-29-2006
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 11-29-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 11-29-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Re: Programmatically calling Toolbar buttons

Hi,

found it: Access some hidden features in MapPoint2002 ActiveX control
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 11-30-2006
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 12-01-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 12-01-2006
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#...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 12-02-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 12-05-2006
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
Quote:
[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)
Quote:
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
Quote:
// this invokes the scribble draw tool
PostMessage(mapPointHwnd, WM_COMMAND, 58205, 0);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 12-05-2006
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,122
Re: Programmatically calling Toolbar buttons

Hi,

thx for feedback it sure will benefit other user.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10 (permalink)  
Old 03-07-2007
Junior Member
White Belt
 
Join Date: Mar 2007
Posts: 3
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...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
buttons, calling, programmatically, toolbar


LinkBacks (?)
LinkBack to this Thread: http://www.mapforums.com/programmatically-calling-toolbar-buttons-5417.html

Posted By For Type Date
gmane.comp.gis.mappoint This thread Refback 03-11-2008 03:43 PM
The Magazine for MapPoint - MP2K Magazine This thread Refback 12-01-2006 04:44 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Creating a new toolbar alt-088 MapPoint 2006/2009 Discussion 4 11-14-2004 07:38 AM
Drawing an Oval Using The Toolbar - QueryCircle? Steve Wenck MapPoint 2006/2009 Discussion 1 08-16-2004 01:49 PM
Cancel Mouse Buttons in Mappoint using VB.NET Anonymous MapPoint 2006/2009 Discussion 0 02-27-2004 06:20 AM
911 outbound calling LLurie MapPoint 2006/2009 Discussion 4 04-21-2003 10:41 AM
VBA calling MP2k2 rkehn MapPoint 2006/2009 Discussion 2 01-15-2003 12:47 PM


All times are GMT -5. The time now is 11:07 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


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