Guidance
指路人
g.yi.org
software / rapidq / Examples / Devices / Display / changeresolution.inc

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
'Converted for use in RapidQ by Christian Schwarzer
'
'Changeresolution.inc
'(c) 2002-2003 by C.Schwarzer
' www.delphsoft.de
' example: changeresolution(800,600,16)

     CONST Null = CHR$(0)
     CONST EWX_LOGOFF = 0
     CONST EWX_SHUTDOWN = 1
     CONST EWX_REBOOT = 2
     CONST EWX_FORCE = 4
     CONST CCDEVICENAME = 32
     CONST CCFORMNAME = 32
     CONST DM_BITSPERPEL = &H40000
     CONST DM_PELSWIDTH = &H80000
     CONST DM_PELSHEIGHT = &H100000
     CONST CDS_UPDATEREGISTRY = &H1
     CONST CDS_TEST = &H4
     CONST DISP_CHANGE_SUCCESSFUL = 0
     CONST DISP_CHANGE_RESTART = 1
     CONST BITSPIXEL = 12

     CONST ENUM_CURRENT_SETTINGS = -1
     CONST ENUM_REGISTRY_SETTINGS = -2

     TYPE DEVMODE
      dmDeviceName AS STRING * CCDEVICENAME
      dmSpecVersion AS WORD
      dmDriverVersion AS WORD
      dmSize AS WORD
      dmDriverExtra AS WORD
      dmFields AS DWORD
      dmOrientation AS SHORT
      dmPaperSize AS SHORT
      dmPaperLength AS SHORT
      dmPaperWidth AS SHORT
      dmScale AS SHORT
      dmCopies AS SHORT
      dmDefaultSource AS SHORT
      dmPrintQuality AS SHORT
      dmColor AS SHORT
      dmDuplex AS SHORT
      dmYResolution AS SHORT
      dmTTOption AS SHORT
      dmCollate AS SHORT
      dmFormName AS STRING * CCFORMNAME
      dmLogPixels AS WORD
      dmBitsPerPel AS WORD
      dmPelsWidth AS DWORD
      dmPelsHeight AS DWORD
      dmDisplayFlags AS DWORD
      dmDisplayFrequency AS DWORD
     END TYPE
     DECLARE FUNCTION EnumDisplaySettings LIB "user32" ALIAS "EnumDisplaySettingsA" (byref DeviceName AS STRING, BYVAL iModeNum AS DWORD, byref DevMo AS DevMode) AS LONG
     DECLARE FUNCTION ChangeDisplaySettings LIB "user32" ALIAS "ChangeDisplaySettingsA" (DevMo AS DevMode, BYVAL dwFlags AS LONG) AS LONG
     DECLARE FUNCTION ExitWindowsEx LIB "user32" ALIAS "ExitWindowsEx" (BYVAL uFlags AS LONG, BYVAL dwReserved AS LONG) AS LONG
     DECLARE FUNCTION CreateDC LIB "gdi32" ALIAS "CreateDCA" (ByRef lpDriverName AS STRING, ByRef lpDeviceName AS STRING, ByRef lpOutput  AS STRING, BYVAL lpInitData AS LONG) AS LONG
     DECLARE FUNCTION DeleteDC LIB "gdi32" ALIAS "DeleteDC" (BYVAL hdc AS LONG) AS LONG
     DECLARE FUNCTION GetDC LIB "user32.dll" ALIAS "GetDC"(BYVAL hwnd AS LONG) AS LONG
     DECLARE FUNCTION GetDesktopWindow LIB "user32.dll" ALIAS "GetDesktopWindow"() AS LONG
     DECLARE FUNCTION GetDeviceCaps LIB "gdi32.dll" ALIAS "GetDeviceCaps"(BYVAL hdc AS LONG, BYVAL nIndex AS LONG) AS LONG
     DECLARE FUNCTION ReleaseDC LIB "user32.dll" ALIAS "ReleaseDC"(BYVAL hwnd AS LONG, BYVAL hdc AS LONG) AS LONG
     DECLARE FUNCTION ShellExecute LIB "shell32.dll" ALIAS "ShellExecuteA" (BYVAL hwnd AS LONG, BYVAL lpOperation AS STRING, BYVAL lpFile AS STRING, BYVAL lpParameters AS STRING, BYVAL lpDirectory AS STRING, BYVAL nShowCmd AS LONG) AS LONG

     DECLARE SUB ChangeResolution(X AS DWORD, Y AS DWORD, Bits AS WORD)


     SUB ChangeResolution(X AS DWORD, Y AS DWORD, Bits AS WORD)
      DIM reponse AS INTEGER
      DIM DevM AS DEVMODE
      DIM DeviceName AS STRING
      DIM iModeNum AS DWORD
      DIM erg AS LONG
      DIM an AS LONG
      DeviceName = ""
      iModeNum = ENUM_CURRENT_SETTINGS

      erg = EnumDisplaySettings(DeviceName, iModeNum, DevM)


      DevM.dmFields = DM_PELSWIDTH OR DM_PELSHEIGHT OR DM_BITSPERPEL
      DevM.dmPelsWidth = X * &H10000
      DevM.dmPelsHeight = Y * &H10000
      DevM.dmBitsPerPel = Bits

      erg = ChangeDisplaySettings(DevM, CDS_TEST)
      SELECT CASE erg
      CASE DISP_CHANGE_SUCCESSFUL
       erg = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
      CASE ELSE
       MESSAGEBOX("Mode not supported", "Error", 0)
      END SELECT
     END SUB
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2019-4-26  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-09-19 07:24:24