SystemEx.Windows.Forms.TaskDialog.PrivateCallback C# (CSharp) Method

PrivateCallback() private method

The callback from the native Task Dialog. This prepares the friendlier arguments and calls the simplier callback.
private PrivateCallback ( [ hwnd, [ msg, [ wparam, [ lparam, [ refData ) : int
hwnd [ The window handle of the Task Dialog that is active.
msg [ The notification. A TaskDialogNotification value.
wparam [ Specifies additional noitification information. The contents of this parameter depends on the value of the msg parameter.
lparam [ Specifies additional noitification information. The contents of this parameter depends on the value of the msg parameter.
refData [ Specifies the application-defined value given in the call to TaskDialogIndirect.
return int
        private int PrivateCallback( [In] IntPtr hwnd, [In] uint msg, [In] UIntPtr wparam, [In] IntPtr lparam, [In] IntPtr refData )
        {
            TaskDialogCallback callback = this.callback;
            if ( callback != null )
            {
                // Prepare arguments for the callback to the user we are insulating from Interop casting sillyness.

                // Future: Consider reusing a single ActiveTaskDialog object and mark it as destroyed on the destry notification.
                ActiveTaskDialog activeDialog = new ActiveTaskDialog ( hwnd );
                TaskDialogNotificationArgs args = new TaskDialogNotificationArgs ( );
                args.Notification = (TaskDialogNotification)msg;
                switch ( args.Notification )
                {
                    case TaskDialogNotification.ButtonClicked:
                    case TaskDialogNotification.RadioButtonClicked:
                        args.ButtonId = (int)wparam;
                        break;
                    case TaskDialogNotification.HyperlinkClicked:
                        args.Hyperlink = Marshal.PtrToStringUni ( lparam );
                        break;
                    case TaskDialogNotification.Timer:
                        args.TimerTickCount = (uint)wparam;
                        break;
                    case TaskDialogNotification.VerificationClicked:
                        args.VerificationFlagChecked = ( wparam != UIntPtr.Zero );
                        break;
                    case TaskDialogNotification.ExpandoButtonClicked:
                        args.Expanded = ( wparam != UIntPtr.Zero );
                        break;
                }

                return ( callback ( activeDialog, args, this.callbackData ) ? 1 : 0 );
            }

            return 0; // false;
        }