|
zhengjialon 发表于 2011-11-30 12:22
谢谢! 看来只能通过判断是否有错误的方法了
不判断错误也可以,用API:
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Sub Command0_Click()
Dim lpClassName As String * 256
If Left$(lpClassName, GetClassName(GetParent(Me.hwnd), lpClassName, 256)) = "OFormsub" Then
MsgBox "有父窗体"
Else
MsgBox "没有父窗体"
End If
End Sub
|
|