O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Make a Borderless Form Movable

Problem

You want to create a borderless form that can be moved. This might be the case if you are creating a custom window that has a unique look (for example, for a visually rich application such as a game or a media player).

Solution

Create another control that responds to the MouseDown, MouseUp, and MouseMove events and programmatically moves the form.

Discussion

Borderless forms omit the title bar portion, which makes it impossible for them to be moved by the user. You can compensate for this shortcoming by adding a control to the form that serves the same purpose.

For example, Figure 11-16 shows a form that includes a label for dragging. When the label is clicked, the code sets a form-level flag to indicate it’s in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required