How to add buttons on the title bar

zhaozj2021-02-11  159

How to add buttons on the title bar

Author: Granville Zhejiang University of Posts and Telecommunications Development Department Yong

Everyone has some software to have some interesting things in the process of using certain software. For example, there is a button on the title bar of the main window. Such small controls are visible everywhere in the Internet. How can the button to join the non-client area? Here, the most critical point is that everyone is not misled by traditional knowledge: I really think it is a button. The Handle's control must not be placed on the title bar. Experienced programmers use Spy to track, immediately discover the secrets. It is not a button, but it is only a way to deal with a button. Since we know, then why can't we do it yourself? Of course, there is no problem, let's use delphi to implement it, and pay attention to my annotation. Before specific examples, we should know the important messages about the title bar: WM_NCPAINT: Heavy painting title bar message. We must cut it here, you can redraw buttons here; WM_NCLBUTTONDOWN: Press the left mouse button on the title bar. We can intercept it, draw a look at the button on the title bar, and can perform the process of self-click event, so that it is like a button; WM_NCLBUTTONUP: Release the left mouse button on the title bar. We can intercept it, draw a picture on the title bar; WM_NCLBUTTONDBLCLK: Double-click the left mouse button on the title bar. We can intercept it, when we do it in the button area, we should make it invalid, so that the form performs maximum and restore operations. WM_ncrbuttondown: Press right-click message on the title bar. We can intercept it, when we do it in the button area, we should make it invalid, thereby avoiding pop-up formula menu. WM_NCMOUSEMOVE: Move mouse messages on the title bar. We can intercept it, when the mouse is removed from the button area, we must draw a button until it is pressed, that is, when the projection is raised. WM_NCActivate: Receives the message when the title bar is switched between activation and non-activation. We can intercept it, when the window is processed, we can do something, such as turning the font on our title bar button or changing the current state of the window. Below I didn't join this feature. If you are interested, you can do it yourself. (Everyone can find that the title bar is the beginning of WM_NC) After knowing the principle, I believe that everyone will make a more beautiful buttons.

转载请注明原文地址:https://www.9cbs.com/read-5709.html

New Post(0)