SOLIDWORKS-PDM-API-SDK
SOLIDWORKS-PDM-API-SDK copied to clipboard
Solution: WPF usercontrol does not accept userinput when host in a EdmTaskPAge
trafficstars
Issue:
- Create a WPF usercontrol with any input and host in an EdmTaskPage.
- Compile add-in and add to the vault.
- Create task and choose add-in from dropdown.
- See created tab to replicate issue.
Code below seems to fix the issue:
public partial class ConditionsWpf : UserControl
{
#region Public Constructors
private const UInt32 DLGC_WANTARROWS = 0x0001;
private const UInt32 DLGC_WANTTAB = 0x0002;
private const UInt32 DLGC_WANTALLKEYS = 0x0004;
private const UInt32 DLGC_HASSETSEL = 0x0008;
private const UInt32 DLGC_WANTCHARS = 0x0080;
private const UInt32 WM_GETDLGCODE = 0x0087;
public ConditionsWpf()
{
InitializeComponent();
Loaded += delegate
{
HwndSource s = HwndSource.FromVisual(this) as HwndSource;
if (s != null)
s.AddHook(new HwndSourceHook(ChildHwndSourceHook));
};
}
IntPtr ChildHwndSourceHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == WM_GETDLGCODE)
{
handled = true;
return new IntPtr(DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL);
}
return IntPtr.Zero;
}
#endregion
}