/// <summary> /// The hook procedure for dialogs. Only called by windows. /// </summary> /// <param name="nCode">Action code</param> /// <param name="wParam">Depends on action code</param> /// <param name="lParam">Depends on action code</param> /// <returns></returns> public static int SaveAsHookProc(int nCode, IntPtr wParam, IntPtr lParam) { switch (nCode) { case 3: // HCBT_CREATEWND CBT_CREATEWND cw = (CBT_CREATEWND)Marshal.PtrToStructure(lParam, typeof(CBT_CREATEWND)); CREATESTRUCT cs = (CREATESTRUCT)Marshal.PtrToStructure(cw.lpcs, typeof(CREATESTRUCT)); if (cs.lpszClass == 0x00008002 && (IntPtr)0 == hwndDlg) { hwndDlg = (IntPtr)wParam; // Get hwnd of SaveAs dialog cs.x = -2 * cs.cx; // Move dialog off screen } break; case 5: // HCBT_ACTIVATE ThreadPressOk tpok = new ThreadPressOk(hwndDlg, saveaswebbrowser.PathFile, saveaswebbrowser.SaveType); hwndDlg = (IntPtr)0; // Create a thread to execute the task, and then // start the thread. new Thread((new ThreadStart(tpok.ThreadProc))).Start(); break; } return(Win32.USER32.CallNextHookEx(hook, nCode, wParam, lParam)); }
public bool onWindowCreation(object sender, CREATESTRUCT data) { return(true); }