在小舖看到這篇令我很有興趣的功能,二話不說 ^^ 又要自己動手寫寫看了
叫出三個表單 toolbar 也跟著新增三個 |
點選 toolbar 上的 Form2 讓表單最上層並關閉 |
Form2 關閉後 toolbar 也一起清掉 |
MDI上的程式碼 |
表單上的程式碼 |
Private Sub frm1_Click()
Call frmShow(Form1)
End Sub
Private Sub frm2_Click()
Call frmShow(Form2)
End Sub
Private Sub frm3_Click()
Call frmShow(Form3)
End Sub
Private Sub frmShow(ByVal tmpForm As Form)
With tmpForm
.Show
Call toolshow(.Caption, .Caption)
End With
End Sub
Private Function toolshow(ByVal s As String, ByVal a As String)
With Toolbar1.Buttons
For i = 0 To .Count - 1
If .Item(i + 1).Caption = s Then Exit Function
Next
AddBTN:
.Add.Caption = s
.Item(.Count).Tag = a
End With
End Function
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Call ShowForm(Button.Tag)
End Sub
Private Sub ShowForm(ByVal tmpForm As String)
Dim objForm As Form
For Each objForm In Forms
If objForm.Name = tmpForm Then
objForm.ZOrder
Exit Sub
End If
Next
End Sub
Public Sub DelTool(ByVal frmName As String)
With Toolbar1.Buttons
For i = 0 To .Count - 1
If .Item(i + 1).Caption = frmName Then: .Remove (i + 1): Exit For
Next
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
MDIForm1.DelTool (Me.Caption)
End Sub
請問可以提供程式檔嗎?
回覆刪除先寄信過來吧 ^^
刪除