WPF context menu in Excel task pane

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

WPF context menu in Excel task pane
Problem using context menu in Excel task pane 
Florent Dugué




Posts: 49
Joined: 2009-09-09
Hi

I'm using Add-in Express 5.1.2022 in Excel 2003.
I have a ADXExcelTaskPane with one control (System.Windows.Forms.Integration.ElementHost), in which one I work using WPF.
The problem is that all WPF context menus are automatically closed as soon as they are opened when used in the task pane.

Simple reproduction : Put a WPF textbox in a custom WPF usercontrol. Link it to the elementHost, this one beeing in a ADXExcelTaskPane. When right click in the textbox, the context menu with cut/copy/paste appear and disappear right after.

Any advice ?

Thanks.
Posted 09 Sep, 2009 11:58:13 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Florent,

Could you send a sample add-in project which can reproduce the issue to the support e-mail address (see readme.txt)?

BTW What OS do you use?
.NET, Extended MAPI, Windows Phone & RT
Posted 10 Sep, 2009 04:47:41 Top
Florent Dugué




Posts: 49
Joined: 2009-09-09
Hi.

I send you a sample project.
I'm on XP SP3, and I also try on Vista SP1 using a VMWare.

Thanks.
Posted 10 Sep, 2009 05:05:37 Top
Andrei Smolin


Add-in Express team


Posts: 14127
Joined: 2006-05-11
Hi Florent,

This issue is caused by the WS_CHILD style used for the pane. Unfortunately, we haven’t found a solution for this issue. There is a workaround, though. You can try to add the following code to your ADXExcelTaskPane.

        private const uint WS_CHILD = 0x40000000;
        private const uint WS_CLIPCHILDREN = 0x02000000;
        private const uint WS_CLIPSIBLINGS = 0x04000000;

        private CreateParams fCreateParams = new CreateParams();
        protected override CreateParams CreateParams
        {
            get
            {
                fCreateParams = base.CreateParams;
                if (!DesignMode)
                {
                    fCreateParams.Style = (int)(WS_CLIPCHILDREN | WS_CLIPSIBLINGS); //| WS_CHILD
                }
                return fCreateParams;
            }
        }


But note that this settings make the Excel main window to lose activity when your ADXExcelTaskPane is activated.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Sep, 2009 07:43:36 Top
Florent Dugué




Posts: 49
Joined: 2009-09-09
Hi

Thanks for checking the problem, also the workaround is a bit weird...
Do you plan on trying to fix this problem in a future release ?
Posted 11 Sep, 2009 03:43:20 Top
Andrei Smolin


Add-in Express team


Posts: 14127
Joined: 2006-05-11
Hi Florent,

As soon as we find a solution, we add it to Add-in Express code. Although currently it looks like there's no solution at all, we will continue to work on this for sure.

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Sep, 2009 04:01:28 Top