如果你能知道那个窗口的标题的话,可以通过findwindow这个api来查找

解决方案 »

  1.   

    谢谢大家!
    就是当我仍然使这个对话框显示时,另一条信息到了,于是程序就要执行.show vbModal,提示模式对话框已加载,不能再载入此窗体
      

  2.   

    方法1
     on error resume Next
    方法2
      设一个全局内存变量来记录窗体的加载与卸载
      如:
      Public AlarmFLoaded as Boolean
      在AlarmF.Show vbMadal语句之前置 AlarmFloaded=True
      在AlarmF关闭时,置 AlarmFloaded=False
      
        
      

  3.   

              '下面是出现错误的部分代码         
         sql = "Select CarCode,CarUnitID,UnitTelePhone From CarInfo Where  CarUnitID=" & "'" & sMark & "'"
                            rst.Open sql, P_Cn, adOpenKeyset, adLockReadOnly
                            If Not rst.EOF Then
                                With rst
                                    NewCar.sCarCode = !CarCode
                                    NewCar.sCarUnitID = !CarUnitID
                                    NewCar.dColor = &HFFFF00
                                    NewCar.sPhoneCode = !UnitTelePhone
                                End With
                                rst.Close
                                If P_AlarmDic.Count = 0 Then
                                    Set NewCar.Text = Main.MonitorText(0)
                                Else
                                    P_CMonitorCar.MonitorTextIndex = P_CMonitorCar.MonitorTextIndex + 1
                                    Load Main.MonitorText(P_CMonitorCar.MonitorTextIndex)
                                    Main.MonitorText(P_CMonitorCar.MonitorTextIndex).ZOrder 0
                                    Set NewCar.Text = Main.MonitorText(P_CMonitorCar.MonitorTextIndex)
                                End If
                                P_CMonitorCar.CarDic.Add sMark, NewCar
                                P_AlarmDic.Add NewCar.sCarCode, sMark
                                TransactCar sVCCol(i), NewCar, DirectionLayer, PointLayer, map, ListView, Form
                                MsgBox NewCar.sCarCode + msgAlarm, vbOKOnly + 32, "注意!"
                                PlaySound P_sPath + "Zr454.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
                                
                                rst.Open "Alarm", P_Cn, adOpenKeyset, adLockOptimistic ', , , adCmdTable
                                With rst
                                    .AddNew
                                    !UnitID = sMark
                                    !CarCode = NewCar.sCarCode
                                    !AlarmTime = Now
                                    !WorkerCode = P_sWorkerCode
                                    !Alarmtype = sType
                                    !TranStatus = 0
                                    !AlarmCon = sVCCol(i)
                                    !TranResult = ""
                                    !ReMark = ""
                                    .Update
                                End With
                                rst.Close
                                                              AlarmF.Show 'vbModal'在这儿出现错误
                            End If
                        End If'用FindWindow不可以
      

  4.   

    Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long 
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long    Function IsRunning(ByVal ProgramID) As Boolean  ' 传入进程标识ID 
      Dim hProgram As Long  '被检测的程序进程句柄 
      hProgram = OpenProcess(0, False, ProgramID)  
      If Not hProgram = 0 Then  
        IsRunning = True  
      Else  
        IsRunning = False  
      End If  
      CloseHandle hProgram  
    End Function      Sub Form_Click() 
      Dim X 
      Me.Caption = "开始运行" 
      X = Shell("NotePad.EXE", 1) 
      While IsRunning(X) 
        DoEvents 
      Wend 
      Me.Caption = "结束运行" 
    End Sub程序内置模块可以用AlarmF.Visible 和 AlarmF.WindowState 判断。
      

  5.   

    可以有这样一种简便的实现方法:定义一个全局型的变量,在需要打开的窗体加载时标记为打开;
    在UNLOAD时,将该标记置回初始值。
      

  6.   

    dim f as new AlarmF
    load f
    f.show