移动窗口
介绍 设计自己的启用了运动形式。你甚至可以添加功能最大化,最小化,恢复的一种形式。下面的代码提供了简要的说明,你可以复制粘贴在表单代码。 你有进口System.Runtime。InteropServices为了宣布Win32 API函数: 隐藏,复制Code
Imports System.Runtime.InteropServices
在表单的代码开始,声明所有常量和api: 隐藏,复制Code
Public Const GWL_STYLE = (-16) Public Const WS_DLGFRAME = &H400000 Public Const HTCAPTION = 2 Public Const WM_NCLBUTTONDOWN = &HA1 Public Const SW_HIDE = 0 Public Const SW_MAXIMIZE = 3 Public Const SW_MINIMIZE = 6 Public Const SW_RESTORE = 9 <DllImport("User32.dll")> _ Public Shared Function ShowWindow(ByVal hWnd As IntPtr, _ ByVal nCmdShow As Integer) As Integer End Function <DllImport("User32.dll")> _ Public Shared Function ReleaseCapture() As Integer End Function <DllImport("User32.dll")> _ Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal wMsg As Integer, _ ByVal wParam As Integer, ByVal lParam As Integer) As Integer End Function
这段代码粘贴在鼠标点下时事件的形式: 隐藏,复制Code
If e.Button = Windows.Forms.MouseButtons.Left Then Me.Cursor = Cursors.SizeAll Call ReleaseCapture() Call SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0&) Me.Cursor = Cursors.Arrow End If
下载源代码查看整个代码。 本文转载于:http://www.diyabc.com/frontweb/news11234.html