动态改变屏幕设置
'-定义
PrivateDeclareFunctionlstrcpy_
Lib"kernel32"Alias"lstrcpyA"_
(lpString1AsAny,lpString2AsAny)_
AsLong
ConstCCHDEVICENAME=32
ConstCCHFORMNAME=32
PrivateTypeDEVMODE
dmDeviceNameAsString*CCHDEVICENAME
dmSpecVersionAsInteger
dmDriverVersionAsInteger
dmSizeAsInteger
dmDriverExtraAsInteger
dmFieldsAsLong
dmOrientationAsInteger
dmPaperSizeAsInteger
dmPaperLengthAsInteger
dmPaperWidthAsInteger
dmScaleAsInteger
dmCopiesAsInteger
dmDefaultSourceAsInteger
dmPrintQualityAsInteger
dmColorAsInteger
dmDuplexAsInteger
dmYResolutionAsInteger
dmTTOptionAsInteger
dmCollateAsInteger
dmFormNameAsString*CCHFORMNAME
dmUnusedPaddingAsInteger
dmBitsPerPelAsInteger
dmPelsWidthAsLong
dmPelsHeightAsLong
dmDisplayFlagsAsLong
dmDisplayFrequencyAsLong
EndType
PrivateDeclareFunction_
ChangeDisplaySettingsLib_
"User32"Alias"ChangeDisplaySettingsA"(_
ByVallpDevModeAsLong,_
ByValdwflagsAsLong)AsLong
'-函数
PublicFunctionSetDisplayMode(WidthAs_
Integer,HeightAsInteger,ColorAs_
Integer)AsLong
ConstDM_PELSWIDTH=&H80000
ConstDM_PELSHEIGHT=&H100000
ConstDM_BITSPERPEL=&H40000
DimNewDevModeAsDEVMODE
DimpDevmodeAsLong
WithNewDevMode
.dmSize=122
IfColor=-1Then
.dmFields=DM_PELSWIDTHOrDM_PELSHEIGHT
Else
.dmFields=DM_PELSWIDTHOr_
DM_PELSHEIGHTOrDM_BITSPERPEL
EndIf
.dmPelsWidth=Width
.dmPelsHeight=Height
IfColor<>-1Then
.dmBitsPerPel=Color
EndIf
EndWith
pDevmode=lstrcpy(NewDevMode,NewDevMode)
SetDisplayMode=ChangeDisplaySettings(pDevmode,0)
EndFunction
例子调用:改变为640x480x24位:
i=SetDisplayMode(640,480,24)
如果成功返回0
- 上一篇:桌面屏幕翻转
- 下一篇:在VisualBasic中终止Windows95