The movement of untitled form and its simple beautification

Source: Internet
Author: User


Let's see it first.

Recently done the web, found that the three Musketeers will always leave some "recent open project" Such traces in the software interface, the heart always feel very uncomfortable, so germination of the idea of writing a scavenger. Tell me what you do.

DW, FW, Fl These traces are in the registry, the simple principle is to delete the value of the registry table OK, these should have nothing to say, so I will not speak. Today we mainly discuss the problem of the form dragging without the title bar and the use of the picture to simply beautify the interface.

There may be a lot of people think that the movement of the untitled bar form is very simple, many friends on the net give some methods, most people say that the method is to create a private process in the privite part of the form procedure Wmnchittest (Var Msg: Twmnchittest); Message wm_nchittest; Like this, the principle is to send a message to the system, the place where the mouse clicks are spoofed (that is, the client area of the form) is the title bar of the form, but after my test if there are other controls on the form, such as a TButton, Then the TButton event will not be triggered, regardless of which method is difficult to trigger, at least my test so. So this idea is not possible. Others have given the use of a series of events such as MouseMove to perform the operation of the top and left of the form.

The first of the above method is not suitable, people are lazy do not want to play too much code, so the second method is not suitable.

Well, don't talk nonsense, let's take one step at a step:

1. First build a form, set the BorderStyle property to Bssingle

2. Put a timage, load a picture, such as

3. Use PS to open images loaded in timage to get the color

4. Then double-click the Color property value under Form1, click "Define Custom Color" in the pop-up Colors dialog box, then fill in the box in the red, green and blue boxes with the corresponding values of R, G, b in the color picker of PS, such as:

5. Click "Add to Custom Color", and then click on the "Custom Color" box on your own defined color, then the custom color will appear a black border, and then determine. This way, the simple beautification of the form is complete.

6. Select the Timage component, select the Events tab, select the OnMouseDown event, and add the following code for it:

Procedure Tform1.image1mousedown (Sender:tobject; Button:tmousebutton; Shift:tshiftstate; X, Y:integer);
Begin
ReleaseCapture;
Perform (Wm_nclbuttondown, htcaption, 0);
End

Here I explain:

ReleaseCapture releasing the mouse capture state

Perform (Wm_nclbuttondown, htcaption, 0); The left mouse button gets the system message to the status of the form's title bar, which reaches the point where the spoofing operating system is clicked is the form's title bar.

A untitled bar form that can be dragged and responds to other components is completed.

If you have the patience, you can also continue to add some special effects for the form, such as the round corner of the form, like MSN slowly scrolling up the message box to let your form scroll up, here I can't, directly to the code:

Procedure Tform1.formcreate (Sender:tobject);
Var
Hnd:thandle;
Begin
Hnd: = createroundrectrgn (0, 0, Width, Height, 15, 15);
SetWindowRgn (Handle, Hnd, True);
AnimateWindow (Handle, +, Aw_slide + aw_ver_negative);
End

"description" 1. Define a handle variable hnd;2 first. Use the Win API function CreateRoundRectRgn to create rounded rectangular regions; 3. Use the API function SetWindowRgn to set the form to rounded corners; 4. AnimateWindow This function is used to set the appearance of the form (the expression may be less accurate here, please forgive me) This function has a lot of parameters, specific self-check it.

Finally, we will write the program's closing fade effect, or use the AnimateWindow function to implement, but this function just let the form hidden, and does not really close, so you have to use a closed code to close the form, OK crap, directly to the code:

AnimateWindow (Handle, N, aw_slide + aw_blend + aw_hide);
Application.terminate;

To this end of this article, for the understanding of the win API function of the master is very simple, please do not laughed at, thank you!

Http://www.lsworks.net/article/53.html

The movement of untitled form and its simple beautification

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.