用label控件要怎么实现鼠标经过时换图,鼠标一移开就换回原来的图??

vbfdy 2004-03-20 07:55:11
用label控件要怎么实现鼠标经过时换图,鼠标一移开就换回原来的图??

在线等,给出源代码就给分,谢谢。。。。。。
...全文
51 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
华芸智森 2004-03-20
  • 打赏
  • 举报
回复
1.可以在MouseMove事件和IMAGE1的父容器 和 IMAGE 的邻近控件的 MouseMove 编程.
Option Explicit

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = IMAGE3.Picture
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image1.Picture = IMAGE2.Picture
End Sub

2.也可以用API函数与时钟判断.. 相关API声明和函数.具体程序你自己写吧.
Public Type SmPointAPI
X As Long
Y As Long
End Type
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long

'
'取当前鼠标的屏幕坐标值.
'函数:SmScrMouseXY
'参数:
'返回值:SmPointAPI结构体.
'例子:
Public Function SmScrMouseXY() As SmPointAPI
Dim hCursorWnd As Long, Point As SmPointAPI
Dim M_Scrxy As SmPointAPI
GetCursorPos Point
hCursorWnd = WindowFromPoint(Point.X, Point.Y)
M_Scrxy.X = Point.X * 15: M_Scrxy.Y = Point.Y * 15
End Function
vbfdy 2004-03-20
  • 打赏
  • 举报
回复
谢谢。。结贴
rainstormmaster 2004-03-20
  • 打赏
  • 举报
回复
参考:
http://expert.csdn.net/Expert/topic/2827/2827134.xml?temp=.6534082
daisy8675 2004-03-20
  • 打赏
  • 举报
回复
label的圖象,把label換成什麼樣子?
rainstormmaster 2004-03-20
  • 打赏
  • 举报
回复
//用label控件要怎么实现鼠标经过时换图,鼠标一移开就换回原来的图??

lable控件不能载入图片,你应该用image或picturebox控件:

这是用picturebox实现的:
'一个picturebox,一个imagelist控件(事先加载两张不同的图片)
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long


Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (X >= 0) And (Y >= 0) And (X < Picture1.Width) And (Y < Picture1.Height) Then
SetCapture Picture1.hwnd
Set Picture1.Picture = ImageList1.ListImages(1).Picture
Else
Set Picture1.Picture = ImageList1.ListImages(2).Picture
ReleaseCapture
End If
End Sub
vbfdy 2004-03-20
  • 打赏
  • 举报
回复
不是,是换label的图像。。。
daisy8675 2004-03-20
  • 打赏
  • 举报
回复
你是說這個

Option Explicit

Private Sub Form_Load()
Me.Label1.MousePointer = 15
End Sub
vbfdy 2004-03-20
  • 打赏
  • 举报
回复
就是怎么判断鼠标是否在label上。。

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧