Skip to main content

Simple (but short cut) to Borderless Forms

 

Pros:

  • Simple, easy to Program
  • Easy to understand for the beginner

Cons

  • May flicker as controls are drawn and redrawn
  • Windows seems not to like this method much :)

Insert this code snippet in your form that you want to be movable :

 

#Region "Declarations"

Dim m As Integer = 0

Dim n As Integer = 0

Dim isMouseDown As Boolean = False

Dim isMouseDownAgain As Boolean = False

#End Region

#Region "Form Events"

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown

If isMouseDownAgain = True Then

    isMouseDown = False

    isMouseDownAgain = False

         End If

         m = MousePosition.X - Me.Location.X

         n = MousePosition.Y - Me.Location.Y

         Me.Location = New Point(MousePosition.X - m, MousePosition.Y - n)

         If isMouseDown = True Then

    isMouseDownAgain = True

        Else

    isMouseDownAgain = False

End If

isMouseDown = True

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

If isMouseDown = True And isMouseDownAgain <> True Then

        Me.Location = New Point(MousePosition.X - m, MousePosition.Y - n)

Else

      Exit Sub

End If

End Sub

Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp

isMouseDown = False

Me.Location = New Point(MousePosition.X - m, MousePosition.Y - n)

End Sub

#End Region

Comments

Popular posts from this blog

The suffocating roadblocks and dead end jobs

Life throws new challenges everytime you decide to do something new.

When you plan to try anything new, you area aware of the challenges that you are likely to face. But Life usually will have other plans. When you expect a right turn, Life will show you a left. When you least expect x to turn up at your door, you find y.

And then there is a dead end job.

This is one job that I at times enjoy. Because I get to work directly in the technologies that I like to work with. At the same time, I feel terrible about the senior management and my future prospects here. What is the worst is that I don't see any way out of this either.

It is not that I have not forwarded my resume over to the other firms. I have. But I have not received any meaningful reply yet. Any response that I have so far been able to elicit are of no interest to me whatsoever.

I feel I have to chalk out a path for myself again. Problem is, the task becomes more and more difficult with age. I can take less risk than I c…

A Good Day

I have a beautiful small house in the hills. It is about 3 km from Manali, in Himachal Pradesh. It is not much. Probably calling it a cottage is stretching it too far. I have got a couple of bedrooms, a small drawing room cum kitchen where we dine as well. There is storage and a small garage that is mostly empty. I have got another small room with just a single bed and a study built on the first floor. It is just about ten feet by ten feet but it has got a retractable ceiling and a wall made of glass with the rest of the roof being something of a balcony. This is the place where I like to spend most of my time.
In the front, there is a garden with some flowers in the front and trees lining the boundary wall. My mother has planted a few vegetables in the back that we regularly use in the kitchen. We mostly require only rice and eggs from the market.

A typical day starts with me waking up and going for a morning stroll. I often spend my nights in the room on the roof. So the first thing I…

My Little Wife

Amar choto bou chole bake bake... If you are looking for some meaning in the words written above - please stop. It is of no use.

This is a short dedicated to my wife whom I did not get to marry.

Being typically Bengali, she is puchu to me.

If you are reading this, please keep in my mind that I am not one bit drunk. And I don't particularly feel like writing either. This you see here is not prose. Just an open faucet. Or a gaping wound sp... okay. Scratch that. Open faucet it is.

She has got a small round face. Her eyes are symmetrical. A bit like almonds. They look lively and restless when open and calm or serene when closed. The nose is neither pointed not large. It sits right in the middle of the face with even elevations on both sides. It is not too small to notice nor is it too large to get in the way. Her lips are small, but not thin. There is an amount of volume to them that you would not usually expect.

Her face looks normal something from a distance. It looks small from c…