Differences between click controls and click inactive forms in Windows

Source: Internet
Author: User

Recently reading windowsProgramDesign:

1. When you click the mouse over an inactive form, Windows will make the form an active form and then send the wm_lbuttondown message to it.
2. When you click a control on the form, the control receives wm_lbuttondown, but Windows does not make the control a focus control, and the program needs to call setfocus to make it focus.

One fact is that for windows, all UI elements are windows. The control is also a window, but it is a child window of the main window, and the main window can also be considered as a Child Window of windows.

So what does the difference in processing imply?

I sent this question to csdn, and it took a week to figure out why.

However, I just figured out that the difference in processing is actually a reflection of the following design ideas:

1. Switch between top-level forms is controlled by windows.

2. Focus switching between controls in the form is controlled by the application.

In Windows, the application unit is a process (or thread or form ).

An application is an external whole. Switching the focus of controls in the form can be considered as internal behavior, so windows will not interfere.

The relationship between applications (Windows) is equal and competitive (input). Therefore, the switching of activity forms cannot be controlled by the application, but should be controlled by windows.

 

According to this idea, the difference is easy to understand.

In user expectation, they want to be able to perform mouse operations on all visible forms, regardless of whether they are active. In addition, you also want to move the form to the active state by clicking the inactive form to receive keyboard input. Therefore, the Windows response is: first transfer it to the active status, and then send the mouse message to it.

For controls in the form, we may think that Windows can automatically obtain the focus after the control receives the mouse message as a default action. This seems to be in line with our general logic, but in fact, the controls are divided into two categories: "input" and "non-input". We only pay attention to the input controls, such as ComboBox and text; the non-input static controls, that is, labels, are ignored. Whether or not the control should be focused after the mouse is clicked is largely determined by the nature of the control. Therefore, this logic is best suited to the control window process.

Related Article

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.