private Int32 myBrowseCallbackProc(IntPtr hwnd, UInt32 uMsg, Int32 lParam, Int32 lpData)
        {
            switch ((BrowseForFolderMessages)uMsg)
              {
            case BrowseForFolderMessages.BFFM_INITIALIZED:
              Debug.WriteLine("BFFM_INITIALIZED");

              if (OnInitialized != null)
              {
            InitializedEventArgs args = new InitializedEventArgs(hwnd);
            OnInitialized(this, args);
              }

              break;

            case BrowseForFolderMessages.BFFM_IUNKNOWN:
              Debug.WriteLine("BFFM_IUNKNOWN");

              if (OnIUnknown != null)
              {
            IUnknownEventArgs args = new IUnknownEventArgs(hwnd, (IntPtr)lParam);
            OnIUnknown(this, args);
              }

              break;

            case BrowseForFolderMessages.BFFM_SELCHANGED:
              Debug.WriteLine("BFFM_SELCHANGED");

              if (OnSelChanged != null)
              {
            SelChangedEventArgs args = new SelChangedEventArgs(hwnd, (IntPtr)lParam);
            OnSelChanged(this, args);
              }

              break;

            case BrowseForFolderMessages.BFFM_VALIDATEFAILEDA:
              Debug.WriteLine("BFFM_VALIDATEFAILEDA");

              if (OnValidateFailed != null)
              {
            string failedSel = Marshal.PtrToStringAnsi((IntPtr)lParam);
            ValidateFailedEventArgs args = new ValidateFailedEventArgs(hwnd, failedSel);
            return OnValidateFailed(this, args);
              }
              break;

            case BrowseForFolderMessages.BFFM_VALIDATEFAILEDW:
              Debug.WriteLine("BFFM_VALIDATEFAILEDW");

              if (OnValidateFailed != null)
              {
            string failedSel = Marshal.PtrToStringUni((IntPtr)lParam);
            ValidateFailedEventArgs args = new ValidateFailedEventArgs(hwnd, failedSel);
            return OnValidateFailed(this, args);
              }

              break;
              }

              return 0;
        }
コード例 #2
0
        private Int32 myBrowseCallbackProc(IntPtr hwnd, UInt32 uMsg, Int32 lParam, Int32 lpData)
        {
            switch ((BrowseForFolderMessages)uMsg)
            {
            case BrowseForFolderMessages.BFFM_INITIALIZED:
                Debug.WriteLine("BFFM_INITIALIZED");

                if (OnInitialized != null)
                {
                    InitializedEventArgs args = new InitializedEventArgs(hwnd);
                    OnInitialized(this, args);
                }

                break;

            case BrowseForFolderMessages.BFFM_IUNKNOWN:
                Debug.WriteLine("BFFM_IUNKNOWN");

                if (OnIUnknown != null)
                {
                    IUnknownEventArgs args = new IUnknownEventArgs(hwnd, (IntPtr)lParam);
                    OnIUnknown(this, args);
                }

                break;

            case BrowseForFolderMessages.BFFM_SELCHANGED:
                Debug.WriteLine("BFFM_SELCHANGED");

                if (OnSelChanged != null)
                {
                    SelChangedEventArgs args = new SelChangedEventArgs(hwnd, (IntPtr)lParam);
                    OnSelChanged(this, args);
                }

                break;

            case BrowseForFolderMessages.BFFM_VALIDATEFAILEDA:
                Debug.WriteLine("BFFM_VALIDATEFAILEDA");

                if (OnValidateFailed != null)
                {
                    string failedSel             = Marshal.PtrToStringAnsi((IntPtr)lParam);
                    ValidateFailedEventArgs args = new ValidateFailedEventArgs(hwnd, failedSel);
                    return(OnValidateFailed(this, args));
                }
                break;

            case BrowseForFolderMessages.BFFM_VALIDATEFAILEDW:
                Debug.WriteLine("BFFM_VALIDATEFAILEDW");

                if (OnValidateFailed != null)
                {
                    string failedSel             = Marshal.PtrToStringUni((IntPtr)lParam);
                    ValidateFailedEventArgs args = new ValidateFailedEventArgs(hwnd, failedSel);
                    return(OnValidateFailed(this, args));
                }

                break;
            }

            return(0);
        }