VB实现全窗体移动
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_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End If
End Sub
http://topic.csdn.net/t/20030524/18/1829023.html
http://zhidao.baidu.com/question/93411647.html?fr=qrl&cid=867&index=5&fr2=query
我想把form5移动到form3中picture1的位置,下面是我的代码(在form3的code中):
Dim r2 As RECT
GetWindowRect Picture1.hwnd, r2
Form5.ScaleMode = vbPixels '设置坐标单位为像素
Form5.Move r2.Left, r2.Top
Form5.Show
为什么移动的坐标仍然是默认的缇而不是屏幕像素呢?
请指教!
问题补充:
要实现窗口的正确移动,应该怎么做?
将form5的左上角的位置挪到form3中picture1左上角的位置
'form3中
Private Type rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Sub Command1_Click()
Dim wrect As rect
Dim picrect As rect
GetWindowRect Picture1.hwnd, picrect
GetWindowRect Form5.hwnd, wrect
MoveWindow Form5.hwnd, picrect.Left, picrect.Top, wrect.Right - wrect.Left, wrect.Bottom - wrect.Top, True
Form5.Show
End Sub
相关文档:
mxl=1 && 最大的文本框编号
mnl=1 &n ......
Option Explicit
Private Const NCBASTAT = &H33
Private Const NCBNAMSZ = 16
Private Const HEAP_ZERO_MEMORY = &H8
Private Const HEAP_GENERATE_EXCEPTIONS = &H4
Private Const NCBRESET = &H32
Private Type NCB
ncb_command As Byte
ncb_retcode As Byte
ncb_lsn As Byte
ncb_num As Byte ......
1、Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
Cancel = True
End Sub
2、Private Sub
Form_Unload(Cancel As Integer)
Cancel = ......
webbrowser 不能收到SendMessage的消息
主要是因为1webbrowser 的句柄找不到。经过努力搜索,终于解决了。做个记录.
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ......