示例#1
0
            private bool FileDialogEnumWindowCallBack(IntPtr hwnd, int lParam)
            {
                StringBuilder className = new StringBuilder(256);
                NativeMethods.GetClassName(new HandleRef(this,hwnd), className, className.Capacity);
                int controlID = NativeMethods.GetDlgCtrlID(hwnd);
                WINDOWINFO windowInfo;
                NativeMethods.GetWindowInfo(new HandleRef(this,hwnd), out windowInfo);

                // Dialog Window
                if (className.ToString().StartsWith("#32770"))
                {
                    _BaseDialogNative = new MSFileDialogWrapper(_CustomControl);
                    _BaseDialogNative.AssignHandle(hwnd);
                    return true;
                }

                switch ((ControlsId)controlID)
                {
                    case ControlsId.DefaultView:
                        _CustomControl._hListViewPtr = hwnd;
                        NativeMethods.GetWindowInfo(new HandleRef(this,hwnd), out _ListViewInfo);
                        _CustomControl.UpdateListView();
                        break;
                    case ControlsId.ComboFolder:
                        _ComboFolders = hwnd;
                        _ComboFoldersInfo = windowInfo;
                        break;
                    case ControlsId.ComboFileType:
                        _hComboExtensions = hwnd;
                        _ComboExtensionsInfo = windowInfo;
                        break;
                    case ControlsId.ComboFileName:
                        if (className.ToString().ToLower() == "comboboxex32")
                        {
                            _hComboFileName = hwnd;
                            _ComboFileNameInfo = windowInfo;
                        }
                        break;
                    case ControlsId.GroupFolder:
                        _hGroupButtons = hwnd;
                        _GroupButtonsInfo = windowInfo;
                        break;
                    case ControlsId.LeftToolBar:
                        _hToolBarFolders = hwnd;
                        _ToolBarFoldersInfo = windowInfo;
                        break;
                    case ControlsId.ButtonOk:
                        _hOKButton = hwnd;
                        _OKButtonInfo = windowInfo;
                        _CustomControl._hOKButton = hwnd;
                        //Win32Types.NativeMethods.EnableWindow(_hOKButton, false);
                        break;
                    case ControlsId.ButtonCancel:
                        _hCancelButton = hwnd;
                        _CancelButtonInfo = windowInfo;
                        break;
                    case ControlsId.ButtonHelp:
                        _hHelpButton = hwnd;
                        _HelpButtonInfo = windowInfo;
                        break;
                    case ControlsId.CheckBoxReadOnly:
                        _hChkReadOnly = hwnd;
                        _ChkReadOnlyInfo = windowInfo;
                        break;
                    case ControlsId.LabelFileName:
                        _hLabelFileName = hwnd;
                        _LabelFileNameInfo = windowInfo;
                        break;
                    case ControlsId.LabelFileType:
                        _hLabelFileType = hwnd;
                        _LabelFileTypeInfo = windowInfo;
                        break;
                }

                return true;
            }
示例#2
0
            public void Dispose()
            {
                if (_CustomControl != null)
                {
                    if (!_CustomControl.IsDisposed)
                    {
                        if (_CustomControl.MSDialog != null)
                        {
                            _CustomControl.MSDialog.Disposed -= new EventHandler(DialogWrappper_Disposed);
                            _CustomControl.MSDialog.Dispose();

                        }
                        //might have been nulled by MSDialog.Dispose()
                        if (_CustomControl != null)
                        {
                            _CustomControl.MSDialog = null;
                            _CustomControl.Dispose();
                        }
                        _CustomControl = null;
                    }
                }
                if (_BaseDialogNative != null)
                {
                    _BaseDialogNative.Dispose();
                    _BaseDialogNative = null;
                }
                if (_hDummyWnd != IntPtr.Zero)
                {
                    NativeMethods.DestroyWindow(_hDummyWnd);
                    DestroyHandle();
                    _hDummyWnd = IntPtr.Zero;
                }
            }