Vb. NET sets the screen resolution, the color bit number, the refresh rate instance code

Source: Internet
Author: User
This article describes the vb.net set screen resolution, color number, refresh rate instance code, a friend in need can refer to the 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 dwflags 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.