Home | Index | Dotnet4all Snippets | Submit resources
About | Mail us 
Moveable Toolbars (Monday, January 30, 2006)



Found the following interesting discussion in the Newsgroups:

Moveable Toolbars
by:VJ

I am looking to implement moveable toolbars like in Word, or Visual
Studio... any pointers or articles would great..

Thanks
VJ


 Reply:
by:Cor Ligthert

 Hi VJ,

I made this sample for John Crouse, however the only thing in my opinion
what you have to change basicly are toolbars instead of labels.

(You can open a windowform application, delete all the code, past this
bellow in and try)

I hope this helps.

Cor

\\Public Class Form1
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Private components As System.ComponentModel.IContainer
Private WithEvents Label1 As New System.Windows.Forms.Label
Private WithEvents Label2 As New System.Windows.Forms.Label
Private mouseX, mouseY As Integer
Private arLabels() As Label
Dim myMousedown As String
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.ClientSize = New System.Drawing.Size(400, 400)
Label1.Name = "Label1"
Label2.Name = "Label2"
arLabels = New Label() {Label1, Label2}
Dim lblY As Integer = 100
For Each Lbl As Label In arLabels
Lbl.Location = New System.Drawing.Point(100, lblY)
Lbl.ForeColor = Color.Red
Lbl.BackColor = Color.Transparent
Lbl.TextAlign = ContentAlignment.MiddleCenter
Lbl.Text = Lbl.Location.X.ToString & "." &
Lbl.Location.Y.ToString
AddHandler Lbl.MouseDown, AddressOf Label_MouseDown
AddHandler Lbl.MouseUp, AddressOf Label_MouseUp
AddHandler Lbl.MouseMove, AddressOf Label_MouseMove
lblY += 30
Me.Controls.Add(Lbl)
Next
End Sub
Private Sub Label_MouseDown(ByVal sender As Object, ByVal _
e As System.Windows.Forms.MouseEventArgs)
Dim lbl As Label = DirectCast(sender, Label)
myMousedown = lbl.Name
lbl.BringToFront()
mouseX = Cursor.Position.X - lbl.Location.X
mouseY = Cursor.Position.Y - lbl.Location.Y
lbl.Cursor = Cursors.Hand
End Sub
Private Sub Label_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs)
Dim lbl As Label = DirectCast(sender, Label)
myMousedown = ""
lbl.Cursor = Cursors.Default
End Sub
Private Sub Label_MouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs)
Dim lbl As Label = DirectCast(sender, Label)
Static LastCursor As Point
Dim NowCursor As Point = New Point(Cursor.Position.X,
Cursor.Position.Y)
If Point.op_Inequality(NowCursor, LastCursor) Then
If myMousedown = lbl.Name Then
lbl.Location = New System.Drawing.Point(Cursor.Position.X _
- mouseX, Cursor.Position.Y - mouseY)
End If
LastCursor = Cursor.Position
lbl.Text = lbl.Location.X.ToString & "." &
lbl.Location.Y.ToString
End If
End Sub
End Class
///


 Reply:
by:hirf-spam-me-here@gmx.at (Herfried K. Wagner [MVP])

 

Do you want to implement that on your own or are you looking for
(commercial) components?

--
Herfried K. Wagner


 Reply:
by:Tom Spink

 Hi, Check out this website:

http://www.divil.co.uk

I use his components and they are amazing! So long as the application you
are writing is freeware, the license is free.

--
HTH,
-- Tom Spink



Posted by Xander Zelders



0 Comments:

Post a Comment

<< Home

 
Previous Posts
    - Project converted from VB6 to VB.Net gets subclass...
    - .Net says I'm not Online, but I am!
    - Freeware/shareware Windows controls
    - Combobox in datagrid?
    - To parenthesize or not... Bug in VB.Net?
    - How to change the Color of a Toolbar?
    - How to pass Objects as type System.Object?
    - How to create a Username/Login Page?
    - Suggestions to increase the performance of searchi...
    - Where did my Dataset Go?



Disclaimer & Terms of Use | DotNet4All.Com concept & © 2004 - 2007 by Zelders² - Holland