Dear All,
I'm working on a new project but have been struck dumb one of the first hurdles! I wish to create many panels but each panel must be moveable via click and drag. The code I'm working with so far works if the Panel already exists but not if I create one through controls.add().
In Summary it would work like this:
1: User clicks 'Add Panel'
2: Panel name generated by user input
3: Panel created on screen and can be moved where user wants
4: Repeat 1 - 4 as needed
Code:
Panel Creation (works without width & height but gives a weird shaped panel):
Variables being called:
Mouse Down:
Mouse Up:
Mouse Move:
I'm working on a new project but have been struck dumb one of the first hurdles! I wish to create many panels but each panel must be moveable via click and drag. The code I'm working with so far works if the Panel already exists but not if I create one through controls.add().
In Summary it would work like this:
1: User clicks 'Add Panel'
2: Panel name generated by user input
3: Panel created on screen and can be moved where user wants
4: Repeat 1 - 4 as needed
Code:
Panel Creation (works without width & height but gives a weird shaped panel):
Variables being called:
Code:
Dim pc_panel as Panel
Dim Drag_Me as boolean = false
Dim mousex as integer
Dim mousey as integer
Code:
pc_panel = New Panel
pc_panel.name = *chose from registry keys*
pc_panel.backcolor = color.red
pc_panel.width = 30
pc_panel.height = 30
pc_panel.top = 50
pc_panel.left = 50
controls.add(pc_panel)
Code:
Drag_Me = true
mousex = Windows.Forms.Cursor.Position.X - sender.left
mousey = Windows.Forms.Cursor.Position.Y - sender.top
Code:
Drag_me = false
Code:
If Drag_Me = True Then
*Panel Name*.Top = Windows.Forms.Cursor.Position.Y - mousey
*Panel Name*.Left = Windows.Forms.Cursor.Position.X - mousex
End If