你可以在程序启动的时候获取屏幕的分辨率 照此作出相应的调整. 试一下下面的代码,可以取得屏幕的分辨率 可以查阅MSDN来察看更国关于GetDeviceCaps函数的信息Private Declare Function GetDeviceCaps Lib "gdi32" _ (ByVal hdc As Long, _ ByVal nIndex As Long) As LongPrivate Const HORZRES As Long = 8 Private Const VERTRES As Long = 10 Private Const BITSPIXEL As Long = 12 Private Const VREFRESH As Long = 116 Private Sub Command1_Click() Dim currHRes As Long Dim currVRes As Long Dim currBPP As Long Dim currVFreq As Long Dim sBPPtype As String Dim sFreqtype As String
'get the system settings currHRes = GetDeviceCaps(hdc, HORZRES) currVRes = GetDeviceCaps(hdc, VERTRES) currBPP = GetDeviceCaps(hdc, BITSPIXEL) currVFreq = GetDeviceCaps(hdc, VREFRESH)
'pretty up the descriptions a tad Select Case currBPP Case 4: sBPPtype = "(16 Color)" Case 8: sBPPtype = "(256 Color)" Case 16: sBPPtype = "(High Color)" Case 24, 32: sBPPtype = "(True Color)" End Select
Select Case currVFreq Case 0, 1: sFreqtype = "(Hardware default)" Case Else: sFreqtype = "(User-selected)" End Select
照此作出相应的调整.
试一下下面的代码,可以取得屏幕的分辨率
可以查阅MSDN来察看更国关于GetDeviceCaps函数的信息Private Declare Function GetDeviceCaps Lib "gdi32" _
(ByVal hdc As Long, _
ByVal nIndex As Long) As LongPrivate Const HORZRES As Long = 8
Private Const VERTRES As Long = 10
Private Const BITSPIXEL As Long = 12
Private Const VREFRESH As Long = 116
Private Sub Command1_Click() Dim currHRes As Long
Dim currVRes As Long
Dim currBPP As Long
Dim currVFreq As Long
Dim sBPPtype As String
Dim sFreqtype As String
'get the system settings
currHRes = GetDeviceCaps(hdc, HORZRES)
currVRes = GetDeviceCaps(hdc, VERTRES)
currBPP = GetDeviceCaps(hdc, BITSPIXEL)
currVFreq = GetDeviceCaps(hdc, VREFRESH)
'pretty up the descriptions a tad
Select Case currBPP
Case 4: sBPPtype = "(16 Color)"
Case 8: sBPPtype = "(256 Color)"
Case 16: sBPPtype = "(High Color)"
Case 24, 32: sBPPtype = "(True Color)"
End Select
Select Case currVFreq
Case 0, 1: sFreqtype = "(Hardware default)"
Case Else: sFreqtype = "(User-selected)"
End Select
Label2 = currHRes & " pixels"
Label3 = currVRes & " pixels"
Label4 = currBPP & " bits per pixel " & sBPPtype
Label5 = currVFreq & " hz " & sFreqtype
End Sub
在这个案例中为什么要那样复杂呢?又不是OpenGL绘图.
Resize OCX可以不用编写程序,控制一个Form中Resize时的Controls改变成对应的大小。在国外某VB 3RD的销售榜一直雄居NO.10左右。使用时只要把Resize Control放到Form就可以了。运行是试试改变Form的大小,就....看到啦:)
form.move (screen.width - form.width) \ 2, (screen.height - form.height)\2