12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace US.Browser.IE
- {
- /// <summary>
- /// webbrower 封装
- /// </summary>
- public class BrowerWeb : WebIfaces
- {
- public BrowerWeb()
- : base()
- {
- }
- //WindowClosing 活动扩展
- public enum GETWINDOWCMD
- {
- GW_HWNDFIRST = 0,
- GW_HWNDLAST = 1,
- GW_HWNDNEXT = 2,
- GW_HWNDPREV = 3,
- GW_OWNER = 4,
- GW_CHILD = 5,
- GW_ENABLEDPOPUP = 6
- }
- [DllImport("user32.dll")]
- private static extern IntPtr GetWindow(IntPtr hWnd, GETWINDOWCMD uCmd);
- public event EventHandler WindowClosing;
- protected virtual void OnWindowClosing(EventArgs e)
- {
- if (WindowClosing != null)
- {
- WindowClosing(this, e);
- }
- }
- protected override void WndProc(ref System.Windows.Forms.Message m)
- {
- const Int32 WM_PARENTNOTIFY = 0x210;
- const Int32 WM_DESTROY = 0x2;
- if (m.Msg == WM_PARENTNOTIFY)
- {
- if (m.WParam.ToInt32() == WM_DESTROY)
- {
- if (m.LParam == GetWindow(this.Handle, GETWINDOWCMD.GW_CHILD))
- {
- EventArgs e = new EventArgs();
- OnWindowClosing(e);
- return;
- }
- }
- }
- base.WndProc(ref m);
- }
- }
- }
|