首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么获取当前窗体在屏幕中的位置(坐标)

2012-01-10 
如何获取当前窗体在屏幕中的位置(坐标)如题,谢谢[解决办法]Public Declare Function GetWindowRect Libus

如何获取当前窗体在屏幕中的位置(坐标)
如题,谢谢

[解决办法]
Public Declare Function GetWindowRect Lib "user32 " Alias "GetWindowRect " (ByVal hwnd As Long, lpRect As RECT) As Long
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type

dim r as rect

GetWindowRect Me.hWnd , r

Debug.Print r.Left , r.Top
[解决办法]
Me.Left, Me.Top, Me.Width, Me.Height
如果要转换为 Pixel 单位分别除以 Screen.TwipsPerPixelX、Screen.TwipsPerPixelY
[解决办法]
窗体里加个定时器

然后:

Option Explicit

Private Sub Timer1_Timer()
Me.Caption = Me.Top \ 15 & ": " & Me.Left \ 15
End Sub

热点排行