当你正在做……不管你做什么了,反正你忙着,突然,窗口不见了。过了一会儿,窗口又回来了。是不是很有趣?
  打开VB,让我们做这个程序去害人。
  先声明作案工具,打开一个模块,写代码:
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Type POINTAPI
        x As Long
        y As Long
End Type
Public Declare Function ShowWindowAsync Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5
  然后在窗体中放置一个时钟,设Interval为1000。在Form_Load事件中写上“Me.Hide”,然后双击时钟,写以下代码:
Private Sub Timer1_Timer()
    If Hidden Then
        If Int(Rnd() * 10) = 0 Then
            ShowWindowAsync wnd, SW_SHOW
            Hidden = False
        End If
        Exit Sub
    Else
        If Int(Rnd * 100) > 1 Then Exit Sub
    End If
    
    Dim myPoint As POINTAPI
    GetCursorPos myPoint
    
    wnd = WindowFromPoint(myPoint.x, myPoint.y)
    If wnd = 0 Then Exit Sub
    
    tmp& = GetParent(wnd)
    While tmp& <> 0
        wnd = tmp&
        tmp& = GetParent(wnd)
    Wend
    
    ShowWindowAsync wnd, SW_HIDE
    
    Hidden = True
End Sub
  试试看,窗口是不是神出鬼没?为了更好的恶作剧,按老规矩,我提供了免安装版本。试试看吧!这回的恶作剧效果真的很好。