->In the process of developing software, the aesthetics of the interface is an important factor in the commercialization of the software. This article introduces a method for realizing form background patterns. For this purpose, a beautiful three-dimensional background can be designed conveniently and flexibly. 1. Create a new form Form1 with the following properties:
Caption="Realization of background pattern"
Borderstyle=3 (no maximum and minimum buttons)
2. Create a grid control Grid1. Its position and size will be set in the program (the same size as Form1), and its properties are:
Enabled=False (the focus will not fall on the grid control Grid1)
Fillstyle=1 (change the Text properties of all cells)
Fixedcols=0 (no fixed rows)
Fixedrows=0 (no fixed columns)
Gridlines=False (grid lines are not visible),
Visible=True
3. Create the image control Picture1, and put the basic background pattern into it when the program is running. The properties are:
Visible=False (invisible)
Autosize=True (automatically adjust size)
4. Add Sheridan3DControls to the control, select the three-dimensional command button SSCommand, and create two buttons:
SSCommand1.Caption="Exit"
SSCommand2.Caption="Change background" (demonstrates different background patterns)
Their property Picture can call the same or different pattern as the background. If you use the ordinary command button control Command, it can also be used, but the command button has no background pattern.
5. Create a background pattern forming subroutine:
DimpictfileAsString' bitmap file name
DimFILEPATHAsString' file path
SubBackpict(pictfile)
picture1.ScaleMode=3
Form1.ScaleMode=3
picture1.Picture=LoadPicture(pictfile)
'The grid control covers the entire form background
grid1.Top=-1
grid1.Left=-1
grid1.Width=Width
grid1.Height=Height
grid1.Cols=Int(Form1.ScaleWidth/picture1.ScaleWidth) 1
grid1.Rows=Int(Form1.ScaleHeight/picture1.ScaleHeight) 1
'All unit sizes are equal to the basic pattern size
ForI=0Togrid1.Cols-1
Forj=0Togrid1.Rows-1
grid1.ColWidth(I)=picture1.ScaleWidth*15
grid1.RowHeight(j)=picture1.ScaleHeight*15
Nextj
NextI
'Select all units
grid1.SelStartCol=0
grid1.SelStartRow=0
grid1.SelEndCol=grid1.Cols-1
grid1.SelEndRow=grid1.Rows-1
grid1.Picture=Picture1.Picture
EndSub
6. Form main program:
PRivateSubForm_Load()
'Get the path name of the running program, with a backslash after the path name
IfRight(App.Path,1)<>"/"Then
filePath=App.Path&"/"
Else
filePath=App.Path
EndIf
'The form initially displays a background composed of Tiles.bmp basic patterns
pictfile="c:/windows/Tiles.bmp"
backpict(pictfile)
EndSub
7. Exit program command button:
PrivateSubSSCommand1_Click()
End
EndSub
8. Demonstrate different shading patterns: This article selects the Windows Tiles.bmp image, readers can also select other graphics they like. The code is as follows:
PrivateSubSSCommand2_Click()'Alternating demonstration of two background patterns
Ifpictfile=filePath&"Pict1.bmp"Then
pictfile="c:/windows/Tiles.bmp"
Else
pictfile=filePath&"Pict1.bmp"
EndIf
Backpict(pictfile)
EndSub->