' ManyThng.BAS -- This is my attempt at a variable screen saver
' It is based on an example in "Learn Programming and Visual Basic 2.0"
' by John Socha and Sybex Inc., (highly recommended)
' first written 4-15-93 Bruce McLean
'
Option Explicit
'
' These variables support saving the maximum number of lines
' in the CONTROL.INI file, which is where the Windows 3.1
' screen savers save setup information.
'
Global MaxLines As Integer ' Lines to show before CLS
Global RepeatCount As Integer ' # of lines the same color
Global MaxChangeMinutes As Single ' minutes to go before changing color
Global MaxCums As Integer ' total number of lines before clearing screen
Global BitmapsDir As String ' place to look for bitmaps
Global CycleBitmapsDir As String ' place to look for bitmaps for palette cycling
Global BmpSeconds As Integer ' seconds between bitmaps on slide show
Global RandomFlag As Integer ' non-zero means pick saver at random, else go in sequence
Global StartSaver As Integer ' zero means pick 1st saver at random, else start with saver the corresponds to value
Global ErrorTrace As Integer ' flag to log data for error tracing
Global LowMemoryFlag As Integer 'set this to run special low memory mode
Global TestMode As Integer 'this mode is for debugging code
Global Passwd As String 'where master password is stored
Global Const Scramble = "soDSM" 'to scramble password
Global PasswdScram As String 'scrambled password
Global TotalNumColors As Long 'place to store number of colors display can handle
Global PaletteHandle As Integer
Global FastPaletteCycleFlag As Integer
Global Const iniName = "CONTROL.INI"
Global Const secName = "Screen Saver.Many Things"
Global Const keyName = "MaxLines"
Global Const RepeatName = "RepeatCount"
Global Const ChangeMinutesName = "MaxChangeMinutes"
Global Const MaxCumsName = "MaxCumLines"
Global Const BmpsDirName = "BitmapsDir"
Global Const CycleBmpsDirName = "CycleBitmapsDir"
Global Const BmpSecondsName = "BmpSeconds"
Global Const RandomFlagName = "RandomFlag"
Global Const LowMemoryFlagName = "LowMemoryFlag"
Global Const StartSaverName = "StartSaver"
Global Const ErrorTraceName = "ErrorTrace"
Global Const PasswordName = "Password"
Global Const PriorityBaseName = "Priority"
Global Const FastPaletteCycleName = "FastPaletteCycle"
Global Const NUMCHARS = 25
' windows defines
Type RECT
left As Integer
top As Integer
right As Integer
bottom As Integer
End Type
'Polygon routine that draws any arbitray polygon using fill, etc.
Type POINTAPI
X As Integer
Y As Integer
End Type
' paint type
Type PAINTSTRUCT '32 Bytes
hDC As Integer
fErase As Integer
rcPaint As RECT
fRestore As Integer
fIncUpdate As Integer
rgbReserved As String * 16
End Type
Global Const PALENTRIES = 256
' This is similar to the LOGPALLETTE defined in
' APIDECS.BAS, however instead of using a buffer, we
' create a 64 entry palette for our use.
Type PALETTEENTRY '4 Bytes
peRed As String * 1
peGreen As String * 1
peBlue As String * 1
peFlags As String * 1
End Type
Type LOGPALETTE
palVersion As Integer
palNumEntries As Integer
palPalEntry(PALENTRIES) As PALETTEENTRY
End Type
Global Pal As LOGPALETTE
'Many things DLL routines used:
Declare Function ManyDibAlloc Lib "mnythdll.dll" (ByVal Wdth As Integer, ByVal Hght As Integer) As Long
Declare Function ManyDibFree Lib "mnythdll.dll" () As Integer
Declare Function ManyDibGet Lib "mnythdll.dll" () As Long
Declare Function ManyDibGetData Lib "mnythdll.dll" () As Long
Declare Function ManyDibLoad Lib "mnythdll.dll" (ByVal FileName As String, Wdth As Integer, Hght As Integer) As Long
Declare Function ManyGifLoad Lib "mnythdll.dll" (ByVal FileName As String, Wdth As Integer, Hght As Integer) As Long
Declare Function ManyDibInit Lib "mnythdll.dll" () As Long
Declare Sub ManyDibModPalette Lib "mnythdll.dll" (ByVal red As Integer, ByVal green As Integer, ByVal blue As Integer)
Declare Sub ManyDibCyclePalette Lib "mnythdll.dll" (ByVal StepSize As Integer, ByVal LowValue As Integer, ByVal HighValue As Integer)
Declare Sub ManyLoadLogPal Lib "mnythdll.dll" (Pal As LOGPALETTE, ByVal Start As Integer, ByVal size As Integer, ByVal Flags As Integer)
Declare Function ManyDIBWrite Lib "mnythdll.dll" (ByVal FileName As String) As Integer
' Windows API Routines used:
Declare Function ShowCursor Lib "USER" (ByVal fShow As Integer) As Integer
Declare Sub BitBlt Lib "GDI" (ByVal DestDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal BWidth As Integer, ByVal BHeight As Integer, ByVal SourceDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal Constant As Long)
Declare Function StretchBlt Lib "GDI" (ByVal hDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal XSrc As Integer, ByVal YSrc As Integer, ByVal nSrcWidth As Integer, ByVal nSrcHeight As Integer, ByVal dwRop As Long) As Integer
Declare Function CopyRect Lib "User" (lpDestRect As RECT, lpSourceRect As RECT) As Integer
Declare Function CreateDC Lib "GDI" (ByVal Driver As Any, ByVal Dev As Any, ByVal O As Any, ByVal Init As Any) As Integer
Declare Sub DrawIcon Lib "User" (ByVal hDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal hIcon As Integer)
Declare Function GetCursor Lib "User" () As Integer
Declare Sub GetCursorPos Lib "User" (lpPNT As Integer)
Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, ByVal nIndex As Integer) As Integer
Declare Function LockResource Lib "Kernel" (ByVal hRes As Integer) As Long
Declare Sub UnlockResource Lib "Kernel" Alias "GlobalUnlock" (ByVal hRes As Integer)
Declare Sub FloodFill Lib "GDI" (ByVal hDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal color As Long)
Declare Function Polygon Lib "GDI" (ByVal hDC As Integer, lpPoints As POINTAPI, ByVal nCount As Integer) As Integer
Declare Function SetPolyFillMode Lib "GDI" (ByVal hDC As Integer, ByVal nPolyFillMode As Integer) As Integer
Declare Function GetNearestColor Lib "GDI" (ByVal hDC As Integer, ByVal crColor As Long) As Long
Declare Function GetDeviceCaps Lib "GDI" (ByVal hDC As Integer, ByVal nIndex As Integer) As Integer
Declare Function SetSysModalWindow Lib "User" (ByVal hWnd As Integer) As Integer
Declare Function SystemParametersInfo Lib "User" (ByVal uAction%, ByVal uParam%, lpvParam As Any, ByVal fuWinIni%) As Integer
Declare Function SelectObject Lib "GDI" (ByVal hDC%, ByVal hObject%) As Integer
Declare Function CreateCompatibleDC Lib "GDI" (ByVal hDC%) As Integer
Declare Function DeleteDC Lib "GDI" (ByVal hDC%) As Integer
Declare Function RealizePalette% Lib "User" (ByVal hDC%)
Declare Function DeleteObject% Lib "GDI" (ByVal hObject%)
Declare Function SetSystemPaletteUse% Lib "GDI" (ByVal hDC%, ByVal wUsage%)
Declare Function GetFreeSystemResources% Lib "User" (ByVal fuSysResource%)
Declare Function GetFreeSpace& Lib "Kernel" (ByVal wFlags%)
Declare Function SetPaletteEntries% Lib "GDI" (ByVal hPalette%, ByVal wStartIndex%, ByVal wNumEntries%, lpPaletteEntries As PALETTEENTRY)
Declare Sub GetKeyboardStateBystring Lib "User" Alias "GetKeyboardState" (ByVal lpKeyState$)
Declare Function ToAsciiBystring Lib "Keyboard" Alias "ToAscii" (ByVal wVirtKey%, ByVal wScanCode%, ByVal lpKeyState$, lpChar&, ByVal wFlags%) As Integer
Declare Function MapVirtualKey Lib "Keyboard" (ByVal wCode%, ByVal wMapType%) As Integer
Declare Function VkKeyScan Lib "Keyboard" (ByVal cChar%) As Integer
'routines for reading profile data in 'CONTROL.INI'
Declare Function GetPrivateProfileInt Lib "KERNEL" (ByVal lpszSectionName As String, ByVal lpszKeyName As String, ByVal nDefault As Integer, ByVal lpszFileName As String) As Integer
Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "KERNEL" (ByVal lpszSectionName As String, ByVal lpszKeyName As String, ByVal nString As String, ByVal lpszFileName As String) As Integer
' variables and constants to be used for screen capture
Global ScrnWidth As Integer, ScrnHeight As Integer
Dim RECT(3) As Integer
Global Const PI = 3.141592654
'Device Parameters for GetDeviceCaps()
Global Const DRIVERVERSION = 0 ' Device driver version
Global Const TECHNOLOGY = 2 ' Device classification
Global Const HORZSIZE = 4 ' Horizontal size in millimeters
Global Const VERTSIZE = 6 ' Vertical size in millimeters
Global Const HORZRES = 8 ' Horizontal width in pixels
Global Const VERTRES = 10 ' Vertical width in pixels
Global Const BITSPIXEL = 12 ' Number of bits per pixel
Global Const PLANES = 14 ' Number of planes
Global Const NUMBRUSHES = 16 ' Number of brushes the device has
Global Const NUMPENS = 18 ' Number of pens the device has
Global Const NUMMARKERS = 20 ' Number of markers the device has
Global Const NUMFONTS = 22 ' Number of fonts the device has
Global Const NumColors = 24 ' Number of colors the device supports
Global Const PDEVICESIZE = 26 ' Size required for device descriptor
Global Const CURVECAPS = 28 ' Curve capabilities
Global Const LINECAPS = 30 ' Line capabilities
Global Const POLYGONALCAPS = 32 ' Polygonal capabilities
Global Const TEXTCAPS = 34 ' Text capabilities
Global Const CLIPCAPS = 36 ' Clipping capabilities
Global Const RASTERCAPS = 38 ' Bitblt capabilities
Global Const ASPECTX = 40 ' Length of the X leg
Global Const ASPECTY = 42 ' Length of the Y leg
Global Const ASPECTXY = 44 ' Length of the hypotenuse
Global Const LOGPIXELSX = 88 ' Logical pixels/inch in X
Global Const LOGPIXELSY = 90 ' Logical pixels/inch in Y
Global Const SIZEPALETTE = 104 ' Number of entries in physical palette
Global Const NUMRESERVED = 106 ' Number of reserved entries in palette
Global Const COLORRES = 108 ' Actual color resolution
Global Const SPI_SETSCREENSAVEACTIVE = 17
Global Const PC_RESERVED = &H1
Global Const PC_EXPLICIT = &H2
Global Const PC_NOCOLLAPSE = &H4
Global Const DIB_RGB_COLORS = 0
Global Const DIB_PAL_COLORS = 1
Global Const SYSPAL_STATIC = 1
Global Const SYSPAL_NOSTATIC = 2
Global Const CF_TEXT = 1
Global Const CF_BITMAP = 2
Global Const CF_METAFILEPICT = 3
Global Const CF_SYLK = 4
Global Const CF_DIF = 5
Global Const CF_TIFF = 6
Global Const CF_OEMTEXT = 7
Global Const CF_DIB = 8
Global Const CF_PALETTE = 9
Global Const CF_OWNERDISPLAY = &H80
Global Const CF_DSPTEXT = &H81
Global Const CF_DSPBITMAP = &H82
Global Const CF_DSPMETAFILEPICT = &H83
Global Const CF_PRIVATEFIRST = &H200
Global Const CF_PRIVATELAST = &H2FF
' This is a message used within Visual Basic to retrieve