在vb中怎么实现,拖动一个窗体时,另一个窗体也随之改变。类似于千千静听一样。
注:用windows api实现。
大侠们,帮帮忙。在此先谢过了
注:用windows api实现。
大侠们,帮帮忙。在此先谢过了
解决方案 »
- 文本中怎么删掉其中的一行或多行?
- 问一个高难度的问题
- vsflexgrid 问题!在线等高手帮忙一下!
- commondialog控件问题
- 请问在vb中如何调用autocad自动绘制图
- 下载下来的xml页面用什么查看?
- 使用此功能时WebBrowser1.LocationName为什么有时返回的是网址?有办法避免吗?
- 请教各位关于VB的初学用书,跟贴有分!!!
- 哪儿可以下载 VB6 SP5中文版
- 谁帮我解答一个非常简单的SQL问题,轻松赚30,我最后的分分哪。
- VB中当charset=UTF-8时quoted-printable解码算法,请各位大侠多多指点
- innosetup制作vb安装程序高手请进
Option Explicit
Private Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const WM_SYSCOMMAND = &H112&
Private Const SC_MOVE = &HF012&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) As Long
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 LongPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
Call ReleaseCapture
SendMessage Me.hwnd, WM_SYSCOMMAND, SC_MOVE, 0
Form2.Left = Form1.Left
Form2.Top = Form1.Top + Form1.Height + 5
End If
End Sub
Private Sub Form_Load()
Me.BorderStyle = 0
Form2.Show
Form2.BorderStyle = 0
Form2.Left = Form1.Left
Form2.Top = Form1.Top + Form1.Height + 5
End Sub
呵呵
我就是说说,我这里没存代码。
Public Declare Function ReleaseCapture Lib "user32" () As Long
这俩是可以解决,看你怎么写了,首先要不停的判断那个所谓的QQ有没有移动
然后
ReleaseCapture
SendMessage hwnd, &HA1, 2, 0 '让被点中的(mousedown)窗口跟着鼠标移动的轨痕走
'form1代码
Private Sub Form_Load()
prevWndProc = GetWindowLong(Me.hwnd, GWL_WNDPROC)
SetWindowLong Me.hwnd, GWL_WNDPROC, AddressOf WndProc
Form2.Show
End SubPrivate Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.hwnd, GWL_WNDPROC, prevWndProc
End Sub
' ' '新建一个模块,代码如下:Declare Function CallWindowProc Lib "user32 " Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Declare Function SetWindowLong Lib "user32 " Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "user32 " Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As LongPublic Const GWL_WNDPROC = (-4)
Public Const WM_MOVE = &H3
Public Const WM_SIZE = &H5Public prevWndProc As Long ' ' ' '默认窗口程序地址
Public Function WndProc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error GoTo ShowErr
' ' ' ' ' '处理窗体移动的消息
If Msg = WM_MOVE Or Msg = WM_SIZE Then
''''
Form2.Move Form1.Left, Form1.Top + Form1.Height
End If
' ' ' ' ' '
WndProc = CallWindowProc(prevWndProc, hwnd, Msg, wParam, lParam)
Exit Function
ShowErr:
MsgBox Err.Source & "- " & Err.Description
End Function