求VB6下绘制一个图片的方法,要求有鼠标移入移出事件和点击事件,我对VB不大熟悉,但是这个事情又很紧急,希望大家伸出援手,多谢,多谢!
解决方案 »
- 毕业设计,班级管理系统!!高手进啊!!!!
- 枕善居关于QQ群伤害网友的郑重声明!!!!!!!
- 怎么实现搜索本机的MP3文件,然后让它们显示在Listbox中呀?
- 谁有英文简历样例?求
- ACTIVE 下载到指定的目录
- 简单的问题(关于MDI子窗体菜单)
- 怎样提取[abc]defghij字符串中的abc??在线。。。
- 怎么刷新数据???
- 怎样实现不删除Acess表中的原有记录而将Excell表中的记录导入Acess
- 怎么样取得目前连接状态
- 用Winsock控件传文件的速度怎样达到最佳化?
- 求:汉字被转成了"%D6%D0%B9%C5" ,也就是说"D6 D0 B9 C5 ",这种是什么编码?谢谢!!
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.Image Image3
Height = 1215
Left = 1560
Top = 1680
Width = 2655
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = FalseDim pic1 As StdPicture, pic2 As StdPictureDim btnLeft As Single, btnTop As Single
Dim btnRight As Single, btnBottom As SingleDim inButton As Boolean, last As BooleanPrivate Sub Form_Load()
Set pic1 = LoadPicture(App.Path + "\111.bmp")
Set pic2 = LoadPicture(App.Path + "\112.bmp")
btnLeft = 150: btnTop = 150
' 亮点在这里啊!不使用 ScaleX 和 ScaleY 计算得到的长度就是有问题的。
btnRight = ScaleX(pic1.Width, vbHimetric, vbPixels) * 15 + btnLeft
btnBottom = btnTop + ScaleY(pic1.Height, vbHimetric, vbPixels) * 15
inButton = False: last = inButton
Image3.Picture = pic1
MsgBox Image3.Picture.Width & " x " & Image3.Picture.Height & vbNewLine & _
Image3.Width & " x " & Image3.Height
End SubPrivate Function IsMouseInButton(X As Single, Y As Single) As Boolean
IsMouseInButton = (X <= btnRight And X >= btnLeft) And (Y <= btnBottom And Y >= btnTop)
End FunctionPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "x: " & X & " y: " & Y & " Button: " & Button
inButton = IsMouseInButton(X, Y)
If inButton <> last Then
Me.Refresh
Debug.Print "InButton: " & inButton & ", last: " & last
End If
last = inButton
End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If inButton Then
MsgBox ("button clicked.")
End If
End SubPrivate Sub Form_Paint()
If inButton Then
PaintPicture pic2, btnLeft, btnTop
Else
PaintPicture pic1, btnLeft, btnTop
End If
End Sub