protected override unsafe IntPtr WndProc(int msg, IntPtr wParam, IntPtr lParam)
            {
                switch (msg)
                {
                case TaskDialogNativeMethods.WM_WINDOWPOSCHANGED:
                    IntPtr result = base.WndProc(msg, wParam, lParam);

                    ref TaskDialogNativeMethods.WINDOWPOS windowPos =
                        ref *(TaskDialogNativeMethods.WINDOWPOS *)lParam;

                    if ((windowPos.flags & TaskDialogNativeMethods.WINDOWPOS_FLAGS.SWP_SHOWWINDOW) ==
                        TaskDialogNativeMethods.WINDOWPOS_FLAGS.SWP_SHOWWINDOW &&
                        !_processedShowWindowMessage)
                    {
                        _processedShowWindowMessage = true;

                        // The task dialog window has been shown for the first time.
                        _taskDialog.OnShown(EventArgs.Empty);
                    }

                    return(result);