winforms 如何实现 缩放表单鼠标放开时触发事件??

winforms 如何实现 缩放表单鼠标放开时触发事件??

目前是使用 Form_Resize() 侦测到表单变化时会触发,但是会一直触发,想做出缩放表单鼠标放开时再做触发

大体上有两个思路
1.不使用Form_Resize事件,而自己用mouse_down和mouse_up实现表单改变大小,那么什么时候执行函数肯定也是你自己说了算
2.使用Form_Resize,配合全局鼠标钩子,检测到Form_Resize触发后,鼠标抬起,再去执行你的函数

你可以参考SO上的类似问题并且答案提供了示例:https://stackoverflow.com/questions/19206376/override-resize-behavior-of-winform-window

WM_RESIZING : is sent to the window when user starts and keeps resizing. The LParam holds the RECT structure of the current window when resizing. We read this info to render the indicative border correctly. Then we need to modify this RECT to the current Bounds of the window to discard the default resizing effect (the size and location are changed immediately).
WM_EXITSIZEMOVE : is sent to the window when the resizing or moving ends. We need to catch this message to assign the Size and Location of the window based on the Size and Location of the transparent layer and of course hide the layer then.

自己重写 wndproc,处理WM_EXITSIZEMOVE消息
https://blog.csdn.net/mydriverc/article/details/1708478