コード例 #1
0
ファイル: TaskDialog.cs プロジェクト: ROOT-LOGIN/bubble
        static int TaskDialogCallback(IntPtr hwnd, TaskDialogNotifications uNotification, IntPtr wp, IntPtr lp, IntPtr dwRefData)
        {
            switch (uNotification)
            {
            case TaskDialogNotifications.TDN_CREATED:
                SendMessage(hwnd, (int)TaskDialogMessages.TDM_SET_PROGRESS_BAR_MARQUEE, TRUE, new IntPtr(20));
                break;

            case TaskDialogNotifications.TDN_NAVIGATED:
                break;

            case TaskDialogNotifications.TDN_BUTTON_CLICKED:
                switch (wp.ToInt32())
                {
                case DialogButtonIds.IDCANCEL:
                    return(HRESULT.S_OK);

                default:
                    return(HRESULT.S_FALSE);
                }

            case TaskDialogNotifications.TDN_HYPERLINK_CLICKED:
                int a = 0;
                break;

            case TaskDialogNotifications.TDN_TIMER:
                break;

            case TaskDialogNotifications.TDN_DESTROYED:
                return(HRESULT.S_OK);

            case TaskDialogNotifications.TDN_RADIO_BUTTON_CLICKED:
                break;

            case TaskDialogNotifications.TDN_DIALOG_CONSTRUCTED:
                break;

            case TaskDialogNotifications.TDN_VERIFICATION_CLICKED:
                break;

            case TaskDialogNotifications.TDN_HELP:
                break;

            case TaskDialogNotifications.TDN_EXPANDO_BUTTON_CLICKED:
                break;

            default:
                break;
            }
            return(HRESULT.S_FALSE);
        }
コード例 #2
0
        private int TaskDialogCallbackProc(IntPtr hWnd, TaskDialogNotifications notification,
            IntPtr wparam, IntPtr lparam, IntPtr referencedata)
        {
            try
            {
                hwndDialog = hWnd;
                switch (notification)
                {
                    case TaskDialogNotifications.Created:
                        ApplyButtonInitialization();
                        OnOpened(EventArgs.Empty);
                        break;
                    case TaskDialogNotifications.Destroyed:
                        OnClosing(EventArgs.Empty);
                        // Clear the dialog handle.
                        hwndDialog = IntPtr.Zero;
                        break;
                    case TaskDialogNotifications.Navigated:
                        ApplyButtonInitialization();
                        OnNavigated(EventArgs.Empty);
                        break;
                    case TaskDialogNotifications.HyperlinkClicked:
                        string link = Marshal.PtrToStringUni(lparam);
                        OnHyperlinkClicked(new HyperlinkClickedEventArgs(link));
                        break;
                    case TaskDialogNotifications.ButtonClicked:
                        // Check if the button is part of the custom buttons.
                        int buttonID = wparam.ToInt32();
                        CustomButton bt;
                        if (currentCustomButtons != null && currentCustomButtons.TryGetValue(buttonID, out bt))
                            return bt.ButtonClicked?.Invoke(bt, EventArgs.Empty) ?? true ? HResultOk : HResultFalse;
                        else
                            return CommonButtonClicked?.Invoke(this, new CommonButtonClickedEventArgs((TaskDialogResult)buttonID)) ?? true ? HResultOk : HResultFalse;
                    case TaskDialogNotifications.RadioButtonClicked:
                        int rbuttonID = wparam.ToInt32();
                        RadioButton rbt;
                        // Note: It should not happen that we don't find the radio button id.
                        if (currentRadioButtons != null && currentRadioButtons.TryGetValue(rbuttonID, out rbt))
                            rbt.OnRadioButtonClicked(EventArgs.Empty);
                        break;
                    case TaskDialogNotifications.ExpandButtonClicked:
                        OnExpandoButtonClicked(new BooleanStatusEventArgs(wparam != IntPtr.Zero));
                        break;
                    case TaskDialogNotifications.VerificationClicked:
                        OnVerificationClicked(new BooleanStatusEventArgs(wparam != IntPtr.Zero));
                        break;
                    case TaskDialogNotifications.Help:
                        OnHelp(EventArgs.Empty);
                        break;
                    case TaskDialogNotifications.Timer:
                        OnTimerTick(EventArgs.Empty);
                        break;
                }

                return HResultOk;
            }
            catch (Exception e)
            {
                // We must catch all exceptions and translate them into a HResult, so that the TaskDialog function
                // is aware of the error and can return, where we rethrow the exception from the HResult.
                return Marshal.GetHRForException(e);
            }
        }