Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Question about moving a themed borderless form

Hello, Thanks for checking out the thread , and hopefully someone can point me in the right direction....

Ok I have a form that I need to drag and the form im using i have themed.... so i try using the following code with no success.....

Code
Dim drag As Boolean
    Dim mousex As Integer
    Dim mousey As Integer

    Private Sub PositronTheme2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
        drag = True
        mousex = Windows.Forms.Cursor.Position.X - Me.Left
        mousey = Windows.Forms.Cursor.Position.Y - Me.Top
    End Sub
    Private Sub PositronTheme2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        If drag Then
            Me.Top = Windows.Forms.Cursor.Position.Y - mousey
            Me.Left = Windows.Forms.Cursor.Position.X - mousex
        End If
    End Sub
Thinking Of a Name Change ....
I've just tested it on Positron theme, it moves fine. But to answer your question:

Declare the following:
Code
Private cX, cY As Integer
Private Dragging As Boolean = False

MouseDown event:
Code
Dragging = True
cX = e.X
cY = e.Y

MouseMove event:
Code
If Dragging Then
      Me.Top = Me.Top + (e.Y - cY)
      Me.Left = Me.Left + (e.X - cX)
End If

MouseUp event:
Code
Dragging = False
You'll want to make changes directly to the PositronTheme class. Otherwise you'll be using repetitive code over all of your themed forms.

I've coded up a simple form skin for you. Take these concepts and apply them to Pat Positron's theme.

http://pastebin.com/BYbeSvQ3

Enjoy. 🤝
https://hackforums.net/showthread.php?tid=4558018
Thanks Guys .... appreciate the quick replies! :D
Thinking Of a Name Change ....


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by KingSeaNov 22, 2018 11:58 AM 7 230 Nov 22, 2018 11:58 AM
Last Post: passwords
[C#] by tenalp eht kcahJul 26, 2016 01:28 AM 3 223 Jul 26, 2016 01:28 AM
Last Post: 6e756c6c
[C] by Mr. RobotJan 23, 2016 02:42 AM 6 305 Jan 23, 2016 02:42 AM
Last Post: Mr. Robot