小弟我想通过 API函数(GetWindowRect)获取小弟我的子窗体和窗体窗体的高度、宽度等,能不能给小弟我举个例子
我想通过 API函数(GetWindowRect)获取我的子窗体和窗体窗体的高度、宽度等,能不能给我举个例子
如题,请帮帮忙
------解决方案--------------------
如题,请帮帮忙
------解决方案--------------------
- VB code
Option Explicit Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function GetWindowRect Lib "user32.dll " (ByVal hwnd As Long, ByRef lpRect As RECT) As Long Private Sub Command1_Click() Dim lngP As Long Dim meRECT As RECT lngP = FindWindow(vbNullString, "子窗体的标题") If lngP <> 0 Then lngP = GetWindowRect(lngP, meRECT) Debug.Print "宽:" & (meRECT.Right - meRECT.Left) * 15 Debug.Print "高:" & (meRECT.Bottom - meRECT.Top) * 15 End Sub