Automatic pop-up ADXExcelTaskPane issue

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

Automatic pop-up ADXExcelTaskPane issue
Once you open the taskpane, it will open automatically when you click File tab in excel. 
Joe W.D


Guest


Hi Support Team,

I recently encountered a problem. Once I open the taskpane, it will pop up automatically every time I click on "File" tab in excel.

See the dynamic image below

[img]https://imgur.com/a/YhIKGJd[/img]

Could you help to follow this issue?

Thanks
Posted 08 Mar, 2019 03:34:22 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Joe,

You need to intercept the should use the ADXExcelTaskPane.ADXCloseButtonClick event to find out that the user closes the pane using the cross. Store this flag in a Boolean; when in the ADXExcelTaskPane.ADXBeforeTaskPaneShow, set that Boolean to ADXExcelTaskPane.Visible.


Andrei Smolin
Add-in Express Team Leader
Posted 11 Mar, 2019 04:21:12 Top
Joe W.D


Guest


Hi Andrei,

Thanks for your reply. In our case, I need re-open TaskPane again(use ADXExcelTaskPanesCollectionItem.ShowTaskPane) when user click my custom ribbon button. In ADXExcelTaskPane.ADXBeforeTaskPaneShow, I can't identify who called this method. When I click the "File" Tab, This method, ADXExcelTaskPane.ADXBeforeTaskPaneShow, will also be triggered. Please let me know what should I do now?

Thanks & Regards
Posted 12 Mar, 2019 22:00:01 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Hello Joe,

If the user closes the pane using by clicking the cross, you store this in a Boolean flag; let's call it isClosedByUser. When the user clicks the Ribbon button, you can set this in the flag called isOpenedByUser.

Accordingly, in ADXBeforeTaskPaneShow, you check the following:

if (isOpenedByUser) {
    isClosedByUser = false;
    isOpenedByUser = false;
    this.Visible = true;
}
else {
    if (isClosedByUser) this.Visible = false;
}


Note that the logic above is applicable only if you have a single Excel window. Since you may have several Excel windows, you'll need yo have window-specific flags. To achieve this, create two dictionaries: the key is the window (see below), the value is the corresponding Boolean flag.

To identify the window in which the form is about to show (again, we talk about the ADXBeforeTaskPaneShow event), you retrieve ADXExcelTaskPane.HostHandle (it is an IntPtr), and use it as key in the dictionaries above.

Say, you can have:
Dictionary<System.IntPtr, bool> isClosedByUser
Dictionary<System.IntPtr, bool> isOpenedByUser

When in the ADXBeforeTaskPaneShow event handler, you get IntPtr hostHandle = this.HostHandle and use the modified version of the code above:

if (isOpenedByUser) {
    isClosedByUser[hostHandle] = false;
    isOpenedByUser[hostHandle] = false;
    this.Visible[hostHandle] = true;
}
else {
    if (isClosedByUser[hostHandle]) this.Visible = false;
}



Andrei Smolin
Add-in Express Team Leader
Posted 13 Mar, 2019 05:05:59 Top