窗体:
IntPtr hwnd = new WindowInteropHelper(this).Handle;
控件:
IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(uielement)).Handle;
句柄的取得不要在构造 函数中取得,此时的vitual还没有产生,在Loaded中 就可以了。
窗体:
IntPtr hwnd = new WindowInteropHelper(this).Handle;
控件:
IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(uielement)).Handle;
句柄的取得不要在构造 函数中取得,此时的vitual还没有产生,在Loaded中 就可以了。