// Hook function
        static void WinEventProc(IntPtr hWinEventHook, uint eventType,
                                 IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            CustomSaveFileDialog csfdg = customSaveFileDialog;

            if (csfdg.hDlg == IntPtr.Zero)
            {
                csfdg.hDlg = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "#32770", "Save As");
            }

            if (hwnd == csfdg.hDlg)
            {
                IntPtr hParent = GetParent(csfdg.hCtrl);

                //this is done only once
                if (!(hParent == csfdg.hDlg))
                {
                    SetParent(csfdg.hCtrl, csfdg.hDlg);       //Bind the user control to the Common Dialog
                }
                RECT cliRect;
                GetClientRect(csfdg.hDlg, out cliRect);

                //Position the button in the file dialog
                MoveWindow(csfdg.hCtrl, cliRect.Left + 130, cliRect.Bottom - 55, 500, 60, true);
            }
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="ctrl">The User Control to be displayed in the file dialog</param>
        public CustomSaveFileDialog(UserControl ctrl)
        {
            InitializeComponent();

            customSaveFileDialog = this;
            this.ctrl            = ctrl;
            hCtrl = ctrl.Handle;

            //Setup Hook; for simplicity, hook all possible events from the current process
            hHook = SetWinEventHook(1, 0x7fffffff, IntPtr.Zero,
                                    procDelegate, (uint)Process.GetCurrentProcess().Id, 0, WINEVENT_OUTOFCONTEXT);
        }