Change cursor in window caption

时间秒杀一切 提交于 2019-12-07 00:31:34

It flickers because you use the wrong message. Any mouse move is followed by WM_SETCURSOR to allow the app to change the cursor. So the cursor changes back to the default. Intercept WM_SETCURSOR instead. The low word of LParam contains the hit test code.

    protected override void WndProc(ref Message m) {
        if (m.Msg == 0x20) {  // Trap WM_SETCUROR
            if ((m.LParam.ToInt32() & 0xffff) == 2) { // Trap HTCAPTION
                Cursor.Current = Cursors.Hand;
                m.Result = (IntPtr)1;  // Processed
                return;
            }
        }
        base.WndProc(ref m);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!