VB中如何编程标签碰到窗体边框时反d

VB中如何编程标签碰到窗体边框时反d,第1张

以下是我程序中的片段:

Private Sub Picture2_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

If X + Label3.Width <= Picture2(0).Width Then

Label3.Left = X

Else

Label3.Left = X - Label3.Width

End If

end sub

当Label3抵达左侧告缺或右侧野伏时,将自动翻转颂友携位置,而不会超出界外而看不见。

Dim

r,

l,

s

As

Boolean

Private

Sub

Form_Load()

s

=

True

l

=

False

r

=

False

End

Sub

Private

Sub

Timer1_Timer()

If

Image1.Left

<=

0

Or

r

=

True

Then

Image1.Left

=

Image1.Left

+

100

l

=

False

r

=

True

End

If

If

Form1.Width

-

Image1.Width

<=

Image1.Left

Or

l

=

True

Then

Image1.Left

=

Image1.Left

-

100

r

=

False

l

=

True

End

If

If

(Image1.Left

<>

0

Or

Form1.Width

-

Image1.Width

<=

Image1.Left)

And

s

=

True

Then

Image1.Left

=

Image1.Left

+

100

l

=

False

r

=

True

s

=

False

End

If

End

Sub

我调唯李试过可达到你的雀闷要求

我在窗口上添顷山弯加了image控件

和timer控件

timer1.interval=1

image1.stretch=true


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12551820.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-26
下一篇 2023-05-26

发表评论

登录后才能评论

评论列表(0条)

保存