How do you prevent a windows from being moved?

前端 未结 15 1978
刺人心
刺人心 2020-11-27 15:30

How would i go about stopping a form from being moved. I have the form border style set as FixedSingle and would like to keep it this way because it looks good in vista :)

15条回答
  •  攒了一身酷
    2020-11-27 16:27

    In Windows, the WS_CAPTION style is the non-client area that allows your window to be moved with a mouse. So the easiest way to do what you want is to remove this style from your window.

    However, if you need to have a caption and still achieve what you want, then the next style would be to capture the WM_NCHITTEST message and check for HTCAPTION. If the code is HTCAPTION, return NTNOWHERE instead. This will prevent the default window procedure from executing the default move window thing.

提交回复
热议问题