关于api的一个比较简单的程序,请赐教!(20分)

  • 主题发起人 主题发起人 richboy2002
  • 开始时间 开始时间
R

richboy2002

Unregistered / Unconfirmed
GUEST, unregistred user!
我按书中所说,在vb中添加了一个command1控件,加入如下代码:
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
Dim nParam As Long
With Command1
If X > 0 And X < 100 then

nParam = HTLEFT
else
If X > .Width - 100 And X < .Width then

nParam = HTRight
End If
If nParam then

Call ReleaseCapture
Call SendMessage(.hwnd, WM_NCLBUTTONDOWN, nParam, 0)
End If
End With
End Sub
但好象并不能实现书中所说的!!请问是怎么回事??请赐教!(该段代码的目的是为了在
运行环境下能拖动command控件,使其左右大小能变动)
 
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 Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim nParam As Long
With Command1
If X > 0 And X < 100 then
nParam = HTLEFT
else
If X > .Width - 100 And X < .Width then
nParam = HTRight
End If
If nParam then
Call ReleaseCapture
Call SendMessage(.hwnd, WM_NCLBUTTONDOWN, nParam, 0)
End If
End With
End Sub
 
VB我没用过,不过类似功能我在delphi实现过
 
说了跟没说一样!
 
如果你的那些判断没问题,SendMessage 起作用了吗?跟踪一下吧。--试试 WM_LBUTTONDOWN
 
后退
顶部