VB窗体初始最大化和改变窗体大小自动缩放控件及字体

2025-11-11 03:39:49 | BOSS追踪

1、模块代码:

'标准模块声明写入(自定义类型) Type cp wp As Single hp As Single tp As Single lp As Single fp As Single End Type

Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long '屏幕尺寸 Private Declare Function GetSystemMetrics32 Lib "user32" _ Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

Public ap() As cp '定义窗体数组

'屏幕宽 Function ScreenWidth() As Long ScreenWidth = GetSystemMetrics32(0) * 15 End Function '屏幕高,去除底部状态栏高度 Function ScreenHeight() As Long ScreenHeight = (GetSystemMetrics32(1) - 40) * 15 End Function

Public Function MyGetWinDirectory() As String Dim sBuffer As String Dim lSize As Long sBuffer = String(255, 0) lSize