Thanks, I finnaly created an Array of my HwndSource.
HwndSource.FromHwnd() return null
Hello,
why HwndSource.FromHwnd() return null ?
...
Hwnd handle = Process.GetCurrentProcess().MainWindowHandle;
...
parameters.ParentWindow = handle;
HwndSource src = new HwndSource(parameters);
...
src.RootVisual = view;
...
HwndSource src2 = HwndSource.FromHwnd(handle); // return null
Thanks
Developer technologies | C#
2 answers
Sort by: Most helpful
-
-
Sam of Simple Samples 5,581 Reputation points2021-02-26T19:13:41.96+00:00 Okay, if the form is a xaml file then it is WPF.
What is
Hwnd?Process.GetCurrentProcess().MainWindowHandleis anIntPtrbut your code does not show the definition ofHwnd. That is probably not important to the problem but I am not sure.What is
parameters? What type is it? aHwndSourcecan be created using aSystem.Windows.Interop.HwndSourceParametersbut they do not have aParentWindowmember.What is
view? I see no declaration of it.Note that the code you show here does not use
src. So most of the code is not relevant.Do you know what the value of
handleis?Also, you do not tell us where the code is at in the application. If the code executes before the main window is created then of course there is no handle.