易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

VB文件粉碎机


'代码:
Option Explicit
'======================用于查找进程和终止进程的API函数常数定义================ =====
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessF ......

VB操作WORD

 Dim wdapp As Word.Application
    Dim wddoc As Word.Document
    Dim wdtable As Word.Table
   
    Set wdapp = CreateObject("word.application")
   
    Set wddoc = wdapp.Documents.Add
   ......

VB 简单计算器

Option Explicit
Dim potflag As Integer      '标识是否用小数点
Dim numcol As Integer       ' 点击运算符的个数
Dim LastInput               ' 指示上一次操作的内容
Dim colflag ......

VB 编程中如何使窗口右上角的关闭按钮(X)失效

1、Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As
Integer)
        Cancel = True
       End Sub
    2、Private Sub
Form_Unload(Cancel As Integer)
        Cancel = ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号