0

I developed an extension with ArcGIS 10.4.1 that I can use through the extension menu and now I need it as a toolbar. The problem is that ArcGIS launches only the startup() event from the extension and not my newly added BaseToolBar.startup()

/// <summary>
/// Classe d'extension pour le contexte
/// </summary>
[Guid("4600d1fb-cac2-4f6d-a726-261abe40dfad")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Mrn.Taktik.ControleGis.ContexteExtension")]
public class ContexteExtension : IExtension, IExtensionConfig, IPersistVariant
{
       .  .  .  Parameters and Access variables  .  .  .

    public void Startup(ref object initializationData)
    {
        this.application = initializationData as IApplication;
        this.appStatus = this.application as IApplicationStatus;

        if (this.application != null)
        {
            contexteTakTik = ContexteTakTik.Instance;
            contexteTakTik.Initialiser(new IntPtr(this.application.hWnd));
            //// Wireup the events
            this.SetupEvents();
        }
    }

       .  .  .  #region COM Registration Functions  .  .  .
}

At this point, I simply created a BaseToolbar and copied what was inside my class into the new one. The only way to to amke it work right now is if I keep included the extension class as it is the only way for my code to enter Startup(). I tried to look online where it is first called but couldnt find anything. I need my code to go through BarreOutils.Startup() and not ContexteExtension.Startup().

/// <summary>
/// Description for ArcGISToolbar1.
/// </summary>
[Guid("bfeb9989-0c45-4db4-b12d-310efaa5d787")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("Mrn.Taktik.ControleGis.ArcGISToolbar1")]
public sealed class BarreOutils : BaseToolbar
{
.  .  .  Parameters and Access variables  .  .  .

    public void Startup(ref object initializationData)
    {
        this.application = initializationData as IApplication;
        this.appStatus = this.application as IApplicationStatus;

        if (this.application != null)
        {
            contexteTakTik = ContexteTakTik.Instance;
            contexteTakTik.Initialiser(new IntPtr(this.application.hWnd));
            //// Wireup the events
            this.SetupEvents();
        }
    }

       .  .  .  #region COM Registration Functions  .  .  .
}
0

I went through some other tools built and apparently you need your tools to work also as an extension and by that i mean, having both classes included in the project, concerning the problem I was having, I used only one or the other when in fact i needed both. There may be some deeper reasoning on why you need both and maybe there's also a possibility to have only one or the other but in my case, i do need both to work properly.

  • By having both, I then made sure to remove all the functions that were doubled from the extension class and the toolbar class. – Sauce Brune Jul 12 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.