【问题标题】:How to use WM_NCHITTEST and WS_EX_LAYOUTRTL together?如何同时使用 WM_NCHITTEST 和 WS_EX_LAYOUTRTL?
【发布时间】:2016-11-16 17:31:52
【问题描述】:

我有使用 WM_NCHITTEST 消息的 SizableUserControl 类和使用 WS_EX_LAYOUTRTL 和 WS_EX_NOINHERITLAYOUT 作为 RightToLeft 镜像的 CustomUserControl 类。 当我同时使用两者时,运行时调整大小是相反的。 我该如何解决?

感谢您的帮助。

【问题讨论】:

    标签: c# right-to-left resizable wndproc createparams


    【解决方案1】:

    我通过将此代码添加到 CustomUserControl 类来修复它。

    protected override void WndProc(ref Message m)
    {
        base.WndProc(ref m);
        if (m.Msg == 0x84) // WM_NCHITTEST
            if (this.RightToLeft == RightToLeft.Yes && this.RightToLeftLayout)
                switch ((int)m.Result)
                {
                    case 10: // HTLEFT
                        m.Result = (IntPtr)11; // HTRIGHT
                        break;
                    case 11: // HTRIGHT
                        m.Result = (IntPtr)10; // HTLEFT
                        break;
                    case 13: // HTTOPLEFT
                        m.Result = (IntPtr)14; // HTTOPRIGHT
                        break;
                    case 14: // HTTOPRIGHT
                        m.Result = (IntPtr)13; // HTTOPLEFT
                        break;
                    case 16: // HTBOTTOMLEFT
                        m.Result = (IntPtr)17; // HTBOTTOMRIGHT
                        break;
                    case 17: // HTBOTTOMRIGHT
                        m.Result = (IntPtr)16; // HTBOTTOMLEFT
                        break;
                    default:
                        break;
                }
    }
    

    【讨论】:

      猜你喜欢
      • 2020-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-26
      • 1970-01-01
      • 2020-04-13
      相关资源
      最近更新 更多