Vb. NET set the screen resolution, color bit number, refresh rate Instance Code _ practical Skills

Source: Internet
Author: User
Copy Code code as follows:

Private Declare Function getdevicecaps Lib "GDI32" (ByVal hdc as Long, ByVal nindex as long) as long
Private Declare Function changedisplaysettings Lib "user32" Alias "Changedisplaysettingsa" (Lpdevmode as Any, ByVal Dwflag s as long) as long
Private Const ccdevicename as Long = 32
Private Const ccformname as Long = 32
Private Const Dm_bitsperpel as Long = &h40000
Private Const dm_pelswidth as Long = &h80000
Private Const dm_pelsheight as Long = &h100000
Private Const dm_displayflags as Long = &h200000
Private Const dm_displayfrequency = &h400000
Private Const Cds_force as Long = &h80000000
Private Const Bitspixel as Long = 12
Private Const horzres as Long = 8
Private Const vertres as Long = 10
Private Const VRefresh = 116
Private Type DEVMODE
Dmdevicename as String * ccdevicename
Dmspecversion as Integer
Dmdriverversion as Integer
Dmsize as Integer
Dmdriverextra as Integer
Dmfields as Long
Dmorientation as Integer
Dmpapersize as Integer
dmPaperLength as Integer
dmPaperWidth as Integer
Dmscale as Integer
Dmcopies as Integer
Dmdefaultsource as Integer
dmPrintQuality as Integer
Dmcolor as Integer
Dmduplex as Integer
Dmyresolution as Integer
Dmttoption as Integer
Dmcollate as Integer
dmFormName as String * ccformname
Dmunusedpadding as Integer
Dmbitsperpel as Integer
Dmpelswidth as Long
Dmpelsheight as Long
Dmdisplayflags as Long
Dmdisplayfrequency as Long
End Type
Private Sub Cmdchangedesktopmode_click ()
Dim DM as DEVMODE
With DM
. Dmpelswidth = CInt (Txtnewwidth.text)
. Dmpelsheight = CInt (Txtnewheight.text)
. Dmbitsperpel = CInt (Txtnewcolor.text)
. dmdisplayfrequency = CInt (Txtnewfreq.text)
. dmfields = Dm_pelswidth or Dm_pelsheight or Dm_bitsperpel or dm_displayfrequency
. dmsize = LenB (DM)
End With
If changedisplaysettings (DM, Cds_force) <> 0 Then
MsgBox "Error! This mode is not supported! "
End If
End Sub
Private Sub Form_Load ()
Txtoldwidth.text = GetDeviceCaps (ME.HDC, Horzres)
Txtoldheight.text = GetDeviceCaps (ME.HDC, Vertres)
Txtoldcolor.text = GetDeviceCaps (ME.HDC, Bitspixel)
Txtoldfreq.text = GetDeviceCaps (ME.HDC, VRefresh)
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.