MapWindow Developer Team : MapWindow Discussion Forum
I'm working on a plug-in which will show a panel. When the panel is closed I want to unload the plug-in. These features are badly documented but I found a delegate function called AddOnCloseHandler which should do the trick. But I can't get it to work. Most probably because I d
Using panels and AddOnCloseHandler
Posted by: pmeems ()
Date: August 31, 2009 03:47PM

I'm working on a plug-in which will show a panel. When the panel is closed I want to unload the plug-in.
These features are badly documented but I found a delegate function called AddOnCloseHandler which should do the trick.
But I can't get it to work. Most probably because I don't use the delegate in the proper manner. I still find delegate a bit difficult ;)
Here's some code:
    /// <summary>
    /// This class holds all code used in this form
    /// </summary>
    public partial class TopPanel : Form
    {
        /// <summary>The reference to the MapWindow map object</summary>
        private MapWindow.Interfaces.IMapWin mapWin;

        /// <summary>The reference to the panel object</summary>
        private Panel topUIPanel = null;

        /// <summary>
        /// Initializes a new instance of the TopPanel class, used by the form
        /// </summary>
        /// <param name="mapWin">The reference to the MapWindow map object.</param>
        /// <param name="parentHandle">The window handle of the main MapWindow form.</param>
        public TopPanel(MapWindow.Interfaces.IMapWin mapWin, int parentHandle)
        {
            this.InitializeComponent();
            this.mapWin = mapWin;

            System.IntPtr tempPtr = (System.IntPtr)parentHandle;
            Form mapFrm = (Form)System.Windows.Forms.Control.FromHandle(tempPtr);

            mapFrm.AddOwnedForm(this);
             
            // The trick of creating dockable panels is to create a standard form with a panel,
            // this panel is used to create the dockable panel.

            // Create new MapWindow panel, the caption is the name of the form:
            this.topUIPanel = this.mapWin.UIPanel.CreatePanel(this.Name, MapWindow.Interfaces.MapWindowDockStyle.Top);

            // Add panel to the mapwindowpanel
            this.topUIPanel.Controls.Add(this.panel1);

            // Add handler
            MapWindow.Interfaces.OnPanelClose OnCloseFunction = Panel1_OnClose();
            this.mapWin.UIPanel.AddOnCloseHandler(this.Name, OnCloseFunction);
        }

        private MapWindow.Interfaces.OnPanelClose Panel1_OnClose()
        {
            // The Dispose method of the form removes the panel, closes the form and disposes it:
            this.Dispose();
            // Don't know what to return???????????
            return null;
        }
    }

Any help is much appreciated.

Thanks,

Paul

--
Don't forget to read the new documentation: www.mapwindow.org/documentation/mapwingis4.8
Join us Google+: MapWindow GIS Google+ Community
Join the MapWindow Group on LinkedIn! LinkedIn - MapWindow Group

Download the latest beta installer at:
tinyurl.com/mwMonthly 32-Bit
tinyurl.com/mwMonthlyx64 64-Bit
Follow me on Twitter MapWindow_nl to read when a new installer is published.

---
Paul Meems
The Netherlands
[www.bontepaarden.nl]
Release manager, configuration manager and
forum moderator of MapWindow GIS

Owner of MapWindow.nl - Support for
Dutch speaking users: www.mapwindow.nl

*******
Everything I say or write is my personal opinion and
not the opinion of the company I work for.
*******
View my profile on LinkedIn

Options: ReplyQuote
Re: Using panels and AddOnCloseHandler
Posted by: arjereza ()
Date: September 19, 2010 11:39PM

Good day all,

I would also like to know how the AddOnCloseHandler works. I also have trouble implementing the OnClosePanel interface. I tried looking over the mwIdentifier code on how it works but I can't seem to figure out what I am missing. I'm using VB.net by the way.

Thanks.

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: