本文整理汇总了C#中System.Windows.Forms.NativeWindow.WndProc方法的典型用法代码示例。如果您正苦于以下问题:C# NativeWindow.WndProc方法的具体用法?C# NativeWindow.WndProc怎么用?C# NativeWindow.WndProc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.NativeWindow
的用法示例。
在下文中一共展示了NativeWindow.WndProc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MyNativeWindowListener
// NativeWindow class to listen to operating system messages.
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
internal class MyNativeWindowListener : NativeWindow
{
// Constant value was found in the "windows.h" header file.
private const int WM_ACTIVATEAPP = 0x001C;
private Form1 parent;
public MyNativeWindowListener(Form1 parent)
{
parent.HandleCreated += new EventHandler(this.OnHandleCreated);
parent.HandleDestroyed += new EventHandler(this.OnHandleDestroyed);
this.parent = parent;
}
// Listen for the control's window creation and then hook into it.
internal void OnHandleCreated(object sender, EventArgs e)
{
// Window is now created, assign handle to NativeWindow.
AssignHandle(((Form1)sender).Handle);
}
internal void OnHandleDestroyed(object sender, EventArgs e)
{
// Window was destroyed, release hook.
ReleaseHandle();
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
// Listen for operating system messages
switch (m.Msg)
{
case WM_ACTIVATEAPP:
// Notify the form that this message was received.
// Application is activated or deactivated,
// based upon the WParam parameter.
parent.ApplicationActivated(((int)m.WParam != 0));
break;
}
base.WndProc(ref m);
}
}