下面的 Form 裡面,只有一個 Label 及兩個 Button 元件而已:
Public Class Form1
Private Const CCDEVICENAME As Short = 32
Private Const CCFORMNAME As Short = 32
Private Const DM_PELSWIDTH As Integer = &H80000
Private Const DM_PELSHEIGHT As Integer = &H100000
'更新螢幕掃瞄頻率常數
Private Const DM_DISPLAYFREQUENCY As Integer = &H400000
'宣告要使用的 API 函式
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Integer, ByVal iModeNum As Integer, ByRef lpDevMode As DEVMODE) As Boolean
'宣告要使用的 API 函式
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (ByRef lpDevMode As DEVMODE, ByVal dwflags As Integer) As Integer