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

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...