Thoughts on How to drag and resize controls

Source: Internet
Author: User

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. :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.