Excel task panes

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

Excel task panes
Enumerating and minimising 
Tom Mulholland




Posts: 15
Joined: 2012-06-26
Hi Andrei

I've finally gained some momentum with excel task panes ... but need a bit more help!

I have a task pane instance running in normal state and working OK. But I want to trap event when it is minimised by a user clicking on double-arrow button in pane header? Checking the VisibleChanged event of the excel task pane and looking at its WindowState, VS tells me "normal" no matter whether it's normal or when it has been minimised?

I'm also trying to enumerate through the various task panes in my pane manager component once the addinmodule is loaded up OK. Is there a simple way in VB to loop through the adxexceltaskpanecollectionitems object to do this?

Thank you, Tom
Posted 18 Apr, 2021 16:30:59 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Tom,

When the user gets the pane visible, the add-in gets the Activated event on the pane. When the pane becomes invisible, the Deactivate event occurs. You find whether the pane gets minimized, check the RegionState property of the task pane instance: it returns ADXRegionState.Minimized in this scenario.


private void ADXExcelTaskPane1_Activated(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("!!! ADXExcelTaskPane1_Activated " + this.RegionState.ToString());
}

private void ADXExcelTaskPane1_Deactivate(object sender, EventArgs e)
{
    System.Diagnostics.Debug.WriteLine("!!! ADXExcelTaskPane1_Deactivate " + this.RegionState.ToString());
}


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Apr, 2021 04:05:34 Top
Tom Mulholland




Posts: 15
Joined: 2012-06-26
Thanks Andrei

I used the following in my VB.net project to change the header of my pane 'p7' when it is minimised by user using double arrow:

  Private Sub p7_Deactivate(sender As Object, e As EventArgs) Handles MyBase.Deactivate
    If Me.WindowState = FormWindowState.Minimized Then Me.Text = "Pane minimised"
  End Sub


This didn't work - stepping through code reports the pane's FormWindowState is normal when it's activated and also normal when it goes through deactivate. There's no deactivated event so I can't use it here.

I've solved it by ignoring the IF and just having:

  Private Sub p7_Deactivate(sender As Object, e As EventArgs) Handles MyBase.Deactivate
    Me.Text = "Pane minimised"
  End Sub
Posted 19 Apr, 2021 14:31:31 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Tom,

You should check Me.RegionState, not Me.WindowState; these are different "minimizeds". Currently, if you have two panes in that region, your form caption is set to "Pane minimised" when another pane is shown on top of yours.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Apr, 2021 08:35:28 Top
Tom Mulholland




Posts: 15
Joined: 2012-06-26
I'm writing a bit of code to report the properties of my 10 excel task panes while Excel is running, i.e.

Pane 1 - name - windowstate - size - enabled - etc. etc.
Pane 2 - name - windowstate - size - enabled - etc. etc.
...
...
Pane 10 - name - windowstate - size - enabled - etc. etc.


I've tried using:

For Each _pane As AddinExpress.XL.ADXExcelTaskPane In AddinModule.CurrentInstance.TaskPanes
'...do stuff...
Next _pane


But VB throws exception when it hits the "for each". Can you advise the best way to loop through the panes collection?

Not sure if the taskpanes collection contains the adxexceltaskpane instances in it....?

Thanks!
Posted 11 May, 2021 15:03:06 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Tom,

Tom Mulholland writes:
Not sure if the taskpanes collection contains the adxexceltaskpane instances in it....?


The TaskPanes collection has this description:

===
Returns the ADXCustomTaskPaneCollection collection of custom task panes.
===

That is, the answer is: No, it doesn't contain ADXExcelTaskPane instances. Such instances can be found in AddinExpress.XL.ADXExcelTaskPanesCollectionItem.TaskPaneInstances.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 12 May, 2021 02:31:55 Top
Tom Mulholland




Posts: 15
Joined: 2012-06-26
Thanks Andrei, distinction now clear - one task pane collection item may have more than one task pane instance.

Regards
Posted 13 May, 2021 11:34:18 Top
Tom Mulholland




Posts: 15
Joined: 2012-06-26
Sorry still can't get it. I'm trying to follow your guidance but this won't work.

For Each panne As AddinExpress.XL.ADXExcelTaskPanesCollectionItem In AddinExpress.XL.ADXExcelTaskPanesCollectionItem.TaskPaneInstances
      MsgBox(panne.Text)
    Next panne


I think you can see what I am trying to do - would you be so kind as to post the three lines I need?

Then I can move on.

Thank you.
Posted 13 May, 2021 12:18:52 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Tom,

Try this one:

Private Sub AdxRibbonButton1_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean) Handles AdxRibbonButton1.OnClick
    For Each panne As AddinExpress.XL.ADXExcelTaskPane In Me.AdxExcelTaskPanesCollectionItem1.TaskPaneInstances
        MsgBox(panne.Text)
    Next panne
End Sub


Me.AdxExcelTaskPanesCollectionItem1 above is one of the AddinExpress.XL.ADXExcelTaskPanesCollectionItem objects declared on the add-in module.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 May, 2021 02:21:34 Top
Tom Mulholland




Posts: 15
Joined: 2012-06-26
Brilliant thank you - it didn't occur to me that this sub has to sit inside AddinModule...
I can also see a fair amount of useful stuff in the manual so coming together finally!!

Regards
Posted 14 May, 2021 15:43:58 Top