Do a profile window in the VFP

zhaozj2021-02-08  259

Do a profile window in the VFP

(Author: Zhou Mingyang, 2000 at 11:50 on September 4)

Making a shaped window sounds like only in VB, VC programming can be done. However, in the VFP, as long as you use the API function, this is not a difficult thing. Through this paper, you must find that the stronger of the VFP program is more than just data processing, but also comparable to other programming languages ​​in terms of program interface design.

First, the implementation principle

In the design of the VB, VC program, if you want to change the shape of the window, it is usually achieved by the call to SetWindowRGN. The SetWindowRGN function can set the window to any shape. The modulation format of this function is as follows:

Int setWindowRgn (HWND HWND, HRGN HRGN, BOOL BREDRAW)

The integration of each parameter is:

HWnd: To change the handle of the window

HRGN: Window display area

BREDRAW: Indicates whether the window needs to be re-painted after the display area is changed, usually the value is true.

Through the introduction of the SETWINDOWRGN function, we can see that in the VFP want to change the shape of the window, you need to know the handle of the VFP window. It is difficult to obtain the situation of the window directly to the VFP, so the API routine library must be utilized. The VFP comes with the API routine library "foxTools.FLL" provides a related function for the window operation. The routines that can be used herein have both _Wontop () and _WHToHWnd (), where _wontop () is used to get the handle of the top window, _WhtohWnd () returns the handle of the specified window. The call format of these two API routines is simple, and it will not be detailed here.

Second, the implementation process

With the above understanding, we can try to design a profile window. The design steps are as follows:

1. Create a new form MULT_SHAPE, set the properties of the form according to Table 1.

Table 1

Attribute name setting value note

Autocenter .t. Automatic home

Backcolor 0,0,160 blue background

Borderstyle no border window boundless box

ControlBox .f. Remove the maximum, minimize, restore button

CAPTION round window

Fillcolor 128, 255, 0

ShowWindow 2-as Top-level form The form is used as the top form, otherwise the form cannot be independent of VFP.

Titlebar 0-OFF Cancel Title Bar

In Table 1, the settings made to the form interface are intended to allow the form to be more like a circular window after running, so we need to remove the contents of the regular windows such as the title bar, the window size control button.

2. Add a label control (Label1) and button control (Command1) on the form, set its title "VFP circular window example" and "exit".

3. Set the event code for the form and control, where the form of the LOAD event code is:

* Register an API function

Declare Integer SetWindowRgn in Win32API INTEGER, INTEGER, INTEGER

Declare Integer CreateroundRectrgn in Win32API INTEGER, INTEGER, INTEGER, INTEGER, INTEGER, INTEGER

* API routine library for registering VFP

Set library to "c: / program files / microsoft visual studio / vfp98 / foxtools.fll" * Set the size of the form

thisForm.top = 0

thisform.Left = 0

thisform.height = 200

thisform.width = 200

The form of Activate event code is:

Thisform.Label1.top = thisform.top thisform.height / 2-thisform.label1.height

Thisform.Label1.Label1.Label1.Label1.Label1.width-thisform.label1.width / 2

Thisform.command1.top = thisform.height-3 * thisform.command1.height

Thisform.command1.Left = thisform.Left (thisForm.width-thisform.command1.width) / 2

* The above code is mainly used to accurately locate each control in a circular window.

TopWindow = _wontop ()

* Get the top window

HWND = _WHTohWnd (TopWindow)

* Get the handle of the top window

CRN1 = CreateroundRectrgn (0,0,200,200,200,200)

* Create a round window, if you want to do other windows, just call the function of different buildings

SetwindowRGN (hwnd, crn1 ,.t.)

The CLICK event code for the Command1 control is:

thisForm.release

Also, if you want to design a window of other shapes, you only need to modify the CreateroundRectrGN (0,0,200, 200, 200, 200, 200, 200, 200) in the form1 in Form1. For example, if you want to create an apple window, change the statement to: CreateroundRectrgn (0, 0, 200, 200, 90, 1800).

Through the procedures described in this article, it has been done in the blink of an eye. Try it, you can make a more colorful shaped window!

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

New Post(0)