WPF Control Focus Issue

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

WPF Control Focus Issue
WPF Control Hosted In ElementHost ADXExcelTaskPane 
Michael Thrift




Posts: 36
Joined: 2015-06-09
Using Microsoft Office 2010, there is an issue embedding a WPF UserControl into an ElementHost. You are unable to keep a combobox or pop up window open.

A solution I found, which was provided by Add-In Express is below:

Add-in Express looked into this for me, and it turns out to have something to do with the Window style of the Task Pane that gets added to Excel. If you turn off the WS_CHILD flag in the Windows CreateParams then Combo Boxes and other popups work as expected.

They gave me this snippet of code to add to my ADXExcelTaskPane:


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

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

        return _CreateParams;
    }
}


However, there is a side effect. The EXCEL window itself loses focus when operating inside the WPF control, and therefore when you try to minimize or resize the ADXExcelTaskPane it requires that you click to regain focus before you can perform any drag, resize or minimize operation.

Any suggestion for correcting this?
Posted 23 Mar, 2016 14:47:53 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Michael,

We've found a better way to fix this. In a couple of minutes I'll send you an email with a download link for this fix. Please let me know if the fix forks for you.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Mar, 2016 04:08:42 Top
Chelsea Hughes




Posts: 3
Joined: 2016-04-13
Could you please send me this fix as well?
Posted 13 Apr, 2016 11:41:32 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Chelsea,

Sure. I've sent it; check you Inbox. Please let me if the fix works for you.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Apr, 2016 02:11:41 Top
chel




Posts: 3
Joined: 2016-04-13
Is there any way to implement this new solution without requiring an unreleased version of ADX? I presume it has something to do with sending WM_CHILDACTIVATE messages to the task pane?
Posted 15 Apr, 2016 16:41:41 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Chelsea,

Another way is to wait a little; we are going to publish a new build this week.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 Apr, 2016 05:32:31 Top