VB工程--百例94--屏幕保护

前端之家收集整理的这篇文章主要介绍了VB工程--百例94--屏幕保护前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

敲此例题时出现了一个问题,就是程序运行后,鼠标找不到啦!经过不懈努力和高人指点,这才把问题解决啦!自己不懂的还很多,编程路任重而道远下面红色字体是注释,认真读写。

Option Explicit
Dim x,r
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then '按escape键退出
x = ShowCursor(True) 'ShowCursor 函数功能:该函数显示或隐藏光标。
End If

End Sub
Private Sub Form_Load()
' x = ShowCursor(False) 此句话的意思是光标隐藏 把false改成true光标同样出现
Form1.Width = Screen.Width
Form1.Height = Screen.Height
Form1.BackColor = RGB(0,255)
Label1.Top = (Screen.Height - Label1.Height) / 2
Label1.Left = 0
Label1.Caption = "廊坊师范学院信息技术提高班"
Label1.ForeColor = RGB(255,0)
Label1.FontItalic = True
Label2.Caption = "九期学员邢金聪"
Label2.ForeColor = RGB(0,255,255)
Label2.FontItalic = True
Label2.Left = (Screen.Width - Label2.Width) / 2
Label2.Top = 0
End Sub

Private Sub Timer1_Timer()
r = SetWindowPos(Form1.hwnd,-1,3)
' BOOL SetWindowPos(HWND hWnd,HWND hWndlnsertAfter,int X,int Y,int cx,int cy,UNIT.Flags)
' h 是类型描述,表示句柄, Wnd 是变量对象描述,表示窗口,所以hWnd 表示窗口句柄
' 通俗地说,如果把一个到处跑的人当作指针的话,那么HWND就是该人的身份证
'http://baike.baidu.com/view/4287577.htm
Label1.Left = Label1.Left + 60
If Label1.Left > Form1.Width Then
Label1.Left = -3000
End If
Label2.Top = Label2.Top + 60
If Label2.Top > Form1.Height Then
Label2.Top = -3000
End If
End Sub

Option Explicit
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long,ByVal hWndInsertAfter As Long,ByVal x As Long,ByVal y As Long,ByVal cx As Long,ByVal cy As Long,ByVal wFlags As Long) As Long
http://baike.baidu.com/view/1080349.htm

Public Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
http://baike.baidu.com/view/1079919.htm

原文链接:https://www.f2er.com/vb/260326.html

猜你在找的VB相关文章