»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
¼¼ÊõÎĵµ > VBÎĵµ > ϵͳ¿ØÖÆ
ÐÞ¸ÄÏÔʾÆ÷µÄË¢ÐÂƵÂÊ
·¢±íÈÕÆÚ£º2003-03-04 00:00:00×÷ÕߣºÕ ³ö´¦£º  

¡¡¡¡¶ÔÓÚWindowsƽ̨£¬ÏÔʾÆ÷µÄ·Ö±çÂʺÍÑÕÉ«ÊýºÜÖØÒª£¬ÓÈÆäÊǶÔÓÚ¶àýÌåÓ¦ÓÃÈí¼þºÍÓÎÏ·Èí¼þ¡£µ«Ðí¶àÇé¿öÏ£¬Óû§µ±Ç°µÄÆÁÄ»ÉèÖò¢²»ÊʺÏÈí¼þµÄÔËÐÐÐèÒª¡£Èí¼þͨ³£µÄ×ö·¨ÊÇÌáʾÓû§½«ÆÁÄ»ÉèÖõ½Èí¼þÒªÇóµÄ·Ö±çÂʼ°ÑÕÉ«Êý£¬ÔÙÖØÐÂÆô¶¯Èí¼þ¡£ÕâÑùÎÞÒÉ»áÔö¼ÓÆÕͨÓû§²Ù×÷Éϵĸºµ£ºÍÀ§ÄÑ£¬½µµÍÁËÈí¼þµÄÓѺÃÐÔºÍÒ×ÓÃÐÔ¡£

---- ÀíÏëµÄ×÷·¨ÊÇ£ºÔÚÈí¼þ¿ªÊ¼Ê±£¬¶¯Ì¬µÄ¸Ä±äÆÁÄ»ÉèÖÃÀ´´ïµ½Èí¼þÔËÐеÄÒªÇó¡£ÔÚÈí¼þÔËÐнáÊøºó£¬ÔÙ×Ô¶¯°ÑÆÁÄ»ÉèÖøĻØÔ­À´µÄÉèÖÃÖµ¡£ÕâÒ»Çйý³Ì¶¼ÔÚ²»Öª²»¾õÖÐÍê³É¡£ÕâÒ»×ö·¨¿ÉÒÔͨ¹ýÔÚVBÖе÷ÓÃAPI£¨Ó¦ÓóÌÐò½Ó¿Ú£©º¯Êý×öµ½¡£ÊµÏÖ·½·¨ÈçÏ£º

---- Ò»¡¢´ò¿ªÒ»¸ö±ê×¼µÄEXE¹¤³Ì¡£

---- ¶þ¡¢ÔÚ¡°¹¤³Ì¡±²Ëµ¥À¸Ï£¬Ñ¡È¡¡°Ìí¼ÓÄ£¿é¡±£¬Îª¹¤³ÌÌí¼ÓÒ»¸öÄ£¿é¡£

---- ²¢ÔÚÄ£¿éÖÐÌí¼ÓÈçÏ´úÂ룺

¡®---------------ÒÔÏ´úÂëÓÃÓڵõ½ÆÁÄ»µÄÉèÖòÎÊý--------------

Declare Function GetDeviceCaps Lib

"gdi32" (ByVal hdc As Long,

ByVal nIndex As Long) As Long

   ¡®È¡Ö¸¶¨É豸ÐÅÏ¢APIº¯Êý

Public Const HORZRES = 8

    ¡®Èý¸öÆÁÄ»³£Á¿

Public Const VHORZRES = 10

Public Const BITSPIXEL = 12

¡®---------------ͨ¹ý×Ö·ûCOPY½øÐÐÊý¾ÝÀàÐÍת»»--------------

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

 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 * CCHFORMNAME

 dmUnusedPadding As Integer

 dmBitsPerPel As Integer

 dmPelsWidth As Long

 dmPelsHeight As Long

 dmDisplayFlags As Long

 dmDisplayFrequency As Long

End Type

¡®------------------ÉèÖÃÆÁÄ»µÄºËÐÄAPI-----------------

Private Declare Function ChangeDisplaySettings

Lib "User32" Alias "ChangeDisplaySettingsA"

(ByVal lpDevMode As Long, ByVal dwflags As Long) As Long

¡®------------------ÉèÖÃÆÁÄ»µÄº¯Êý-----------------

Public Function SetDispMode(Width As Integer,

Height As Integer, Color As Integer) As Long

£¨SetDispModeÊÇ×Ô¼º¹¹ÔìµÄ¸ü¸ÄÆÁÄ»ÉèÖõĺ¯ÊýÀ´£¬

ËüµÄÈý¸ö²ÎÊýWidth¡¢HeightºÍColor·Ö±ðÊÇÆÁÄ»µÄºáÏò·Ö±æÂÊ¡¢

×ÝÏò·Ö±æÂÊ,ÑÕɫλÊý£¬ÆäÖµ¿ÉΪ24£¬16£¬0µÈ¡£0ΪԭÓÐÑÕÉ«ÉèÖᣣ©

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 = 0 Then 

  ¡®Èç¹ûColor=0ÔòÖ»¸Ä±äÆÁÄ»µÄ·Ö±æÂÊ£¬¶ø²»¸Ä±äÉ«²Ê¡£

  .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT

 Else  

     ¡®Èç¹ûColor²»µÈ0Ôò¸Ä±äÆÁÄ»µÄ·Ö±æÂʺÍÉ«²Ê¡£

  .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL

 End If

 .dmPelsWidth = Width 

 .dmPelsHeight = Height

 If Color < > 0 Then

 .dmBitsPerPel = Color

 End If

End With

 pDevmode = lstrcpy(NewDevMode, NewDevMode) 

¡®µÃµ½Ò»¸öÖ¸ÏòNewDevMode½á¹¹µÄLongÐ͵ÄÖ¸Õë¡£

 ChangeDisplaySettings pDevmode, 0

End Function

---- Èý¡¢ÔÚ¹¤³Ì´°ÌåÖУ¬¼ÓÈëÁ½¸ö°´Å¥Command1ºÍCommand2£¬ÆäCaptionÊôÐÔ·Ö±ðΪ¡°800x600x16¡±ºÍ¡°»Ö¸´Ô­ÉèÖᱡ£

---- Æä³ÌÐò´úÂëΪ£º

¡®´°¿ÚµÄ¡°Í¨ÓÃ|ÉùÃ÷¡±Çø

Option Explicit

Dim H, V, Color As Long 

  ¡¯ÉùÃû±äÁ¿£¬ÓÃÓÚ±£´æ×î³õÆÁÄ»ÉèÖÃ

Private Sub Form_Load()

¡®---------------ÒÔÏ´úÂëÓÃÓڵõ½×î³õµÄÆÁÄ»É豸--------------

 H = GetDeviceCaps(Form1.hdc, HORZRES)

 V = GetDeviceCaps(Form1.hdc, VHORZRES)

 Color = GetDeviceCaps(Form1.hdc, BITSPIXEL)

End Sub

Private Sub Command1_Click()

  ¡®µ÷ÓÃSetDispModeº¯Êý¸Ä±äÆÁÄ»ÉèÖÃ

  SetDispMode 800, 600, 16

End Sub

Private Sub Command2_Click()

  ¡®»Ö¸´×î³õÆÁÄ»ÉèÖÃ

 SetDispMode Cint(H), Cint(V), Cint(Color)

End Sub

---- ËÄ¡¢½«³ÌÐò±àÒëÖ´ÐС£

---- ±¾³ÌÐòÖ´Ðкó£¬Èç¹ûµ¥»÷Command1£¬ÔòÄúµÄ¼ÆËã»úÆÁÄ»ÏÔʾģʽ½«±»ÉèÖÃΪ¡°800x600x16¡±µÄÏÔʾģʽ£»Èç¹ûµ¥»÷Command2, ÔòÄúµÄ¼ÆËã»úÆÁÄ»ÏÔʾģʽ½«±»ÉèÖÃΪԭÀ´µÄÏÔʾģʽ¡£´Ë³ÌÐòÉÔ¼ÓÐ޸ģ¬¼´¿É·ÅÖÃÓÚ×ÀÃæ»òÈÎÎñÀ¸ÖУ¬Ö±½Ó¿ì½ÝµÄÐÞ¸ÄÆÁÄ»ÉèÖá£

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00478