Link to home
Start Free TrialLog in
Avatar of jsound
jsound

asked on

Moving Window without Border

I have a form with the BorderStyle set to None. The code for moving the form is no problem, as I have that going.

Problem: When I move the form, Windows leaves a 'trail' of previous form locations, which I think is very little I can do about. What I thought of doing is to show only an outline of the form while it is being moved. However, that is what I need help with. Any suggestions?

Thanks,

JB
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

How are you currently moving the form?  There may be a better way that doesn't leave trails...
Avatar of caball88
caball88

the trails could be a video card issue, not sure if its a property of .NET but just that computer cannot refresh the screen fast enough.
Avatar of jsound

ASKER

Using the two event handlers does the trick. The panel pnlMain sits in the background and takes the mouse down and mouse move events. However, I could just do that with the form and it works the same.

    Private Sub pnlMain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseDown
        If e.Button = MouseButtons.Left Then
            StartPoint = Me.PointToScreen(New Point(e.X, e.Y))
        End If
    End Sub

    Private Sub pnlMain_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlMain.MouseMove
        If e.Button = MouseButtons.Left Then
            Dim currentPoint As Point = Me.PointToScreen(New Point(e.X, e.Y))
            Me.Location = New Point(Me.Location.X - (StartPoint.X - currentPoint.X), Me.Location.Y - (StartPoint.Y - currentPoint.Y))
            StartPoint = currentPoint
        End If
    End Sub
Avatar of jsound

ASKER

A quick update:

Seems that the 'trails' are mostly showing up over the scrollbars of the VS.NET IDE that was sitting in the background. Looks like on a normal desktop the 'trails' are not that much of an issue.

So, while this issue seems like it's workable, the question still remains: Is there a way to basically just show the outline of a borderless form when it is being moved?

Thanks for your help and suggestions thus far!

JB
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jsound

ASKER

Worked like a charm! :-)

Thanks for your help!

JB