Arcgis pro sdk Windows Form handler problem

1151
2
10-01-2018 05:33 AM
tanerkoka
Occasional Contributor II

Hi ,

We using  Arcgis Pro SDK for .Net version 2.2.0 We are developing tools for Arcgis Pro. We are using windows forms in it but we can not find parent handler in Arcgis Pro SDK but in ArcObject I can like ((IntPtr)ArcMap.Application.hWnd) . Application therefor forms are sliding down. How can I solve this problem ? 

Here is below when we use properly windows forms  when we develope tools for ArcMap.

public class Library
{
private const int GWL_HWNDPARENT = -8;
[DllImport("User32", CharSet = CharSet.Auto)]
private static extern int SetWindowLong(IntPtr hWnd, int Index, int Value);


public static void SetParentForm(IntPtr parentHandle, IntPtr childHandle)
{
SetWindowLong(childHandle, GWL_HWNDPARENT, parentHandle.ToInt32());
}

}

Library.SetParentForm((IntPtr)ArcMap.Application.hWnd, this.anaYolForm.Handle);

Thanks For Helping.

Tags (2)
0 Kudos
2 Replies
CharlesMacleod
Esri Regular Contributor

Look at the System.Windows.Interop.WindowInteropHelper class: https://docs.microsoft.com/en-us/dotnet/api/system.windows.interop.windowinterophelper?view=netframe...

Pass in the WPF Window whose handle you want. Probably FrameworkApplication.Current.MainWIndow in your case.

joonpark
New Contributor III

Another way is to use win32 FindWindow (windows - FindWindow() not working - Stack Overflow )

Dim ret As Long
ret = FindWindow(Nothing, "ArcGIS PRO Project Name")