我没明白楼主在说什么。 请问楼主,“标题栏”都没了,你哪来的“系统菜单”呢?我给个代码,把代码帖入窗体的代码窗口,执行后大概就是楼主你要的效果,别忘给分哦:) Option Explicit'***************************************** 移动窗体的API Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long Private Const WM_NCLBUTTONDOWN = &HA1 Private Const HTCAPTION = 2 '***************************************** 隐藏任务栏图标API Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Const GWL_EXSTYLE = (-20) Private Const WS_EX_TOOLWINDOW = &H80&Private Sub Form_Load() '************************ 初始化窗体 ************************ With Me .AutoRedraw = True: .BorderStyle = 0: .Caption = "" .Width = 8775: Me.Height = 2650 '2250 .Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2 End With '************************ 隐藏任务栏按钮 ************************ SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = 1 Then Call ReleaseCapture Call SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&) End If End SubPrivate Sub Form_Click() End '右键结束程序 End Sub
以下是我的源码: Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Const GWL_STYLE = (-16) Private Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME Private Const WS_SIZEBOX = &H40000 Private Const HTCAPTION = 2 Private Const WM_NCLBUTTONDOWN = &HA1Private Sub Form_Load() Dim OldStyle As Long ScaleMode = 3 ForeColor = vbGreen OldStyle = GetWindowLong(hWnd, GWL_STYLE) SetWindowLong hWnd, GWL_STYLE, OldStyle And Not WS_CAPTION And Not WS_SIZEBOX End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = vbLeftButton Then If Y >= 0 And Y <= 25 Then ReleaseCapture SendMessageLong hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0 End If End If End SubPrivate Sub Form_Paint() Line (0, 0)-(ScaleWidth, 25), vbBlue, BF CurrentX = 10 CurrentY = 10 Print "标题栏" End Sub
请问楼主,“标题栏”都没了,你哪来的“系统菜单”呢?我给个代码,把代码帖入窗体的代码窗口,执行后大概就是楼主你要的效果,别忘给分哦:)
Option Explicit'***************************************** 移动窗体的API
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Long) As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
'***************************************** 隐藏任务栏图标API
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_TOOLWINDOW = &H80&Private Sub Form_Load()
'************************ 初始化窗体 ************************
With Me
.AutoRedraw = True: .BorderStyle = 0: .Caption = ""
.Width = 8775: Me.Height = 2650 '2250
.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
End With
'************************ 隐藏任务栏按钮 ************************
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
Call ReleaseCapture
Call SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End SubPrivate Sub Form_Click()
End '右键结束程序
End Sub
'************************ 隐藏任务栏按钮 ************************
SetWindowLong Me.hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
Private Const WS_SIZEBOX = &H40000
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1Private Sub Form_Load()
Dim OldStyle As Long
ScaleMode = 3
ForeColor = vbGreen
OldStyle = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong hWnd, GWL_STYLE, OldStyle And Not WS_CAPTION And Not WS_SIZEBOX
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
If Y >= 0 And Y <= 25 Then
ReleaseCapture
SendMessageLong hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End If
End If
End SubPrivate Sub Form_Paint()
Line (0, 0)-(ScaleWidth, 25), vbBlue, BF
CurrentX = 10
CurrentY = 10
Print "标题栏"
End Sub