永发信息网

VB鼠标拖动无标题窗体代码

答案:2  悬赏:10  手机版
解决时间 2021-02-01 08:10
  • 提问者网友:眉目添风霜
  • 2021-02-01 01:05
Y As Single)
ReleaseCapture
ret& = SendMessage(Me.hWnd, SC_MOVE + HTCAPTION, 0)
'WM_SYS向窗体发送一个窗体移动命令
'SC_MOVE + HTCAPION单击左键移动窗体
End Sub
'
', WM_SYSPrivate 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) As Long
Private Const WM_SYSCOMMAND = &H112
Private Const SC_MOVE = &HF010&
Private Const HTCAPTION = 2
Private Sub Command1_Click()
End
End Sub
Private Sub Form1_MouseDown(Button As Integer, Shift As Integer, X As Single
最佳答案
  • 五星知识达人网友:玩世
  • 2021-02-01 01:20
lParam As Any) As Long
Private Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1

Private Sub Form1_MouseDown(Button As Integer, Shift As Integer, X As Single, ByVal Y As Long, _
ByVal cx As Long; Alias "SendMessageA" (ByVal hwnd As Long, WM_NCLBUTTONDOWNPrivate Declare Function SetWindowPos& Lib " (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal X As Long;user32", ByVal wParam As Long;user32"user32", Y As Single)
', ByVal cy As Long;拖动窗体
If Button = 1 Then ’注意这里,你的无法实现就是这里的问题,没有定义鼠标按下
ReleaseCapture
SendMessage hwnd, ByVal wMsg As Long; () As Long
Private Declare Function SendMessage Lib ", ByVal wFlags As Long)

Private Declare Function ReleaseCapture Lib "
全部回答
  • 1楼网友:青灯有味
  • 2021-02-01 02:51
拖动 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) as long private const wm_syscommand = &h112 private const sc_move = &hf010& private const wm_nclbuttondown = &ha1 private const htcaption = 2 private sub form_mousedown(button as integer, shift as integer, x as single, y as single) releasecapture sendmessage me.hwnd, wm_syscommand, sc_move + htcaption, 0 'sendmessage hwnd, wm_nclbuttondown, htcaption, 0& '上述两种方法都能实现该功能。 end sub 置顶 private declare function setwindowpos& lib "user32" (byval hwnd as long, byval hwndinsertafter as long, byval x as long, byval y as long, byval cx as long, byval cy as long, byval wflags as long) 窗口代码: dim rtn '让窗口在顶层 rtn = setwindowpos(me.hwnd, -1, 0, 0, 0, 0, 3) '取消窗口在顶层 'rtn = setwindowpos(f_v.hwnd, -2, 0, 0, 0, 0, 3)
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯