Beispiel #1
0
            protected override void WndProc(ref Message m)
            {
                switch ((Msg)m.Msg)
                {
                case Msg.WM_NOTIFY:
                    OFNOTIFY ofNotify = (OFNOTIFY)Marshal.PtrToStructure(m.LParam, typeof(OFNOTIFY));
                    switch (ofNotify.hdr.code)
                    {
                    case (uint)DialogChangeStatus.CDN_SELCHANGE:
                    {
                        StringBuilder filePath = new StringBuilder(256);
                        NativeMethods.SendMessage(new HandleRef(this, NativeMethods.GetParent(Handle)), (uint)DialogChangeProperties.CDM_GETFILEPATH, (IntPtr)256, filePath);
                        if (_CustomCtrl != null)
                        {
                            _CustomCtrl.OnFileNameChanged(this, filePath.ToString());
                        }
                    }
                    break;

                    case (uint)DialogChangeStatus.CDN_FOLDERCHANGE:
                    {
                        StringBuilder folderPath = new StringBuilder(256);
                        NativeMethods.SendMessage(new HandleRef(this, NativeMethods.GetParent(Handle)), (int)DialogChangeProperties.CDM_GETFOLDERPATH, (IntPtr)256, folderPath);
                        if (_CustomCtrl != null)
                        {
                            _CustomCtrl.OnFolderNameChanged(this, folderPath.ToString());
                        }
                    }
                    break;

                    case (uint)DialogChangeStatus.CDN_TYPECHANGE:
                    {
                        OPENFILENAME ofn = (OPENFILENAME)Marshal.PtrToStructure(ofNotify.OpenFileName, typeof(OPENFILENAME));
                        int          i   = ofn.nFilterIndex;
                        if (_CustomCtrl != null && _filterIndex != i)
                        {
                            _filterIndex = i;
                            _CustomCtrl.OnFilterChanged(this as IWin32Window, i);
                        }
                    }
                    break;

                    case (uint)DialogChangeStatus.CDN_INITDONE:
                        break;

                    case (uint)DialogChangeStatus.CDN_SHAREVIOLATION:
                        break;

                    case (uint)DialogChangeStatus.CDN_HELP:
                        break;

                    case (uint)DialogChangeStatus.CDN_INCLUDEITEM:
                        break;

                    case (uint)DialogChangeStatus.CDN_FILEOK://0xfffffda2:
#pragma warning disable 1690, 0414
                        //NativeMethods.SetWindowPos(_CustomCtrl._hFileDialogHandle, IntPtr.Zero,
                        //(int)_CustomCtrl._OpenDialogWindowRect.left,
                        //(int)_CustomCtrl._OpenDialogWindowRect.top,
                        //(int)_CustomCtrl._OpenDialogWindowRect.Width,
                        //(int)_CustomCtrl._OpenDialogWindowRect.Height,
                        //FileDialogControlBase.MSFileDialogWrapper.UFLAGSSIZE);
                        break;

#pragma warning restore 1690, 0414
                    default:

                        break;
                    }
                    break;

                case Msg.WM_COMMAND:
                    switch (NativeMethods.GetDlgCtrlID(m.LParam)) //switch (m.WParam & 0x0000ffff)
                    {
                    case (int)ControlsId.ButtonOk:                //OK
                        break;

                    case (int)ControlsId.ButtonCancel://Cancel
                        break;

                    case (int)ControlsId.ButtonHelp: //0x0000040e://help
                        break;
                    }
                    break;

                default:
                    break;
                }
                base.WndProc(ref m);
            }