LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Drag label position on userform at runtime - jerky movement

I want to be able to drag a label (or other suitable control to act
like a box) on a userform at runtime.

I have written the following to do this but have these problems:
1) the movement is quite jerky - at times the label can even jump
backwards although I am only moving the mouse fowards
2) the mouse gets ahead of the label

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
Static sngXOld As Single
Dim sngDelta As Single

If m_blnMouseIsDown Then
sngDelta = (X - sngXOld)
Me.Label1.Left = Me.Label1.Left + sngDelta
Me.Label2.Left = Me.Label2.Left + sngDelta
DoEvents
sngXOld = X
End If
End Sub

I can improve things a little bit by only moving the label once the
mouse is moved a certain minimum distance, ie. If Abs(sngDelta) 5,
but it's still not perfect and the mouse still gets ahead of the label.

Can anyone suggest an alternative approach - or have I simply
overlooked something here?

Thanks a lot,
Andrew

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default Data Label Position Kermit Charts and Charting in Excel 2 January 16th 08 01:18 AM
Outside Label Position not listed Debbie Charts and Charting in Excel 1 September 8th 06 10:28 AM
Change label border color at runtime timspier[_3_] Excel Programming 3 March 11th 06 06:53 AM
Add a label at runtime Ron Excel Programming 3 December 4th 05 08:23 PM
Data Label Object Position not working Sean[_7_] Excel Programming 0 August 12th 04 10:14 PM


All times are GMT +1. The time now is 12:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"