PC Review


Reply
Thread Tools Rate Thread

Draggable controls possible at run-time?

 
 
Sam Marrocco
Guest
Posts: n/a
 
      21st Feb 2004
Is is possible to make vb.net controls such as a checkbox or button
draggable while an app is running, thereby allowing the user to
"re-design" the layout of buttons on a form?
--
==================================================================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
==================================================================

 
Reply With Quote
 
 
 
 
lonnieh
Guest
Posts: n/a
 
      22nd Feb 2004
I don't know how everybody else does it, but this is how i'd do it.
I'll have to code this in C# because I don't have a VB.net, but i'm
sure you'll be able to translate this just fine.

private int _mX; // _mX and _mY hold the
coordinates
private int _mY; // when the event _MouseDown fires

private void pictureBox1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
pictureBox1.Left += e.X - _mX; //(.Left = .Left) + e.X
- _mX
pictureBox1.Top += e.Y - _mY;
}
}

private void pictureBox1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
_mX = e.X;
_mY = e.Y;
}
}

looking through the MSDN cds I'd assume that the VB.net equivalent
would be...


[code:1:02070e9725]Private mX as Integer
Private mY as Integer

Private Sub pictureBox1_MouseDown(sender as Object, e As
System.Windows.Forms.MouseEventArgs) Handles
pictureBox1.MouseDown
If e.Button = MouseButtons.Left Then
mX = e.X
mY = e.Y
End If
End Sub

Private Sub pictureBox1_MouseMove(sender as Object, e As
System.Windows.Forms.MouseEventArgs) Handles
pictureBox1.MouseMove
If e.Button = MouseButtons.Left Then
pictureBox1.Left = pictureBox1.Left + e.X - mX
pictureBox1.Top = pictureBox1.Top + e.Y - mY
End If
End Sub[/code:1:02070e9725]

good luck.


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
Sam Marrocco
Guest
Posts: n/a
 
      22nd Feb 2004
Thanks, that answers my question---I was hoping there was a property
that I could set to make controls movable, but it looks like you're
suggesting the method (I was hoping) I wouldn't have to use. Thanks, it
works great!

lonnieh wrote:

> I don't know how everybody else does it, but this is how i'd do it.
> I'll have to code this in C# because I don't have a VB.net, but i'm
> sure you'll be able to translate this just fine.
>
> private int _mX; // _mX and _mY hold the
> coordinates
> private int _mY; // when the event _MouseDown fires
>
> private void pictureBox1_MouseMove(object sender,
> System.Windows.Forms.MouseEventArgs e)
> {
> if (e.Button == MouseButtons.Left)
> {
> pictureBox1.Left += e.X - _mX; //(.Left = .Left) + e.X
> - _mX
> pictureBox1.Top += e.Y - _mY;
> }
> }
>
> private void pictureBox1_MouseDown(object sender,
> System.Windows.Forms.MouseEventArgs e)
> {
> if (e.Button == MouseButtons.Left)
> {
> _mX = e.X;
> _mY = e.Y;
> }
> }
>
> looking through the MSDN cds I'd assume that the VB.net equivalent
> would be...
>
>
> [code:1:02070e9725]Private mX as Integer
> Private mY as Integer
>
> Private Sub pictureBox1_MouseDown(sender as Object, e As
> System.Windows.Forms.MouseEventArgs) Handles
> pictureBox1.MouseDown
> If e.Button = MouseButtons.Left Then
> mX = e.X
> mY = e.Y
> End If
> End Sub
>
> Private Sub pictureBox1_MouseMove(sender as Object, e As
> System.Windows.Forms.MouseEventArgs) Handles
> pictureBox1.MouseMove
> If e.Button = MouseButtons.Left Then
> pictureBox1.Left = pictureBox1.Left + e.X - mX
> pictureBox1.Top = pictureBox1.Top + e.Y - mY
> End If
> End Sub[/code:1:02070e9725]
>
> good luck.
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
> http://www.usenet.com


--
==================================================================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
==================================================================

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Draggable Navigation Map Mark Stephens Microsoft Excel Programming 0 22nd Jun 2008 04:08 PM
Getting draggable panels to snap Showjumper Microsoft ASP .NET 0 3rd Jul 2006 01:31 AM
List with draggable items Onno Willems Microsoft Access Forms 3 15th Dec 2004 09:16 AM
ASP DHTML Draggable Windows -> ASP.NET !!! soulcode Microsoft ASP .NET 0 22nd Mar 2004 01:53 AM
Draggable Control ? JezB Microsoft Dot NET Framework Forms 6 18th Dec 2003 11:49 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:05 PM.