Questions on your download example

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

Questions on your download example
How to switch between several task panes programmatically 
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Hi,

I am studying the following download example:
How to switch between several task panes programmatically.
https://www.add-in-express.com/support/vb-net-excel.php


In AddinModule.vb of this example, you have this function:

Private Function GetTaskPane(ByVal Item As AddinExpress.XL.ADXExcelTaskPanesCollectionItem, ByVal ShouldBeVisible As Boolean, ByVal ShouldBeActive As Boolean) As AddinExpress.XL.ADXExcelTaskPane
        Dim TaskPane As AddinExpress.XL.ADXExcelTaskPane = Item.TaskPaneInstance
        If TaskPane IsNot Nothing Then
            If (ShouldBeVisible AndAlso TaskPane.Visible OrElse (Not ShouldBeVisible AndAlso Not TaskPane.Visible)) AndAlso (ShouldBeActive AndAlso TaskPane.Active OrElse (Not ShouldBeActive AndAlso Not TaskPane.Active)) Then
                Return TaskPane
            End If
        End If
        Return Nothing
    End Function



I have some difficulty understanding the parameters in the code:

---------------
First parameter:
ByVal Item As AddinExpress.XL.ADXExcelTaskPanesCollectionItem

This, I can understand. "Item" represents an item in the ADX Excel Task Panes Collection, which we can see in the Designer.

--------------
Second parameter:
ByVal ShouldBeVisible As Boolean

I have no idea at all what this parameter represents, and what it is supposed to do.

Also, where (i.e. in which Properties window) do we specify that a task pane SHOULD BE visible?

Why does the name of the parameter begin with "SHOULD BE" ? I know it's just a name. But the author of the sample must have something else in mind?

What does he mean if he says: "This task pane SHOULD BE visible"?

Everything in his following IF statements show that he attaches much importance to the words "SHOULD BE".

--------------
Third parameter:
ByVal ShouldBeActive As Boolean

This parameter is as mysterious to me.

I have no idea at all what this parameter represents, and what it is supposed to do.

Also, where do we determine whether the Task Pane is active or not?



---------------

Thanks for enlightening me.
If I don't understand what these parameters do, I have little hope of understanding the codes which follow.


Thanks
Leon
Posted 23 Jan, 2019 02:57:21 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Leon,

I suppose SHOULD reflects the fact that the pane instance may not exist.

As to Visible and Active, pay attention to the last item in section An Absolute Must-Know (see the PDF file in the folder {Add-in Express}\Docs on your development PC):


Here are the three main points you should be aware of:

- There are application-specific <Manager> components such as ADXOlFormsManager or ADXEcelTaskPanesManager; every <Manager> component provides the Items collection; each <Item> from the collection binds a <Form>, which is an application-specific descendant of System.Windows.Forms.Form such as ADXOlForm or ADXExcelTaskPane, to the visualization (Excel, Word, PowerPoint and Outlook) and context (Outlook- only) settings.
- You never create an instance of a <Form> in the way you create an instance of System.Windows.Forms.Form; instead, the <Manager> creates instances of the <Form> for you; the instances are created either automatically or at your request.
- The Visible property of a <Form> instance is true, when the instance is embedded into a subpane of the host window (as specified by the visualization settings) regardless of the actual visibility of the instance; the Active property of the <Form> instance is true, when the instance is actually shown on top of all other instances in the same region.

Note. Anywhere on this page, as well as on other pages, a term in angle brackets, such as <Manager> or <Form> above, specifies a component, class, or class member, the actual name of which is application-dependent. Every such term is covered on the corresponding page of this manual.



Andrei Smolin
Add-in Express Team Leader
Posted 23 Jan, 2019 05:49:55 Top
Leon Lai Kan




Posts: 200
Joined: 2018-12-20
Hi, Andrei

Thanks for your great insight.

The Visible property of a <Form> instance is true, when the instance is embedded into a subpane of the host window (as specified by the red)


What are red? Where are they found?

Leon

red

I guess it means the properties of the Task Pane? But I don't find any "visible"property listed.
Posted 23 Jan, 2019 07:08:04 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Leon,

With Advanced Task Pane in Excel, there are no visibility-related settings.

Each <Manager> (ADXExcelTaskPanesManager in your case) has the Items collection. ADXExcelTaskPanesManager .Items contains ADXExcelTaskPanesCollectionItem objects. ADXExcelTaskPanesCollectionItem specifies 1) the pane class instances of which will be created, 2) the position in which the pane instances should be shown, 3) other properties describing the container in which a task pane instance is shown.

The visibility-related properties are part of the container description. I think such settings should be named context-sensitive properties. They make sense in Outlook add-ins: they let the developer specifying that instances of a pane class are shown for e.g. mails or tasks (not shown for other Outlook items).

Just in case you need it: to prevent a task pane from showing, you set ADXExcelTaskPane.Visible=False in the ADXExcelTaskPane.ADXBeforeTaskPaneShow event.

Note that you do not create pane instance; the manager creates them when required. Also note that you shouldn't expect that a pane instance is something permanent: the manager may close and create a new pane instance when reacting to conditions outside of your code. BTW, you may find useful the sample project discussed in https://www.add-in-express.com/forum/read.php?FID=5&TID=15279.


Andrei Smolin
Add-in Express Team Leader
Posted 23 Jan, 2019 08:46:45 Top