'1,打开程序窗口,点击comand启动扫雷游戏,隐藏自身窗口.
'2,手动把扫雷最小化
'3,程序窗口5秒后自动显示,目的是把扫雷窗口恢复显示.
Dim lTime As Long, i As Integer, click As Boolean
Private Sub Command1_Click()
RetVal = Shell("C:\WINDOWS\system32\winmine.exe", 1)
click = True
Form1.Hide
lngHand = GetForegroundWindow()
'Form1.Show
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000 ' 每秒发生一次Timer事件
click = False
End Sub
Sub Timer1_Timer()
If click Then
i = i 1
lTime = 5 - i
Me.Caption = "还有" Str(lTime) "秒!"
If lTime = 0 Then
Form1.Show
Call ShowWindow(ByVal lngHand, SW_SHOWNORMAL) '将1.EXE窗口还原显示
Call SetForegroundWindow(ByVal lngHand) '设置焦点
Timer1.Enabled = False
End If
End If
End Sub
'///////////////添加一个模块,把下面的代码放进去///////
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long