What is "Start Menu"? This should be a piece of crap. Because as long as you use the Windows system, you know that the menu appears when you click the Start button on the left side of the taskbar, and you may use this menu every day.
So can the software written by VFP do not use the menu, but the Software menu function items are placed in such a similar to the Windows system "Start Menu"? It's OK, as long as you like it.
Today we use a list box control to make a simple Start menu, and the runtime clicks the form's Start button, and then the following figure:
You can now perform the individual feature items in this Start menu, such as clicking the "Show Background" form below:
In addition, see the example in the previous example Vfp:timer control instance-the animation label is moving up and down, in this case the animation is left and right. In the VFP Basic Tutorial-list box control (ListBox) in the article has given the list box control common properties and methods, this example does not repeat these content, only give examples of the production process and code.
Production steps:
Create a new form, set its width and height property values to 290 and 250, and save it as "form 1.scx".
Add controls to the form and set properties:
1. Add a command button in the lower-left corner of the form to set its Caption property value to start.
2, add a list box control above the command button List1, drag it with the mouse to the width of the command button as wide as the Height property value set to 85.
3, add a Label control Label1, and set its Caption property value to "Programming entry Net", ForeColor property value to "255,0,0", The AutoSize property value is set to the. T.,fontsize property value set to the 12,fontbold property value set to. T.
4, add a Timer control, the interval property value with the default of 0.
The form designer following the above steps is complete as follows:
Third, add the event code:
1, the form of the Activate event code:
This.list1.additem ("Show animation")
This.list1.additem ("Turn off animation")
This.list1.additem ("Show background")
This.list1.additem ("Remove Background")
This.list1.additem ("Exit system")
2, the form of the MouseMove event code:
Lparameters Nbutton, Nshift, nXCoord, nYCoord
Thisform.list1.visible=.f.
3. Init event code for the form:
Cc=sys (16)
Start=at (":", cc)-1
Cend=rat ("\", cc,1)
Set Default to (Substr (cc,start,cend-start+1))
Thisform.list1.visible=.f.
Thisform.label1.visible=.f.
4, the command button "start" Click event Code: THISFORM.LIST1.VISIBLE=.T.
5, List box control List1 Click event code:
Do case This.listindex case
this.selected (5) && exit system
thisform.release case
this.selected (4) && Remove background
thisform.picture= ""
this.visible=.f.
Case this.selected (3) && display background
thisform.picture= "landscape. jpg"
this.visible=.f.
Case this.selected (2) && turn off animation
thisform.timer1.interval=0
thisform.label1.visible=.f.
this.visible=.f.
Case this.selected (1) && display animation
thisform.timer1.interval=40
thisform.label1.backstyle=0
thisform.label1.visible=.t.
This.visible=.f.
Endcase
6, Timer control timer1 timer event code:
If thisform.label1.left+thisform.label1.width>0
thisform.label1.left=thisform.label1.left-3
Else
thisform.label1.left=thisform.width
endif
Four, run "form 1.scx".
This example code is debugged in the win2003+vfp6.0 environment.
See the full set of "rookie also learn VFP" tutorial