動態改變螢幕設定 解析度、顏色等。 (轉)
動態改變螢幕設定 解析度、顏色等。 (轉)[@more@]動態改變螢幕設定
'- 定義
Private Declare Function lstrcpy _
Lib "kernel32" Alias "lstrcpyA" _
(lpString1 As Any, lpString2 As Any) _
As Long
Const CCHDEVICENAME = 32
Const CCHFORMNAME = 32
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefault As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Declare Function _
ChangeDisplaySettings Lib _
"User32" Alias "ChangeDisplaySettingsA" (_
ByVal lpDevMode As Long, _
ByVal dwflags As Long) As Long
'-
Public Function SetDisplayMode(Width As _
Integer,Height As Integer, Color As _
Integer) As Long
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const DM_BITSPERPEL = &H40000
Dim NewDevMode As DEVMODE
Dim pDevmode As Long
With NewDevMode
.dmSize = 122
If Color = -1 Then
.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
Else
.dmFields = DM_PELSWIDTH Or _
DM_PELSHEIGHT Or DM_BITSPERPEL
End If
.dmPelsWidth = Width
.dmPelsHeight = Height
If Color <> -1 Then
.dmBitsPerPel = Color
End If
End With
pDevmode = lstrcpy(NewDevMode, NewDevMode)
SetDisplayMode = ChangeDisplaySettings(pDevmode, 0)
End Function
例子:改變為 640x480x24位:
i = SetDisplayMode(640, 480, 24)
如果成功返回 0 。
'- 定義
Private Declare Function lstrcpy _
Lib "kernel32" Alias "lstrcpyA" _
(lpString1 As Any, lpString2 As Any) _
As Long
Const CCHDEVICENAME = 32
Const CCHFORMNAME = 32
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefault As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Declare Function _
ChangeDisplaySettings Lib _
"User32" Alias "ChangeDisplaySettingsA" (_
ByVal lpDevMode As Long, _
ByVal dwflags As Long) As Long
'-
Public Function SetDisplayMode(Width As _
Integer,Height As Integer, Color As _
Integer) As Long
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const DM_BITSPERPEL = &H40000
Dim NewDevMode As DEVMODE
Dim pDevmode As Long
With NewDevMode
.dmSize = 122
If Color = -1 Then
.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
Else
.dmFields = DM_PELSWIDTH Or _
DM_PELSHEIGHT Or DM_BITSPERPEL
End If
.dmPelsWidth = Width
.dmPelsHeight = Height
If Color <> -1 Then
.dmBitsPerPel = Color
End If
End With
pDevmode = lstrcpy(NewDevMode, NewDevMode)
SetDisplayMode = ChangeDisplaySettings(pDevmode, 0)
End Function
例子:改變為 640x480x24位:
i = SetDisplayMode(640, 480, 24)
如果成功返回 0 。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-987917/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- CentOS7.0怎麼設定螢幕解析度?CentOS7.0設定螢幕解析度教程CentOS
- Flutter改變狀態列字型、狀態列背景顏色、Appbar背景顏色的方式FlutterAPP
- 設定div高度等於螢幕高度
- Android開發——Java程式碼動態改變顏色字型的方法AndroidJava
- 設定grub配置檔案中的螢幕解析度
- 改變SVG圖的顏色SVG
- 圖示任意改變顏色
- CardView改變陰影顏色View
- win10怎麼改變工作列顏色 w10系統如何設定工作列顏色Win10
- 在LCD螢幕上漸變顯示sRGB所有範圍顏色, 最大可漸變16,581,375種顏色
- Android 圓形ProgressBar 改變顏色Android
- 滑鼠移動到button顏色改變的實現
- AUTOCAD——設定顏色
- 如何改變你的終端顏色
- JS 操作 DOM 改變方塊顏色JS
- web前端 改變SVG圖的顏色Web前端SVG
- linux改變shell的輸出顏色Linux
- 設定toast的字型顏色和背景顏色AST
- 直播平臺軟體開發,Uniapp動態設定元件顏色APP元件
- JavaScript WebGL 設定顏色JavaScriptWeb
- CAD如何設定顏色
- 螢幕解析度修改SwitchResX
- win10電腦螢幕顏色不正常怎麼調 win10電腦螢幕顏色發黃怎麼處理Win10
- win10 工作列顏色怎麼改_win10怎麼設定工作列顏色Win10
- win10顏色變得很奇怪怎麼恢復 win10電腦螢幕顏色調回正常操作方法Win10
- pycharm改變語法錯誤的顏色PyCharm
- 使用 Promise 迴圈改變 div 背景顏色Promise
- Windows10系統如何修改開始螢幕顏色Windows
- win10怎麼自定義解析度_win10怎麼設定螢幕解析度Win10
- win10螢幕顏色不正常怎麼調_安裝win10後螢幕顏色顯示不正常如何解決Win10
- 直播系統搭建,設定透明背景(去掉蒙層)狀態列顏色不改變
- 1909win10怎麼設定工作列顏色_1909win10工作列顏色如何改Win10
- win10電腦螢幕的顏色不正是怎麼了_升級win10系統後螢幕顏色不正如何解決Win10
- 我的SCRT顏色設定
- react native拖動上方顯示值,改變背景顏色的sliderReact NativeIDE
- 純css改變輸入框游標顏色CSS
- NGUI和UGUI改變字型顏色的寫法NGUIUGUI
- 線上直播系統原始碼,iOS 根據滑動距離改變狀態列顏色原始碼iOS
- 如何在 Mac 上更改資料夾顏色,改變 mac 資料夾顏色教程Mac