楼上的兄台:我早就想过这个问题,现在的问题就是在没有边框的情况下如何才能移动窗体?还有6楼的代码我加了,但是还是不能移动。咋回事?
汗~我打不开你的工程我没有装EXCEL...所以看不了你的窗体样子。。。你的窗体被控件覆盖了?
6楼的代码是FORM的鼠标按下触发。。。。如果你的FORM挡住了当然就不行了。。。。
人家代码对的。。你对边框是什么概念?
下面是个例子,你放个按钮上去:
Option Explicit
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 Long, lParam As Any)
Private Const htcaption = 2
Private Const wm_nclbuttondown = &HA1
Private Sub Command1_Click() '这个需要空格或者回车触发
End
End Sub
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i& , r&
If Button = 1 Then
i = ReleaseCapture()
r = SendMessage(hwnd, wm_nclbuttondown, htcaption, 0)
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i & , r &
If Button = 1 Then
i = ReleaseCapture()
r = SendMessage(hwnd, wm_nclbuttondown, htcaption, 0)
End If
End Sub
拖窗体可以移动。。。。如果你把按钮放大到整个屏幕。。。拖按钮可以移动。。。