
const int WM_ACTIVATE = 0x0006;const int WA_INACTIVE = 0;const int WA_ACTIVE = 1; const int WA_CliCKACTIVE = 2; protected overrIDe voID WndProc(ref Message m) { if (m.Msg == WM_ACTIVATE) { // When m.WParam is WA_INACTIVE,the window is being deactivated and // m.LParam is the handle of the window that will be activated. // When m.WParam is WA_ACTIVE or WA_CliCKACTIVE,the window is being // activated and m.LParam is the handle of the window that has been // deactivated. } base.WndProc(ref m); } 编辑:此方法可以在其应用的窗口之外使用(例如,在d出窗口外部).
您可以使用NativeWindow根据其句柄附加到任何窗口并查看其消息循环.请参阅以下代码示例:
public class Popup : Form{ const int WM_ACTIVATE = 0x0006; const int WA_INACTIVE = 0; private ParentwindowIntercept parentwindowIntercept; public Popup(IntPtr hWndParent) { this.parentwindowIntercept = new ParentwindowIntercept(hWndParent); } private class ParentwindowIntercept : NativeWindow { public ParentwindowIntercept(IntPtr hWnd) { this.AssignHandle(hWnd); } protected overrIDe voID WndProc(ref Message m) { if (m.Msg == WM_ACTIVATE) { if ((int)m.WParam == WA_INACTIVE) { IntPtr windowFocusGoingTo = m.LParam; // Compare handles here } } base.WndProc(ref m); } }} 总结 以上是内存溢出为你收集整理的.net – 确定表单被停用时激活的位置全部内容,希望文章能够帮你解决.net – 确定表单被停用时激活的位置所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)