Drag and Dock a Form to the Screen

Category:
Forms and Controls
Type:
Snippets
Difficulty:
Intermediate
Author:
Arvind Bhambhani

Version Compatibility: Visual Basic 6

More information:
This is code to drag a form with mouse. It docks itself when you try to move it to the edges of the screen. The code will work even if you set the BorderStyle property of the form to 0, i.e. no border.

This code works when you drag the form by clicking down on its active area, not on its title bar.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: