另一个例子,可以用下面给出这一小段代码检测当前屏幕分辨率,然后根据结果作出反应──例如,重新调整窗体大小以适应用程序户分辨率。 Public Function CheckRez(pixelWidth As Long, pixelHeight As Long) As Boolean Dim lngTwipsX As Long Dim lngTwipsY As Long 'convert pixels to twips lngTwipsX = pixelWidth * 15 lngTwipsY = pixelHeight * 15 'check against current settings If lngTwipsX <> Screen.Width Then CheckRez = False Else If lngTwipsY <> Screen.Height Then CheckRez = False Else CheckRez = True End If End If End Function 'Next, run the following code at the start of the program: If CheckRez(640, 480) = False Then MsgBox "Incorrect screen size!" Else MsgBox "Screen Resolution Matches!" End If
然后根据他们调整你的窗体。
你可在form_REsize事件中判断当前分辨率进行控制
Dim lngTwipsX As Long
Dim lngTwipsY As Long
'convert pixels to twips
lngTwipsX = pixelWidth * 15
lngTwipsY = pixelHeight * 15 'check against current settings
If lngTwipsX <> Screen.Width Then
CheckRez = False
Else
If lngTwipsY <> Screen.Height Then
CheckRez = False
Else
CheckRez = True
End If
End If
End Function 'Next, run the following code at the start of the program: If CheckRez(640, 480) = False Then
MsgBox "Incorrect screen size!"
Else
MsgBox "Screen Resolution Matches!"
End If
text1.width=me.width*0.5