加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-16 22:38:13 所属栏目:大数据 来源:网络整理
导读:敲此例题时出现了一个问题,就是程序运行后,鼠标找不到啦!经过不懈努力和高人指点,这才把问题解决啦!自己不懂的还很多,编程路任重而道远 。 下面红色字体是注释,认真读写。 Option Explicit Dim x,r Private Sub Form_KeyPress(KeyAscii As Integer) I

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读