'要在MDI窗口的QueryUnload事件中写代码,子窗体的isRead变量跟of_Save方法要用public定义Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim tempControl As Object For Each tempControl In Forms If tempControl.Name <> MDIForm1.Name Then if tempControl.isRead=false then'如果没有 tempControl.of_Save end if End If Next End Sub
Dim hwnd as longhwnd = GetWindow(hwndMDIClient, GW_CHILD)
MDI窗口的Unload事件中 Call Shutdown 下面的程序你改改,应该能用 Public Sub Shutdown(Optional ByVal Force As Boolean = False) Dim i As Long Dim X As Integer On Error Resume Next For i = Forms.Count - 1 To 0 Step -1 Unload Forms(i) If Not Force Then If Forms.Count > i Then Exit Sub End If End If Next i If Force Or (Forms.Count = 0) Then Close If Force Or (Forms.Count > 0) Then End End Sub
Dim tempControl As Object
For Each tempControl In Forms
If tempControl.Name <> MDIForm1.Name Then
if tempControl.isRead=false then'如果没有
tempControl.of_Save
end if
End If
Next
End Sub
下面的程序你改改,应该能用
Public Sub Shutdown(Optional ByVal Force As Boolean = False)
Dim i As Long
Dim X As Integer
On Error Resume Next
For i = Forms.Count - 1 To 0 Step -1
Unload Forms(i)
If Not Force Then
If Forms.Count > i Then
Exit Sub
End If
End If
Next i
If Force Or (Forms.Count = 0) Then Close
If Force Or (Forms.Count > 0) Then End
End Sub