*NAME: ScreenResolution() * PROCEDURE ScreenResolution * *-- The parameter is the width of the screen in pixels. LPARAMETERS tnResolution, tlSetMark * *-- Use second parameter only to check and set the mark *-- in the menu (if you have a menu bar). * *-- We use the following two libraries: One to *-- get the available display settings, the other *-- to change the setting. If the change fails, *-- it will just not take the change into effect. * Declare Integer EnumDisplaySettings in Win32API ; String lpszDeviceName, ; Integer iModeNum, ; String @lpDevMode * Declare Integer ChangeDisplaySettings in Win32API ; String @lpDevMode, ; Integer dwflags * *-- Two class libraries, from *-- http://www.foxite.com/downloads/default.aspx?id=&keyword=struct&category= * *-- (Download Struct.VCX and WinStruct.VCX.) Set ClassLib to Struct, WinStruct Additive loStruct = NEWOBJECT("DevMode") * *-- First create the structure using the current *-- display setting. Local lcDMCurrent loStruct.dmSize = loStruct.SizeOf() loStruct.dmDriverExtra = 0 lcDMCurrent = loStruct.GetString() EnumDisplaySettings( NULL, -1, @lcDMCurrent) loStruct.SetString( m.lcDMCurrent) lnCurrentWidth = loStruct.dmPelsWidth * IF tlSetMark = .T. *-- (Remove this code if you don't use a menu bar). SET MARK OF BAR 1 OF ScreenResolution TO .F. SET MARK OF BAR 2 OF ScreenResolution TO .F. SET MARK OF BAR 3 OF ScreenResolution TO .F. SET MARK OF BAR 4 OF ScreenResolution TO .F. SET MARK OF BAR 5 OF ScreenResolution TO .F. * *-- Set the mark. DO CASE CASE lnCurrentWidth = 800 SET MARK OF BAR 1 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1024 SET MARK OF BAR 2 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1280 SET MARK OF BAR 3 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1400 SET MARK OF BAR 4 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1600 SET MARK OF BAR 5 OF ScreenResolution TO .T. ENDCASE RETURN .T. ENDIF * *-- Now search in the available settings for the one *-- that we wanted to set. We find the match by comparing *-- the display width in pixels with the parameter. Local lnMode, lcDevMode, lnOK, lnLastColor lnMode = 0 lcDevMode = loStruct.GetString() lnLastColor = 0 Do While .T. m.lnOK = EnumDisplaySettings( NULL, m.lnMode, @lcDevMode ) loStruct.SetString( m.lcDevMode) IF loStruct.dmPelsWidth = tnResolution AND ; loStruct.dmBitsPerPel = 32 lcDMCurrent = loStruct.GetString() ENDIF * If m.lnOK == 0 *-- That means we had the last available one. Exit Endif * *-- Check the next higher one. lnMode = m.lnMode + 1 Enddo * loStruct.SetString( m.lcDMCurrent) #DEFINE DM_BITSPERPEL 0x00040000 #DEFINE DM_PELSWIDTH 0x00080000 #DEFINE DM_PELSHEIGHT 0x00100000 loStruct.dmFields = DM_BITSPERPEL + DM_PELSWIDTH + DM_PELSHEIGHT lcDMCurrent = loStruct.GetString() IF ChangeDisplaySettings( @lcDMCurrent, 0 ) = 0 * *-- Now set the mark. *-- (Remove this code if you don't use a menu bar). lnCurrentWidth = tnResolution * SET MARK OF BAR 1 OF ScreenResolution TO .F. SET MARK OF BAR 2 OF ScreenResolution TO .F. SET MARK OF BAR 3 OF ScreenResolution TO .F. SET MARK OF BAR 4 OF ScreenResolution TO .F. SET MARK OF BAR 5 OF ScreenResolution TO .F. DO CASE CASE lnCurrentWidth = 800 SET MARK OF BAR 1 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1024 SET MARK OF BAR 2 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1280 SET MARK OF BAR 3 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1400 SET MARK OF BAR 4 OF ScreenResolution TO .T. CASE lnCurrentWidth = 1600 SET MARK OF BAR 5 OF ScreenResolution TO .T. ENDCASE ENDIF * RETURN .T. * * *>Is there a way of knowing what the user ‘s monitor is set on with regards to screen size?