Excel VBA Form Resize

Liên hệ QC

hai2hai

VNUNi®
Thành viên danh dự
Tham gia
14/6/06
Bài viết
1,137
Được thích
2,297
Nghề nghiệp
Tư vấn giải pháp bán lẻ
Allows you to resize Excel VBA UserForms automatically for the screen resolution of your users.

Public Const LOGPIXELSY = 90 'Logical pixels/inch in Y
Public Const POINTSPERLOG = 72& 'points per logical inch
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex&) As Long

Public Sub MonitorInfo()
ScrWidth = PixelsToPoints(GetSystemMetrics32(0)) '< in pixels
ScrHeight = PixelsToPoints(GetSystemMetrics32(1))
End Sub

Public Function PixelsToPoints(ByVal lfHeightPix As Long) As Single
Dim DC As Long
DC = GetDC(0)
PixelsToPoints = Abs((lfHeightPix * POINTSPERLOG) / GetDeviceCaps(DC, LOGPIXELSY))
ReleaseDC 0, DC
End Function
 

File đính kèm

  • Excel VBA Form Resize.zip
    21.1 KB · Đọc: 295
Web KT
Back
Top Bottom