我正在使用.Net 6和PInvoke nuget包来访问Win32 API,我将按以下方式创建Win32窗口:
IntPtr windowHandle = User32.CreateWindowEx(User32.WindowStylesEx.WS_EX_TOOLWINDOW,
"static",
"Window Title",
User32.WindowStyles.WS_OVERLAPPEDWINDOW |
User32.WindowStyles.WS_VISIBLE,
0,
0,
800,
800,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero,
IntPtr.Zero);
当窗口在屏幕上显示时,我有the same situation as this guy个窗口渲染良好,但对用户没有响应.当我将鼠标移到窗口上时,鼠标指针变为加载圆.
我认为没有响应是由于没有处理窗口事件和消息.我想以某种方式重写或钩住Win32窗口的WndProc方法来处理消息,显然是the User32.GetMessage() does not return all messages.
在WPF中,您可以add a hook to the HwndHost来处理WndProc消息.如何获取WndProc消息.Net 6而不使用WPF?