Showing toolbar and getting IEApp

Add-in Express™ Support Service
That's what is more important than anything else

Showing toolbar and getting IEApp
 
Rodrigo Oliveira




Posts: 27
Joined: 2009-06-15
Hi all,

My problem:

I start a browser with the page already loaded and my toolbar disabled (hided). When I enable (show) the toolbar on browser and try to get IEApp (WebBrowser), it is comming null.

How I can get IEApp instantiated?

Thanks.

Rodrigo
Posted 09 Mar, 2010 07:37:34 Top
Thiarley Fontenele




Posts: 1
Joined: 2010-03-09
I have the same problem here. :!:
Posted 09 Mar, 2010 11:47:57 Top
Lobo Junior




Posts: 1
Joined: 2010-03-09
This question is very important for me too.

I am studing addin API, but without sucess. :cry:
Posted 09 Mar, 2010 11:56:35 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
I've just created an IE Toolbar project using the latest build of Add-in Express 2010 for IE and .NET (6.1.368), registered the toolbar, opened IE 8, hid the toolbar and clicked Disable in the dialog, re-started IE 8, made the toolbar visible in the main menu and clicked Enable in the corresponding dialog. When the toolbar was shown, I clicked a toolbar button and got the following message:
IEApp != null

My code is as follows:
using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Windows.Forms;
using IE = Interop.SHDocVw;
 
namespace MyIEToolBar3
{
    /// <summary>
    /// Add-in Express for Internet Explorer Toolbar
    /// </summary>
    [ComVisible(true), Guid("5894F5EB-C0B0-4DE8-862C-0CB7E3EF7E87")]
    public class IEToolbarModule : AddinExpress.IE.ADXIEToolbarModule
    {
        public IEToolbarModule()
        {
            InitializeComponent();
        }

        private Button button1;
 
        #region Component Designer generated code
        /// <summary>
        /// Required by designer
        /// </summary>
        private System.ComponentModel.IContainer components;
 
        /// <summary>
        /// Required by designer support - do not modify
        /// the following method
        /// </summary>
        private void InitializeComponent()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(11, 1);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(111, 22);
            this.button1.TabIndex = 0;
            this.button1.Text = "button1";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // IEToolbarModule
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.Controls.Add(this.button1);
            this.HelpText = "erwerw";
            this.MenuText = "qqq";
            this.Name = "IEToolbarModule";
            this.Position = AddinExpress.IE.ADXIEToolBarPosition.tbpNewRow;
            this.Size = new System.Drawing.Size(300, 24);
            this.Title = "qqq";
            this.ResumeLayout(false);

        }
        #endregion
 
        #region ADX automatic code
 
        // Required by Add-in Express - do not modify
        // the methods within this region
 
        public override System.ComponentModel.IContainer GetContainer()
        {
            if (components == null)
                components = new System.ComponentModel.Container();
            return components;
        }
 
        [ComRegisterFunctionAttribute]
        public static void RegisterIEToolbarModule(Type t)
        {
            AddinExpress.IE.ADXIEToolbarModule.RegisterIEToolbarModuleInternal(t);
        }
 
        [ComUnregisterFunctionAttribute]
        public static void UnregisterIEToolbarModule(Type t)
        {
            AddinExpress.IE.ADXIEToolbarModule.UnregisterIEToolbarModuleInternal(t);
        }
 
        #endregion
 
        public IE.WebBrowser IEApp
        {
            get
            {
                return (this.IEObj as IE.WebBrowser);
            }
        }
 
        public mshtml.HTMLDocument HTMLDocument
        {
            get
            {
                return (this.HTMLDocumentObj as mshtml.HTMLDocument);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (IEApp == null)
                System.Windows.Forms.MessageBox.Show("IEApp == null");
            else
                System.Windows.Forms.MessageBox.Show("IEApp != null");
        }

 
    }
}


Am I doing anything wrong?


Andrei Smolin
Add-in Express Team Leader
Posted 12 Mar, 2010 05:34:36 Top
Rodrigo Oliveira




Posts: 27
Joined: 2009-06-15
In fact, it's not when the toolbar is already loaded, I need IEApp (WebBrowser) not null on constructor class.

Is it possible?

Thanks!

Rodrigo
Posted 16 Mar, 2010 08:51:41 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Rodrigo,

Sorry, I don't understand you. What do I need to do to reproduce the scenario you are talking about?


Andrei Smolin
Add-in Express Team Leader
Posted 16 Mar, 2010 08:58:57 Top
Rodrigo Oliveira




Posts: 27
Joined: 2009-06-15
Ok. I will try.

I need do html changes (e.g: add my css on the current page loaded) when the toolbar is enabled (visible).

So, on the constructor class I need to have the IEApp (WebBrowser) not null, for I do this changes.
It's not mandatory on constructor class, it also can be on another event that always is fired when toolbar is enabled.

Thanks.

Rodrigo
Posted 16 Mar, 2010 09:08:27 Top
Rodrigo Oliveira




Posts: 27
Joined: 2009-06-15
Andrei,

I got on OnConnect event. This is not a problem anymore.

Thanks for attention!

Rodrigo
Posted 16 Mar, 2010 09:38:04 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hi Rodrigo,

IEApp is initialized when the module is being created so you cannot access it in the constructor. Try using the OnConnect event to get it for the first time.

It is probable that I still don't understand you. If this is the case, please change my code as required and send it to me to the support e-mail address (see readme.txt).


Andrei Smolin
Add-in Express Team Leader
Posted 16 Mar, 2010 09:43:58 Top
Rodrigo Oliveira




Posts: 27
Joined: 2009-06-15
Andrei,

OnConnect works for me.

Thanks!

Rodrigo
Posted 16 Mar, 2010 09:53:03 Top