- Inicie un nuevo proyecto EXE estándar. Form1 se agrega de forma predeterminada.
- Form1 de establecer las propiedades ControlBox, MinButton y MaxButton en False y, a continuación, desactive su título.
- Coloque un control CommandButton (Command1) a Form1.
- Coloque el código siguiente en la sección de declaraciones generales de Form1:
Private Declare Function SendMessage Lib "User32" _ Alias "SendMessageA" (ByVal hWnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ lParam As Any) As Long Private Declare Sub ReleaseCapture Lib "User32" () Const WM_NCLBUTTONDOWN = &HA1 Const HTCAPTION = 2 Private Sub Form_Load() Command1.Caption = "Exit" End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _ X As Single, Y As Single) Dim lngReturnValue As Long If Button = 1 Then Call ReleaseCapture lngReturnValue = SendMessage(Form1.hWnd, WM_NCLBUTTONDOWN, _ HTCAPTION, 0&) End If End Sub Private Sub Command1_Click() End End Sub
- Presione la tecla F5 para ejecutar el programa. Hace clic y se mantiene sobre Form1 le permitirá mover el formulario. Al presionar el control CommandButton, saldrá del programa.