In winform applications, some custom non-standard windows are often used to improve the software's perception. Since the standard window title and border are no longer used, the move and resize functions of the window need to be implemented by yourself. When I write this function, I directly change the location and size in onmousemove. After using this method, the CPU usage sometimes reaches 100% during Resize and move, because the mousemove message is frequently generated, basically, the Mouse sends a mousemove message every time it moves a pixel. Because I resize the mouse in mousemove, the frequency of resize will also be very frequent, this may not be a problem in some simple windows (with few controls and simple self-painting logic), but for some complicated windows, frequent repainting and layout are costly.
Later, I tried to resize the idle event. Some experiments showed that the trigger frequency of the idle event was 40% less than that of mousemove, but the effect remained unchanged. It is better that the idle event is based on the applicationProgramWhether it is idle or not to determine the frequency of occurrence. In this way, when the system is busy, the slow response of window Resize is acceptable, in this way, more CPU resources can be used in the required computing.
This is just a note memo. If you have used the resize function of the Self-painted window, you are welcome to discuss it together. :)