home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / scrnsave / scrmbler.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  6.6 KB  |  175 lines

  1. VERSION 2.00
  2. Begin Form SCRMBLER 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Screen Scrambler Settings"
  5.    ClientHeight    =   3375
  6.    ClientLeft      =   2580
  7.    ClientTop       =   1065
  8.    ClientWidth     =   4095
  9.    Height          =   3780
  10.    Icon            =   SCRMBLER.FRX:0000
  11.    Left            =   2520
  12.    LinkTopic       =   "ScreenScramble"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3375
  16.    ScaleWidth      =   4095
  17.    Top             =   720
  18.    Width           =   4215
  19.    Begin CommandButton Cancel 
  20.       Cancel          =   -1  'True
  21.       Caption         =   "Cancel"
  22.       Height          =   375
  23.       Left            =   2160
  24.       TabIndex        =   7
  25.       Top             =   2880
  26.       Width           =   1695
  27.    End
  28.    Begin CommandButton OK 
  29.       Caption         =   "OK"
  30.       Default         =   -1  'True
  31.       Height          =   375
  32.       Left            =   240
  33.       TabIndex        =   6
  34.       Top             =   2880
  35.       Width           =   1695
  36.    End
  37.    Begin CommandButton Test 
  38.       Caption         =   "&Test"
  39.       Height          =   375
  40.       Left            =   2280
  41.       TabIndex        =   5
  42.       Top             =   2400
  43.       Width           =   1455
  44.    End
  45.    Begin CommandButton Setting 
  46.       Caption         =   "&Settings..."
  47.       Height          =   375
  48.       Left            =   360
  49.       TabIndex        =   4
  50.       Top             =   2400
  51.       Width           =   1455
  52.    End
  53.    Begin CommandButton Delete 
  54.       Caption         =   "&Delete"
  55.       Height          =   375
  56.       Left            =   1680
  57.       TabIndex        =   3
  58.       Top             =   1320
  59.       Width           =   735
  60.    End
  61.    Begin CommandButton Add 
  62.       Caption         =   "&Add "
  63.       Height          =   375
  64.       Left            =   1680
  65.       TabIndex        =   2
  66.       Top             =   720
  67.       Width           =   735
  68.    End
  69.    Begin FileListBox SCR_files 
  70.       Height          =   2175
  71.       Left            =   120
  72.       Pattern         =   "*.SCR"
  73.       TabIndex        =   1
  74.       Top             =   120
  75.       Width           =   1455
  76.    End
  77.    Begin ListBox SCRtoUSE 
  78.       Height          =   2175
  79.       Left            =   2520
  80.       TabIndex        =   0
  81.       Top             =   120
  82.       Width           =   1455
  83.    End
  84. 'Get Windows Directory API call. Used to Get path for file list box.
  85. Declare Function GetWindowsDirectory Lib "Kernel" (ByVal lpBuffer As String, ByVal nSize As Integer) As Integer
  86. 'Windows API to see if program has terminated.
  87. Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)
  88. Sub Add_Click ()
  89. If SCR_Files.FileName = "SCRMBLER.SCR" Or SCR_Files.FileName = "" Then Exit Sub'If selected screen saver is this one, or none, cancel procedure.
  90. If SCRtoUSE.ListCount > 0 Then
  91.     For Item% = 0 To SCRtoUSE.ListCount
  92.         'If Item is already on list, cancel procedure.
  93.         If SCRtoUSE.List(Item%) = SCR_Files.FileName Then Exit Sub
  94.     Next
  95. End If
  96. SCRtoUSE.AddItem SCR_Files.FileName' Add File from File list to Screen Saver List.
  97. End Sub
  98. Sub Cancel_Click ()
  99. End 'Close Settings Window
  100. End Sub
  101. Sub Delete_Click ()
  102. If SCRtoUSE.ListIndex = -1 Then Exit Sub 'If no items selected cancel procedure
  103. Li% = SCRtoUSE.ListIndex'Save list index
  104. SCRtoUSE.RemoveItem SCRtoUSE.ListIndex' Remove Saver from list
  105. SCRtoUSE.ListIndex = Li% - 1'Highlight Previous Item
  106. End Sub
  107. Sub Form_Load ()
  108. On Error Resume Next'Enable Error Trapping
  109. If App.PrevInstance = True Then End' If already loaded, cancel this copy.
  110. If UCase$(Command$) = "/C" Then ' check for /C command line parameter to activate Settings window.
  111.     Left = Screen.Width / 2'Align Window (It looks better on SVGA using this)
  112.     Top = Screen.Height / 8'Align Window
  113.     SCR_Files.Path = Getwindowsdir()' Set file list box path to windows directory.
  114.     Open Getwindowsdir() + "SCRMBLER.DAT" For Input As #1'Open sequential data file
  115.     If Err <> 0 Then Close #1: Exit Sub'If file error, Don't create list
  116.     While Not EOF(1)'Loop until end of file
  117.         Input #1, Text$'Get text from file
  118.         SCRtoUSE.AddItem Text$'Add Text to list box.
  119.     Wend
  120.     Close #1'Close File
  121. End If
  122. If UCase$(Command$) = "/S" Then ' Check for /S to start screen Saver
  123.     Visible = False'Make sure Window is visible at no times
  124.     'for conveinince, savers are loaded into List box
  125.     Open Getwindowsdir() + "SCRMBLER.DAT" For Input As #1'Open sequential data file
  126.     If Err <> 0 Then Close #1: Exit Sub'If file error, Don't create list
  127.     While Not EOF(1)'Loop until end of file
  128.         Input #1, Text$'Get text from file
  129.         SCRtoUSE.AddItem Text$'Add Text to list box.
  130.     Wend
  131.     Close #1'Close File
  132.     Randomize'Initiate random number generator
  133.     SCRtoUSE.ListIndex = Int(Rnd * SCRtoUSE.ListCount)'Randomly Chose Saver
  134.     Test_Click'Show saver by seleting it in the list and clicking test button (done automaticly)
  135.     End'Exit Program
  136. End If
  137. End Sub
  138. Function Getwindowsdir () As String 'Borrowed from the example setup program that came with VB.
  139.     temp$ = String$(145, 0)              ' Size Buffer
  140.     x = GetWindowsDirectory(temp$, 145)  ' Make API Call
  141.     temp$ = Left$(temp$, x)              ' Trim Buffer
  142.     If Right$(temp$, 1) <> "\" Then      ' Add \ if necessary
  143.         Getwindowsdir$ = temp$ + "\"
  144.     Else
  145.         Getwindowsdir$ = temp$
  146.     End If
  147. End Function
  148. Sub OK_Click ()
  149. Open Getwindowsdir() + "SCRMBLER.DAT" For Output As #1'Open List file
  150. If SCRtoUSE.ListCount > 0 Then
  151.     For Item% = 0 To SCRtoUSE.ListCount - 1
  152.         'Save List in sequential file
  153.         Print #1, SCRtoUSE.List(Item%)
  154.     Next
  155. End If
  156. Close #1'Close File
  157. End'Close Settings Window
  158. End Sub
  159. Sub Setting_Click ()
  160. If SCRtoUSE.ListIndex = -1 Then Exit Sub'If No Item Selected, cancel procedure
  161. FileCopy Getwindowsdir() + SCRtoUSE.Text, "~LZLWLS.exe"'Copy file to an EXE file which can be used from VB, I just made up the name, It has no significance.
  162. x% = Shell("~LZLWLS.exe /c", 1)'Run Saver in settings window.
  163. While GetModuleUsage(x%) > 0'Check to see if program has terminated
  164.     DoEvents
  165. Kill "~LZLWLS.exe"'Delete file
  166. End Sub
  167. Sub Test_Click ()
  168. If SCRtoUSE.ListIndex = -1 Then Exit Sub'If No Item Selected, cancel procedure
  169. FileCopy Getwindowsdir() + SCRtoUSE.Text, "~LZLWLS.exe"'Copy file to an EXE file which can be used from VB, I just made up the name, It has no significance.
  170. x% = Shell("~LZLWLS.exe /s", 1)'Run Saver.
  171. While GetModuleUsage(x%) > 0'Check to see if program has terminated
  172.     DoEvents
  173. Kill "~LZLWLS.exe"'Delete file
  174. End Sub
  175.