How to Get a point outside a VB.form in Button Add-ins?

814
4
Jump to solution
12-07-2013 08:56 AM
EnzheLu
New Contributor II
Well, I have already find some way to get a point. However, they cannot work appropritately. For example, OnMouseDown event is not exist in Button Add-in classes. Furthermore, OnMouseDown Event in VB Forms can only work in side the form. So I sincerely asking for if there is any other way to obtain a point outside the form within Button Add-ins? If it is appropriate, would you like to show me the sample of codes? I will be really appreciate of it.:cool:
0 Kudos
1 Solution

Accepted Solutions
SusanGoddard
New Contributor
I believe this is what you are trying to do, you will need to reference the appropriate objects in your code as well


        public IPoint getpointclicked(IMxApplication mxapp, ISymbol symbol)
        {
            IAppDisplay appdisplay = mxapp.Display;
            IScreenDisplay screendisplay = appdisplay.FocusScreen as IScreenDisplay;
            IRubberBand rubberband = new RubberPoint();
            IGeometry geo = new Point();
            Boolean result = rubberband.TrackExisting(screendisplay, symbol, geo);
            if (result)
            {
                IPoint point = rubberband.TrackNew(screendisplay, symbol) as IPoint;
                return point;
            }

            return null;
        }

View solution in original post

0 Kudos
4 Replies
AlexandraFairbarns
New Contributor III
Well, I have already find some way to get a point. However, they cannot work appropritately. For example, OnMouseDown event is not exist in Button Add-in classes. Furthermore, OnMouseDown Event in VB Forms can only work in side the form. So I sincerely asking for if there is any other way to obtain a point outside the form within Button Add-ins? If it is appropriate, would you like to show me the sample of codes? I will be really appreciate of it.:cool:

What are you trying to do? It would appear to me that you want to create a tool rather than a button. Buttons should be used where you do not need a constant response from the user i.e. it does one job - opens a dockable window or windows form or runs a script. You can do the same with a tool. However, whilst the tool is switched on Arc will continue to send information on what the user is doing to the tool, hence the OnMouseDown event. In this way you can pass information to a form if you are using one. Personally I have not attempted what you are trying - but a google search did bring this up: http://stackoverflow.com/questions/5528543/getting-position-of-mouse-cursor-when-clicked-out-side-th...
0 Kudos
SusanGoddard
New Contributor
I believe this is what you are trying to do, you will need to reference the appropriate objects in your code as well


        public IPoint getpointclicked(IMxApplication mxapp, ISymbol symbol)
        {
            IAppDisplay appdisplay = mxapp.Display;
            IScreenDisplay screendisplay = appdisplay.FocusScreen as IScreenDisplay;
            IRubberBand rubberband = new RubberPoint();
            IGeometry geo = new Point();
            Boolean result = rubberband.TrackExisting(screendisplay, symbol, geo);
            if (result)
            {
                IPoint point = rubberband.TrackNew(screendisplay, symbol) as IPoint;
                return point;
            }

            return null;
        }
0 Kudos
DuncanHornby
MVP Notable Contributor
If you want to interact with the map window you need to be using a Tool AddIn button not the Button AddIn which does something once you clicked on it.
0 Kudos
EnzheLu
New Contributor II
I believe this is what you are trying to do, you will need to reference the appropriate objects in your code as well


        public IPoint getpointclicked(IMxApplication mxapp, ISymbol symbol)
        {
            IAppDisplay appdisplay = mxapp.Display;
            IScreenDisplay screendisplay = appdisplay.FocusScreen as IScreenDisplay;
            IRubberBand rubberband = new RubberPoint();
            IGeometry geo = new Point();
            Boolean result = rubberband.TrackExisting(screendisplay, symbol, geo);
            if (result)
            {
                IPoint point = rubberband.TrackNew(screendisplay, symbol) as IPoint;
                return point;
            }

            return null;
        }


Actually I just cut the function and replace with another feature in my add-ins. But I think this really would work with my old version add-ins. Thank you. I really appreciate for your help
0 Kudos