Ten practical skills of VFP 6.0

zhaozj2021-02-08  207

Zhu Yingxi (Hebei Province. Renqiu City)

---- One. Select the network printer

---- The local area online in the author is installed with multiple network printers. When printing operations prepared using VFP 6.0, if you can select some of the free network printers to print, not necessarily Default printer output, increasing work efficiency? After executing the command: Report from ... to print, execute the following program code: set printer to name getprinter (), you can call the "Print Settings" dialog box of the operating system, users can reach the window Flexible selection of idle printers for print output features. (Note: The optional printer name is the named printer name on the user's computer.)

---- II. Restore lost FPT files

---- Due to false operation, remove the free table's note file, resulting in the free table. In this case, we can use the following method:

---- 1. Create a new free table, and the free table contains only one field, which is a note type. Close the free table, expand it to the memo file named FPT to the mistake of the memorized free table, or rename the memo file to the mistake of the misused free table. Run the following program can also resume lost FPT files:

Accept 'Please enter the lost. FPT

Free table name (without extension): 'to namef

Namef = trim (namef) '. bbb'

CREA DBF & NAMEF (AA ​​M)

USE

Dele File & Namef

---- 2. Create an empty FPT file with the VFP low file function, and the original free table can be opened. The list of procedures is as follows:

Accept 'Please enter the lost. FPT

Free table name (without extension): 'to namef

Namef = trim (namef) '. fpt'

HAND = fcreate (namef)

ABC = REPL (CHR (0), 3) CHR (8)

REPL (CHR (0), 3) '@' repl (chr (0), 504)

= fwrite (Hand, ABC)

= fclose (HAND)

Return

---- The above method only establishes a new FPT file for the free table of the FPT file, and the content in the original FPT file has been lost and cannot be recovered. If this is encountered in the actual operation, it is best to restore the original FPT file. If the original FPT file cannot recover, the above method is used.

---- Third. Detach from the VFP Operation Procedure

---- Using the application created by VFP 6.0, after compiling into an executable program, if it is independently running from the VFP environment, except that we know is "config.fpw" in the application directory. Outside the configuration file, the scriptures must also contain three dynamic link library files that "vfp6r.dll", "vfp6rchs.dll", "vfp6Rchs.dll". These three files in the "Windows / System" directory, users can copy them into their application directory. Finally, after compiling and forming an executable, run the installation wizard to create a release disk, and our developed appliances can be installed under Win 98 in Win 98.

---- Four. Low-level file function encrypted database

---- VFP has a very weak link to the confidentiality of the database. Since the .dbf file is open, even in DOS is used in DOS, it can be browsed, so the author encrypts the data from the following two: ---- 1. When adding data to the free table, When encrypted, the data is encrypted when the free table is updated, and the data is decrypted when reading data.

---- 2. Encryption with the low-level file function provided by VFP, encrypted files unable to open, browse, and use it, then execute the encrypted free table to restore.

** Encrypted Database (also Decrypting Procedure) **

SET TALK OFF

Close All

CLEA

@ 10, 10 SAY "Please enter to encrypt

Free gauge (including extension): "get file1 defa ''

reta

Handle = FOPEN ("& File1", 2)

IF Handle <0

@ 14, 10 SAY "Cannot open the file!"

= inkey (0)

Retu

ENDIF

J = 0

Do while.Not.feof (Handle)

BB = FREAD (Handle, 1)

CC = CHR (MOD (ASC (BB) 128, 256))

= fseek (Handle, J)

= FWRITE (Handle, CC)

ASC (BB), ASC (CC)

J = J 1

Enddo

= fclose (Handle)

Close All

Retu

---- Five. Simple setting of the TEXTBOX object input length

---- In the previous XBase syntax, we can define a variable or text bar in the input length format through the Picture parameter, and the Format and InputMask properties are supported in the TEXTBOX object in the VFP to define the format of the input. We can use the comparative original method to set, such as when the text box object with 20 fields is required, we can define it in the inputmask property of this object as INPUTMASK = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".

---- But this setting method is very troublesome, especially when faceting longer string inputs. In fact, we can use another way to make such a demand design process very simple, and the following is specifically described with this simple fast setting input field.

---- Use the replicate () function to set the input length Here we use the object's INPUTMASK attribute to define the input format and the input length, but when the object's input is longer, it can be used by the arithmetic expression. Set. Establish an Expression dialog box through the InputMask attribute in the Properties window, we can use the replicate () function to set the number of "X" (this example is 20). After completing, return to the property setting window, we can see the expression in the "= Replicate (20) bit value in the InputMask property bar, so we can easily complete the length control of the long character input. From this, we can also experience the convenience of being good at using expressions.

---- 6. Design method of Chinese text box

---- In the process of program development, we often need some text boxes, and these text boxes can only enter Chinese. In this case, a Chinese input method is typically started manually. If the software can automatically launch the default Chinese input method, it will bring great convenience to the programmer. The following classes can achieve this feature, the specific design steps are as follows:

---- 1. Create a new class, the base class is "TextBox", class name "Chinese TextBox", stored in the "Myclass" class library.

---- 2. After entering the class designer, set the properties of "Chinese TextBox" such as font, color, etc.

---- 3. Design GotFocus event, code is: = iMestatus (1) Represents the Chinese input method automatically when the cursor moves to this box. ---- 4. Design the LostFocus event, the code is: = iMestatus (0) indicates that the Chinese input method is automatically turned off when the cursor moves this box. After design, save it to the file.

---- 7. Design method of stereo frame class

---- In the standard class of VFP, a shape control class is provided, which can simply set the Speciaalef Fect property to "0-3D" attribute, and set "backstyle" attribute to "0- Transparent "to design a three-dimensional stereo frame.

---- However, such a three-dimensional stereo frame is too monotonous, lack of changes. With the following design methods, we can make the effect similar to the Three_D Panel in VB. The specific design steps are as follows:

---- 1. Create a new class, the base class is "Container", class named "Three_Panel", stored in the "Myclass" class library.

---- 2. After entering the class designer, set the properties of "Three_ Panel" as shown in Table 1. After the property is designed, the file can be stored, and the bobbin class of the raised effect can be obtained.

---- 3. By adjusting the value of "Specialeffect" is "1-concave", the edge frame class (Three_P Anel_ao) can be designed. Adjust the remaining parameters to get different effects borders.

---- 8. Play animation in the program

---- We know that VFP only supports still pictures and cannot play GIF animations directly. But there are many interesting and gorgeous GIF animations in the Internet, how to insert these animations into your VFP program, let your program more attractive?

---- It is actually very simple, decomposing GIF animations into individual still GIF or BMP images, then use timers to make these still pictures in VFP, generate animation effects.

---- There are a lot of software that decomposes GIF animation into a still picture, it is easy to find online, such as Animagic GIF. Decomposed pictures We are saved in this form of A0.BMP, A1.BMP .... Add timer Timer1, Timer1's INTERVAL1, set to 100, and then add image1 control, and its backstyle is set to 0 (transparent), and Stretch is also set to 0 (crop).

---- Write code in the Form's LOAD process:

Public i, n

I = 0

N = 5 (total number of still pictures)

Write code in Timer1 Timer:

Local J

i = mod (i 1, n)

J = Alltrim (STR (i))

thisform.Image1.picture = "a" -j - ". BMP"

Run the form, we can see the familiar GIF animation.

---- Nine. Paste the VFP top layer form

---- When you set the form to the top form and run in Windows independently, you will find that the copy paste function in the form is invalid, which causes great inconvenience to the actual work, so that the prepared software does not meet the professional level. Through careful analysis and practice, the author believes that the reason for this problem is that when Microsoft design VFP, only consider the replication and pasting of the form under the system menu, that is, the form under the system menu can use replication and paste hot keys. And the form under Windows is completely detached from the control of the system menu, so the copy and paste the hotkey fail.

---- Solving the way to write the following event handler to KeyPress Event in the control of the form (this article), the event handler first copies the selection content to the Windows clipboard, and then clip The content on the board is added to the control. KeyPress Event

LParameters nkeycode, nshiftaltctrl

IF nkeycode = 3

&& Ctrl C replication

-cliptext = this.seltext

ENDIF

IF nkeycode = 22

&& Ctrl V Paste

Do Case

Case this.selstart = 0

this.Value = -cliptext this.value

Case this.selstart> = 1

And this.selstart <= le (this.value)

THIS.VALUE = SUBS (this.Value, 1, this.selstart)

-Cliptext SUBS (this.Value, this.selstart 1)

Endcase

ENDIF

thisform.grid1.column1.setfocus ()

SELE recent

IF not EOF ()

Skip

ENDIF

thisform.refresh

---- Ten. Add a cyclic micromass control unit for VFP

---- In VFP programming, the fine-tuning control is one of the most common controls. Follow the basic functions provided by micro regulators, by clicking the up or down arrow, while reaching the maximum or minimum of the fine-tuning control, if you continue click the up or down arrow, you will remain the maximum or minimum. Through the analysis of the Spinner control attributes and events, the author implements the loop microiding control feature with programming methods.

---- Cyclespinner implemented by: When you click the up arrow to reach the maximum value, click the up arrow, you can automatically skip to the minimum; you click the down arrow to achieve the minimum value When you can automatically jump to the maximum; the rest functions inherit the functionality of the Spinner base class. The specific implementation method is as follows: Use a form control to design a fine tuning button in the form, and set the following properties:

SpinnerHighValue = max

&& Max should be less than Spinner Base Categories

&& offer maximum default

SpinnerlowValue = min

&& min should be greater than Spinner base class

&& offer the minimum default

Value = 1

Name = 'cyclespinner'

Write the following code in the init incident:

THIS.SPINNNERHIGHVALUE = this.

SpinnerHighValue this.increment

THIS.SPINNERLOWVALUE = this.

SpinnerlowValue-this.Increment

Write the following code in the InteractiveChange event:

IF this.value = this.spinnerhighvalue

THIS.VALUE = INT (this.

SpinnerlowValue this.increment)

ENDIF

IF this.value = this.spinnerLowhvalue

THIS.VALUE = INT (this.

SpinnerHighValue-this.increment)

ENDIF

Thisform.refresh

---- Take it as a class and add it to your class library.

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

New Post(0)