1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| 'Form1 的 BorderStyle=0 'Form1 里面 Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long Private Declare Function GetDesktopWindow Lib "user32"() As Long Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Private Sub Form_Load Form1.Height = Screen.Height Form1.Width = Screen.Width Form1.Top = 0 Form1.Left = 0 Me.AutoRedraw = True BitBlt Form1.hDC, 0, 0, Screen.Width, Screen.Height, GetDC(GetDesktopWindow), 0, 0, vbSrcCopy End Sub
'Form1 有一个 Timer(Timer1),Interval=1 Private Sub Timer1_Timer() Form2.Show 1 Timer1.Enabled = False End Sub
'Form2 里面 'Form2 的 BorderStyle=0 '设置 Form2 的 KeyPreview 为 True,否则……运行时就真的惨了…… Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.Left = Random(Screen.Width - Me.Width) Me.Top = Random(Screen.Height - Me.Height) End Sub
Private Function Random(ByVal Number) As Long Random = CLng(Rnd * Number + 1) End Function
'如果 KeyPreview=False,就不会触发这个事件了,就…… Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyEscape Then MsgBox "哈哈,这是专门给你的 SURPRISE!", vbInformation End End If End Sub
'Form2 有一个 Label(Label1),Caption="点我",Left=0,Top=0,AutoSize=True,字体……随便吧,反正自动调整。 Private Sub Form_Load() Me.Height = Label1.Height + Me.Height - Me.SacleHeight Me.Width = Label1.Width + Me.Width - Me.ScaleWidth End Sub
|