I got a small code that enables a control to be moved during runtime:
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const HTCAPTION = 2
Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left = True Then
Button1.Capture = False
Dim msg As Message = _
Message.Create(Button1.Handle, WM_NCLBUTTONDOWN, _
New IntPtr(HTCAPTION), IntPtr.Zero)
Me.DefWndProc(msg)
End If
End Sub
I need to save the button's new location after it has been moved and load it as well. I would like to use My.Settings for this but I do not know what values should I store.
For example:
Create a New Setting: Project menu-> Properties -> Settings ->create a setting as below
Name Type Scope Value
myLoc System.Drawing.Point User 2;2
Applied to app
Read Settings when Form_Load
Button1.Location = My.Settings.myLoc
Change and save Settings
My.Settings.myLoc = Button1.Location
My.Settings.Save()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With