-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subclass WinUI Window to hook native win32 events #1687
Conversation
public static class WindowsNativeMessageIds | ||
{ | ||
public const int WM_DPICHANGED = 0x02E0; | ||
public const int WM_DISPLAYCHANGE = 0x007E; | ||
public const int WM_SETTINGCHANGE = 0x001A; | ||
public const int WM_THEMECHANGE = 0x031A; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we want to do this? Just these? All? This casing? Pascal case?
Maybe for now we can keep this internal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we could just keep it internal for our own uses and maybe doc a url to a good way to find the id's.
I was torn between trying to provide some consts here for common events users may want, and exposing more individual events that propagate from these and get exposed in a more strongly named/typed way (like adding an OnThemeChanged
to the lifecycle)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var args = new WindowsNativeMessageEventArgs(hWnd, msg, wParam, lParam); | ||
|
||
NativeMessage?.Invoke(this, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth rewriting these lines to :
_NativeMessage?.Invoke(this, new WindowsNativeMessageEventArgs(hWnd, msg, wParam, lParam));
That way you don't allocate the event arguments unless there's a listener.
To do some things in WinUI we need to use win32 API's still.
This adds support to subclass the Window and start listening for windows native messages, and exposes them as a lifecycle event for other things to use.
For instance you could now use this: