建立工程,點“工程”->“組件”,在列表中找到並勾選“Microsoft PictureClip Control 6.0”將其添加到工具箱。
在表單中添加一個PictureClip控制項,設定它的Picture屬性裝載一副映像,設定PictureClip控制項的Col屬性為3(3列),Row屬性為3(3行)。
然後添加一個CommandButton控制項Command1,設定其Style為1(圖形按鈕),再複製8個Command1,提示是否建立控制項數組時點“是”,再添加一個CommandButton控制項Command2,將Caption屬性設為“轉換”
如:
{
function anonymous()
{
function anonymous()
{
function anonymous()
{
function anonymous()
{
if(this.width>screen.width-500)this.style.width=screen.width-500;
}
}
}
}
}" border="0">
在表單中添加以下代碼:
Option Explicit
Private Sub Command2_Click()
Dim i As Integer, j As Integer
For i = 0 To 8
Command1(i).Caption = "" '去掉文字
Command1(i).Picture = PictureClip1.GraphicCell(i)
Command1(i).Width = PictureClip1.CellWidth * 15
Command1(i).Height = PictureClip1.CellHeight * 15
If i Mod 3 = 0 Then
j = j + 1
End If
If i Mod 3 <> 0 Then
Command1(i).Move Command1(i - 1).Left + Command1(i - 1).Width, Command1(0).Top + (j - 1) * Command1(0).Height
Else
If i <> 0 Then
Command1(i).Move Command1(0).Left, Command1(i - 1).Top + Command1(i - 1).Height
End If
End If
Next
End Sub
運行:
{
function anonymous()
{
function anonymous()
{
function anonymous()
{
function anonymous()
{
if(this.width>screen.width-500)this.style.width=screen.width-500;
}
}
}
}
}" border="0">
點擊“轉換”
{
function anonymous()
{
function anonymous()
{
function anonymous()
{
function anonymous()
{
if(this.width>screen.width-500)this.style.width=screen.width-500;
}
}
}
}
}" border="0">
實際應用中可能將圖片分成的塊數不一定,所以按鈕可以只建立一個(index設為0),然後通過程式動態建立其它按鈕。