public void WndProcRet(object sender, WndProcRetEventArgs e) { if (e.cw.message == WndMessage.WM_INITDIALOG || e.cw.message == WndMessage.WM_UNKNOWINIT) { USER32.MoveWindow(e.cw.hwnd, rect.Left, rect.Top, rect.Width, rect.Height, 1); // uninstall this hook WindowsHook wndHook = (WindowsHook)sender; Debug.Assert(wndProcRetHook == wndHook); wndProcRetHook.Uninstall(); wndProcRetHook = null; } }
public void WndProcRet(object sender, WndProcRetEventArgs e) { switch (e.cw.message) { case WndMessage.WM_INITDIALOG: case WndMessage.WM_UNKNOWINIT: case WndMessage.WM_ACTIVATE: //tony 2011.3.12 update 这是能否显示在当前父窗体中央的关键! USER32.MoveWindow(e.cw.hwnd, rect.Left, rect.Top, rect.Width, rect.Height, 1); // uninstall this hook WindowsHook wndHook = (WindowsHook)sender; Debug.Assert(wndProcRetHook == wndHook); wndProcRetHook.Uninstall(); wndProcRetHook = null; break; default: break; } }