VERSION 2.00 Begin Form frmMain ClientHeight = 6795 ClientLeft = 1260 ClientTop = 2385 ClientWidth = 9480 Height = 7200 Icon = MAIN.FRX:0000 Left = 1200 LinkTopic = "Form1" MaxButton = 0 'False ScaleHeight = 6795 ScaleWidth = 9480 Top = 2040 Width = 9600 Begin SSPanel Panel3D1 BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Height = 6495 Left = 0 TabIndex = 57 Top = 0 Width = 9495 Begin CommandButton cmdExit Caption = "E&xit" Height = 375 Left = 8220 TabIndex = 2 Top = 5940 Width = 1140 End Begin CommandButton cmdAbout Caption = "&About..." Height = 375 Left = 7050 TabIndex = 1 Top = 5940 Width = 1140 End Begin CommandButton cmdHelp Caption = "&Help" Height = 375 Left = 5880 TabIndex = 0 Top = 5940 Width = 1140 End Begin SSFrame fraGenOptions Caption = "Generating WordJunction Puzzles" ForeColor = &H00000000& Height = 4155 Left = 5790 TabIndex = 36 Top = 90 Width = 3585 Begin OptionButton optOptions BackColor = &H00C0C0C0& Caption = "Step &4: Generate/Print/Save Puzzles" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 225 Index = 3 Left = 120 TabIndex = 11 Top = 1140 Width = 3315 End Begin OptionButton optOptions BackColor = &H00C0C0C0& Caption = "Step &1: Select A Word-Clue File" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 225 Index = 0 Left = 120 TabIndex = 8 Top = 300 Value = -1 'True Width = 3195 End Begin OptionButton optOptions BackColor = &H00C0C0C0& Caption = "Step &3: Specify Advanced Settings" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 225 Index = 2 Left = 120 TabIndex = 10 Top = 870 Width = 3315 End Begin OptionButton optOptions BackColor = &H00C0C0C0& Caption = "Step &2: Set Puzzle Appearance" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 255 Index = 1 Left = 120 TabIndex = 9 Top = 570 Width = 3195 End Begin PictureBox picOptions BackColor = &H00C0C0C0& Height = 2505 Index = 0 Left = 90 ScaleHeight = 2475 ScaleWidth = 3375 TabIndex = 65 Top = 1530 Visible = 0 'False Width = 3405 Begin TextBox txtWordNumber Alignment = 1 'Right Justify Enabled = 0 'False Height = 315 Left = 2490 MaxLength = 4 TabIndex = 27 Top = 540 Width = 585 End Begin SpinButton spnWordNumber Delay = 200 Enabled = 0 'False Height = 315 Left = 3060 Top = 540 Width = 255 End Begin CommandButton cmdGetWords Caption = "&Get Words..." Height = 375 Left = 120 TabIndex = 25 Top = 90 Width = 1350 End Begin Label lblClue BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 1365 Left = 600 TabIndex = 41 Top = 1080 Width = 2655 WordWrap = -1 'True End Begin Label lblWord BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 195 Left = 600 TabIndex = 40 Top = 840 Width = 2655 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "Clue:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 195 Index = 7 Left = 120 TabIndex = 29 Top = 1080 Width = 405 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "Word:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 195 Index = 2 Left = 120 TabIndex = 28 Top = 840 Width = 525 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "Word Number In Word-Clue File:" Enabled = 0 'False FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 195 Index = 1 Left = 120 TabIndex = 26 Top = 600 Width = 2325 End End Begin PictureBox picOptions BackColor = &H00C0C0C0& Height = 2505 Index = 3 Left = 90 ScaleHeight = 2475 ScaleWidth = 3375 TabIndex = 66 Top = 1530 Visible = 0 'False Width = 3405 Begin CommandButton cmdLoad Caption = "&Load..." Height = 375 Left = 1890 TabIndex = 15 Top = 1170 Width = 1365 End Begin CommandButton cmdStop Caption = "&Stop" Enabled = 0 'False Height = 375 Left = 1890 TabIndex = 13 Top = 330 Width = 1365 End Begin CommandButton cmdPrintSetup Caption = "Printer &Setup..." Height = 375 Left = 120 TabIndex = 16 Top = 1980 Width = 1695 End Begin CommandButton cmdPrint Caption = "&Print..." Enabled = 0 'False Height = 375 Left = 1890 TabIndex = 17 Top = 1980 Width = 1365 End Begin CommandButton cmdSaveAs Caption = "Save &As..." Enabled = 0 'False Height = 375 Left = 120 TabIndex = 14 Top = 1170 Width = 1695 End Begin CommandButton cmdGenerate Caption = "&Generate Puzzle" Enabled = 0 'False Height = 375 Left = 120 TabIndex = 12 Top = 330 Width = 1695 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "To Print A Puzzle, Use These Controls:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 210 Index = 10 Left = 120 TabIndex = 39 Top = 1740 Width = 3105 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "To Save Or Load A Puzzle, Use These Controls:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 390 Index = 9 Left = 120 TabIndex = 38 Top = 750 Width = 3105 WordWrap = -1 'True End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "To Generate A Puzzle, Use These Controls::" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 210 Index = 8 Left = 120 TabIndex = 37 Top = 90 Width = 3165 End End Begin PictureBox picOptions BackColor = &H00C0C0C0& Height = 2505 Index = 2 Left = 90 ScaleHeight = 2475 ScaleWidth = 3375 TabIndex = 64 Top = 1530 Visible = 0 'False Width = 3405 Begin ComboBox cboFirstWord Enabled = 0 'False Height = 300 Left = 120 Sorted = -1 'True Style = 2 'Dropdown List TabIndex = 33 Top = 960 Width = 3135 End Begin TextBox txtIterations Alignment = 1 'Right Justify Enabled = 0 'False Height = 285 Left = 600 MaxLength = 5 TabIndex = 35 Text = "100" Top = 1485 Width = 1035 End Begin SSCheck chkRandomWord Caption = "Select Words &Randomly" Enabled = 0 'False FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 195 Left = 120 TabIndex = 30 Top = 120 Value = -1 'True Width = 2775 End Begin SSCheck chkRandomMatch Caption = "Select &Matches Randomly" Enabled = 0 'False FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 195 Left = 120 TabIndex = 31 Top = 390 Value = -1 'True Width = 2775 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "&Starting Word:" Enabled = 0 'False FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 210 Index = 4 Left = 120 TabIndex = 32 Top = 690 Width = 1275 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "&Tries:" Enabled = 0 'False FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 210 Index = 5 Left = 120 TabIndex = 34 Top = 1515 Width = 435 End End Begin PictureBox picOptions BackColor = &H00C0C0C0& Height = 2505 Index = 1 Left = 90 ScaleHeight = 2475 ScaleWidth = 3375 TabIndex = 24 Top = 1530 Visible = 0 'False Width = 3405 Begin TextBox txtSize Alignment = 1 'Right Justify Height = 315 Left = 2190 MaxLength = 2 TabIndex = 19 Text = "10" Top = 60 Width = 555 End Begin SSOption optStyle Caption = "&Word Find" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 255 Index = 0 Left = 330 TabIndex = 21 TabStop = 0 'False Top = 630 Width = 2595 End Begin SSOption optStyle Caption = "&Crossword" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 255 Index = 1 Left = 330 TabIndex = 22 Top = 900 Value = -1 'True Width = 2595 End Begin SpinButton spnSize Delay = 200 Height = 315 Left = 2730 Top = 60 Width = 255 End Begin CommandButton cmdSquareFillColor Caption = "Solid S&quare Color..." Enabled = 0 'False Height = 345 Left = 330 TabIndex = 23 Top = 1230 Width = 2175 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "Puzzle St&yle:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 210 Index = 11 Left = 120 TabIndex = 20 Top = 360 Width = 1005 End Begin Shape shpSampleSquare FillColor = &H00808080& FillStyle = 0 'Solid Height = 375 Left = 2640 Shape = 1 'Square Top = 1230 Width = 375 End Begin Label lblGeneral BackStyle = 0 'Transparent Caption = "Ma&ximum Squares Per Side:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 210 Index = 3 Left = 120 TabIndex = 18 Top = 90 Width = 2025 End End End Begin SSFrame fraPuzzleDispOptions Caption = "Viewport Control:" ForeColor = &H00000000& Height = 1425 Left = 5790 TabIndex = 61 Top = 4230 Width = 3585 Begin SSOption optZoom Caption = "Custom &Zoom:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 225 Index = 2 Left = 120 TabIndex = 5 TabStop = 0 'False Top = 900 Width = 1305 End Begin SSOption optZoom Caption = "&Show Actual Size" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 225 Index = 1 Left = 120 TabIndex = 4 TabStop = 0 'False Top = 645 Width = 2115 End Begin SSOption optZoom Caption = "Fi&t Puzzle To Viewport" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 225 Index = 0 Left = 120 TabIndex = 3 Top = 390 Value = -1 'True Width = 2205 End Begin HScrollBar hsbScale Enabled = 0 'False Height = 240 LargeChange = 25 Left = 1560 Max = 200 Min = 30 SmallChange = 10 TabIndex = 6 Top = 900 Value = 100 Width = 1725 End Begin Label lblScale Alignment = 2 'Center BackStyle = 0 'Transparent Caption = "100%" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00000000& Height = 225 Left = 1920 TabIndex = 7 Top = 1170 Width = 975 End End Begin CommonDialog dlgCMDialog CancelError = -1 'True Left = 5820 Top = 5400 End Begin VScrollBar vsbCW Height = 6000 LargeChange = 10 Left = 5400 TabIndex = 60 Top = 240 Width = 255 End Begin PictureBox picPuzzleContainer BackColor = &H00000000& BorderStyle = 0 'None Height = 4455 Left = 540 ScaleHeight = 297 ScaleMode = 3 'Pixel ScaleWidth = 297 TabIndex = 59 Top = 930 Width = 4455 Begin PictureBox picPuzzle AutoSize = -1 'True BackColor = &H00000000& BorderStyle = 0 'None ClipControls = 0 'False Height = 1065 Left = 0 ScaleHeight = 71 ScaleMode = 3 'Pixel ScaleWidth = 281 TabIndex = 56 Top = 0 Visible = 0 'False Width = 4215 End Begin Image imgThinking Height = 930 Left = 120 Picture = MAIN.FRX:0302 Top = 1770 Visible = 0 'False Width = 4230 End End Begin HScrollBar hsbCW Height = 240 LargeChange = 10 Left = 90 TabIndex = 58 Top = 6000 Width = 5355 End Begin PictureBox picViewPort BackColor = &H00C0C000& Height = 5775 Left = 90 Picture = MAIN.FRX:4C04 ScaleHeight = 5745 ScaleWidth = 5295 TabIndex = 55 Top = 240 Width = 5325 Begin Image Image2 BorderStyle = 1 'Fixed Single Height = 510 Left = 0 Picture = MAIN.FRX:7136 Top = 0 Width = 510 End Begin Label lblGeneral Alignment = 2 'Center BackColor = &H00FFFF00& Height = 195 Index = 6 Left = 4170 TabIndex = 63 Top = 240 Visible = 0 'False Width = 855 End Begin Label lblGeneral Alignment = 2 'Center BackColor = &H00FFFF00& Caption = "Viewport" Height = 225 Index = 0 Left = 2160 TabIndex = 62 Top = 5400 Width = 975 End End Begin Label Label2 Alignment = 2 'Center BackColor = &H00000000& BackStyle = 0 'Transparent Caption = "A PC Magazine Utility By Jonathan Waldman And Jack R. Heath" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00000000& Height = 195 Left = 390 TabIndex = 67 Top = 30 Width = 4905 End End Begin SSPanel pnlStatusBar Align = 2 'Align Bottom BevelOuter = 0 'None BorderWidth = 1 Height = 300 Left = 0 TabIndex = 50 Top = 6495 Width = 9480 Begin SSPanel pnlIterations Alignment = 1 'Left Justify - MIDDLE BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Caption = "Tries:" FloodColor = &H00FFFF00& FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00000000& Height = 300 Left = 7940 TabIndex = 53 Top = 15 Width = 1530 Begin Label lblpnlIterations Alignment = 1 'Right Justify BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 225 Left = 450 TabIndex = 54 Top = 30 Width = 975 End End Begin SSPanel pnlMinWordsPlaced Alignment = 1 'Left Justify - MIDDLE BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Caption = "Min:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 300 Left = 4935 TabIndex = 48 Top = 15 Width = 1515 Begin Label lblpnlMinPlaced Alignment = 1 'Right Justify BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 225 Left = 360 TabIndex = 49 Top = 30 Width = 1095 End End Begin SSPanel pnlMaxWordsPlaced Alignment = 1 'Left Justify - MIDDLE BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Caption = "Max" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 300 Left = 6435 TabIndex = 51 Top = 15 Width = 1515 Begin Label lblPnlMaxPlaced Alignment = 1 'Right Justify BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 225 Left = 420 TabIndex = 52 Top = 30 Width = 1035 End End Begin SSPanel pnlWordsInFile Alignment = 1 'Left Justify - MIDDLE BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Caption = "Total:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 300 Left = 1845 TabIndex = 44 Top = 15 Width = 1410 Begin Label lblpnlWordsInFile Alignment = 1 'Right Justify BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 225 Left = 480 TabIndex = 45 Top = 30 Width = 855 End End Begin SSPanel pnlWordsPlaced Alignment = 1 'Left Justify - MIDDLE BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Caption = "Placed:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 300 Left = 3240 TabIndex = 46 Top = 15 Width = 1710 Begin Label lblPnlPlaced Alignment = 1 'Right Justify BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 225 Left = 600 TabIndex = 47 Top = 30 Width = 1005 End End Begin SSPanel pnlSourceFile Alignment = 1 'Left Justify - MIDDLE BevelInner = 1 'Inset BevelOuter = 0 'None BorderWidth = 1 Caption = "File:" FontBold = 0 'False FontItalic = 0 'False FontName = "MS Sans Serif" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False Height = 300 Left = 15 TabIndex = 42 Top = 15 Width = 1840 Begin Label lblpnlFileName Alignment = 2 'Center BackStyle = 0 'Transparent FontBold = 0 'False FontItalic = 0 'False FontName = "Courier New" FontSize = 8.25 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00800000& Height = 225 Left = 390 TabIndex = 43 Top = 30 Width = 1395 End End End End Option Explicit Dim CWResize As Integer Sub cmdAbout_Click () DisplayAboutBox frmMain, "WordJunction", "1.00", "1995 Ziff-Davis Publishing Company", "", "First Appeared in PC MAGAZINE, US Edition", "November 21, 1995", "Written by Jonathan Waldman and Jack R. Heath", 0, True, 0, 0 End Sub Sub cmdExit_Click () End End Sub Sub cmdGenerate_Click () Dim Iterations As Long, TotalIterations As Long, i As Integer Dim Ret As Integer Dim oldArgs As typeArgs Dim oldSolution() As typeSolution gCancelFlag = False ' get user preferences If GetUserPrefs() Then ' turn off create button picPuzzle.Height = 0 picPuzzle.Width = 0 picPuzzle.Visible = False ' size x size label lblGeneral(6).Visible = False CWResize = True gCreatingPuzzle = True gPuzzleExists = False imgThinking.Visible = True picPuzzleContainer.Refresh Iterations = 0 ' Recalled is false on first iteration only Args.Recalled = False ' set iterations to 1 TotalIterations = Val(txtIterations.Text) ' set percentage done property pnlIterations.FloodType = 1 ' disable zoom option frame control SetViewportOptions False ' disable puzzle options frame SetGenerateOptions False lblPnlMinPlaced.Caption = 0 lblPnlMaxPlaced.Caption = 0 lblPnlPlaced.Caption = 0 lblPnlIterations.Visible = False Do Iterations = Iterations + 1 pnlIterations.FloodPercent = Int((Iterations / TotalIterations) * 100) If Iterations > 1 Then Args.Recalled = True Ret = CreatePuzzle(Me) If Ret Then ' update the count of words placed into the puzzle lblPnlPlaced.Caption = Args.PlacedCnt lblPnlPlaced.Refresh ' set minimum placed value If Iterations = 1 Or (Iterations > 1 And Args.PlacedCnt < Val(lblPnlMinPlaced.Caption)) Then lblPnlMinPlaced.Caption = Trim$(Str$(Args.PlacedCnt)) lblPnlMinPlaced.Refresh End If ' set maximum placed value If Args.PlacedCnt > Val(lblPnlMaxPlaced.Caption) Then lblPnlMaxPlaced.Caption = lblPnlPlaced.Caption lblPnlMaxPlaced.Refresh oldArgs = Args Erase oldSolution ReDim oldSolution(1 To UBound(Solution, 1)) For i = 1 To UBound(Solution, 1) oldSolution(i) = Solution(i) Next i End If ' stop if all words were placed If Args.PlacedCnt = UBound(Words, 1) + 1 Then gCancelFlag = True End If ' check to see if we are at the last iteration ' if so, get the best solution into the Args and Solution vars If gCancelFlag Or (Iterations = Val(txtIterations.Text) And (Ret > 0)) Then Erase Solution Args = oldArgs ReDim Solution(1 To UBound(oldSolution, 1)) For i = 1 To UBound(oldSolution, 1) Solution(i) = oldSolution(i) Next i lblPnlPlaced.Caption = Trim$(Str$(Args.PlacedCnt)) lblPnlPlaced.Refresh End If Else gCancelFlag = True End If Loop Until Iterations = TotalIterations Or gCancelFlag pnlIterations.FloodType = 0 pnlIterations.FloodPercent = 0 pnlIterations.Refresh lblPnlIterations.Visible = True lblPnlIterations.Caption = Trim$(Str$(Iterations)) lblPnlIterations.Refresh imgThinking.Visible = False SetGenerateOptions True If Ret <> 0 Then SetActivePuzzle True Else MsgBox "A problem occurred when trying to create a puzzle. " & Args.ErrorMsg SetActivePuzzle False End If Screen.MousePointer = DEFAULT End If End Sub Sub cmdGetWords_Click () Dim Filename As String Dim CharPos As Integer Dim Ret As Integer Dim i As Integer On Error GoTo LoadCancelled dlgCMDialog.Filename = "" dlgCMDialog.Filter = "Word-Clue Files|*.WRD|Saved Puzzles|*.CW" dlgCMDialog.FilterIndex = 1 dlgCMDialog.Action = 1 Filename = dlgCMDialog.Filename On Error GoTo 0 If Filename <> "" Then InitializeEmptyForm Me.Refresh CharPos = InStr(Filename, ".") If CharPos > 0 Then ' the user has chosen a saved puzzle to restore If Mid$(Filename, CharPos + 1) = "CW" Then Ret = fnLoadPuzzle() If Ret > 0 Then SetActivePuzzle True SetLoadedPuzzleOptions False lblpnlFileName.Caption = dlgCMDialog.Filetitle lblpnlWordsInFile.Caption = Trim$(Str$(Ret)) txtWordNumber.Text = "1" lblWord.Caption = Words(0) lblClue.Caption = Clues(0) Else InitializeEmptyForm End If ' the user has chosen a word list to use ElseIf Mid$(Filename, CharPos + 1) = "WRD" Then Ret = fnLoadWords(Filename) If Ret > 0 Then lblpnlWordsInFile.Caption = Trim$(Str$(Ret)) SetLoadedPuzzleOptions True SetGenerateOptions True cboFirstWord.Clear cboFirstWord.AddItem "" cboFirstWord.ItemData(cboFirstWord.NewIndex) = -1 For i = 0 To Ret - 1 cboFirstWord.AddItem Words(i) cboFirstWord.ItemData(cboFirstWord.NewIndex) = i Next i cboFirstWord.ListIndex = 0 lblpnlFileName.Caption = dlgCMDialog.Filetitle SetActivePuzzle False txtWordNumber.Text = "1" lblWord.Caption = Words(0) lblClue.Caption = Clues(0) Else InitializeEmptyForm End If Else MsgBox "You must supply an file name with an extension of 'WRD' or 'CW'." End If End If End If Exit Sub LoadCancelled: If Err = 32755 Then Exit Sub MsgBox "Error encountered during load (" & Trim$(Str$(Err)) & "):" & Chr$(13) & Chr$(13) & Error, MB_ICONEXCLAMATION Exit Sub End Sub Sub cmdHelp_Click () SendKeys "{F1}" End Sub Sub cmdLoad_Click () Dim Filename As String Dim CharPos As Integer Dim Ret As Integer Dim i As Integer On Error GoTo LoadCancelled2 dlgCMDialog.Filename = "" dlgCMDialog.Filter = "Saved Puzzles|*.CW" dlgCMDialog.FilterIndex = 1 dlgCMDialog.Action = 1 Filename = dlgCMDialog.Filename On Error GoTo 0 If Filename <> "" Then InitializeEmptyForm CharPos = InStr(Filename, ".") If CharPos > 0 Then ' the user has chosen a saved puzzle to restore Ret = fnLoadPuzzle() If Ret > 0 Then SetActivePuzzle True SetLoadedPuzzleOptions False lblpnlFileName.Caption = dlgCMDialog.Filetitle lblpnlWordsInFile.Caption = Trim$(Str$(Ret)) txtWordNumber.Text = "1" lblWord.Caption = Words(0) lblClue.Caption = Clues(0) Else InitializeEmptyForm End If Else MsgBox "You must supply an file name with an extension of 'CW'." End If End If Exit Sub LoadCancelled2: If Err = 32755 Then Exit Sub MsgBox "Error encountered during load (" & Trim$(Str$(Err)) & "):" & Chr$(13) & Chr$(13) & Error, MB_ICONEXCLAMATION Exit Sub End Sub Sub cmdPrint_Click () frmPrintOptions.Show MODAL End Sub Sub cmdPrintSetup_Click () MsgBox "The current printer must be selected using the Windows Control Panel (usually in Program Manager's 'Main' group)." End Sub Sub cmdSaveAs_Click () Dim Ret As Integer Ret = fnSavePuzzle() End Sub Sub cmdSquareFillColor_Click () dlgCMDialog.Color = shpSampleSquare.FillColor dlgCMDialog.Flags = CC_RGBINIT Or CC_SHOWHELP dlgCMDialog.Action = DLG_COLOR If shpSampleSquare.FillColor <> dlgCMDialog.Color Then shpSampleSquare.FillColor = dlgCMDialog.Color shpSampleSquare.Refresh DisplayPuzzle End If End Sub Sub cmdStop_Click () gCancelFlag = True End Sub Sub DisplayPuzzle () On Error GoTo DisplayPuzzleErr If picPuzzle.Visible Then Dim Zoom As Integer, CenterFlag As Integer Dim Row As Integer, Col As Integer, i As Integer, j As Integer, RandomLetter As String Dim SkipNumberPrint As Integer gPuzzleExists = False InitPuzzleGrid Screen.MousePointer = HOURGLASS Puzzle.Title = "Title" picPuzzle.ScaleMode = TWIPS picPuzzleContainer.ScaleMode = TWIPS Me.ScaleMode = TWIPS For i = 0 To 2 If optZoom(i) Then Zoom = i Exit For End If Next Puzzle.Height = Args.Size Puzzle.Width = Args.Size lblGeneral(6).Caption = Trim$(Str$(Args.Size)) & " x " & Trim$(Str$(Args.Size)) lblGeneral(6).Refresh If Zoom = 2 Then gCWScale = hsbScale.Value / 100 CenterFlag = False Else ' fit to window If Zoom = 0 Then gCWScale = (picPuzzleContainer.Width / ((Puzzle.Width * 460) + (picPuzzle.DrawWidth * Screen.TwipsPerPixelX))) CenterFlag = True Else ' actual size gCWScale = 1 End If End If Puzzle.SquareSize = 460 * gCWScale Puzzle.SquareFillColor = shpSampleSquare.FillColor Puzzle.SquareBorderColor = BLACK Puzzle.ThreeD = False picPuzzle.Cls picPuzzle.FillStyle = 0 picPuzzle.Height = (Puzzle.Height * Puzzle.SquareSize) + (picPuzzle.DrawWidth * Screen.TwipsPerPixelY) picPuzzle.Width = (Puzzle.Width * Puzzle.SquareSize) + (picPuzzle.DrawWidth * Screen.TwipsPerPixelX) vsbCW.Max = picPuzzle.Height - picPuzzleContainer.Height hsbCW.Max = picPuzzle.Width - picPuzzleContainer.Width hsbCW.Enabled = Not (hsbCW.Max <= 0) vsbCW.Enabled = Not (vsbCW.Max <= 0) vsbCW.LargeChange = picPuzzleContainer.Height vsbCW.SmallChange = Puzzle.SquareSize hsbCW.LargeChange = picPuzzleContainer.Width hsbCW.SmallChange = Puzzle.SquareSize CenterFlag = CenterFlag Or ((hsbCW.Enabled = False) And (vsbCW.Enabled = False)) If CenterFlag Then vsbCW.Max = Puzzle.Height * Puzzle.SquareSize hsbCW.Max = Puzzle.Height * Puzzle.SquareSize picPuzzle.Top = (picPuzzleContainer.Height - vsbCW.Max) \ 2 picPuzzle.Left = (picPuzzleContainer.Width - hsbCW.Max) \ 2 End If picPuzzle.Refresh ' print the grid's "black" squares only first SetWordFont BLACK For Row = 1 To UBound(PuzzleGrid%, 1) For Col = 1 To UBound(PuzzleGrid%, 1) If PuzzleGrid%(Row, Col) = 0 Then picPuzzle.CurrentX = Puzzle.SquareSize * (Col - 1) picPuzzle.CurrentY = Puzzle.SquareSize * (Row - 1) If Not optStyle(0).Value Then ' crossword style picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), Puzzle.SquareFillColor, BF picPuzzle.CurrentX = Puzzle.SquareSize * (Col - 1) picPuzzle.CurrentY = Puzzle.SquareSize * (Row - 1) picPuzzle.FillStyle = TRANSPARENT picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), BLACK, B Else ' word find style picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), WHITE, BF RandomLetter$ = Chr$(Int(Rnd * 26) + 65) SetCursorLetter RandomLetter$, Puzzle, Col, Row picPuzzle.Print RandomLetter$ End If End If Next Col Next Row SkipNumberPrint = False For i = 1 To UBound(Solution, 1) ' across word SkipNumberPrint = False If Solution(i).AcrossWord > -1 Then For j = 1 To Len(Words(Solution(i).AcrossWord)) If PuzzleGrid%(Solution(i).Row, Solution(i).Col + j - 1) Then picPuzzle.CurrentY = Puzzle.SquareSize * (Solution(i).Row - 1) picPuzzle.CurrentX = Puzzle.SquareSize * (Solution(i).Col + j - 2) picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), WHITE, BF ' Draw upper-left. If Not optStyle(0).Value Then picPuzzle.CurrentY = Puzzle.SquareSize * (Solution(i).Row - 1) picPuzzle.CurrentX = Puzzle.SquareSize * (Solution(i).Col + j - 2) picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), BLACK, B ' Draw upper-left. SetWordFont BLACK Else SetWordFont RED End If SetCursorLetter Mid$(Words(Solution(i).AcrossWord), j, 1), Puzzle, Solution(i).Col + j - 1, Solution(i).Row picPuzzle.Print Mid$(Words(Solution(i).AcrossWord), j, 1) ' mark that we filled this square with a letter PuzzleGrid%(Solution(i).Row, Solution(i).Col + j - 1) = 0 End If If j = 1 And Not optStyle(0).Value Then SkipNumberPrint = True SetNumberFont SetCursorNumber Puzzle, Solution(i).Col, Solution(i).Row picPuzzle.Print Trim$(Str$(i)) End If Next j End If ' down word If Solution(i).DownWord > -1 Then For j = 1 To Len(Words(Solution(i).DownWord)) If PuzzleGrid%(Solution(i).Row + j - 1, Solution(i).Col) Then picPuzzle.CurrentY = Puzzle.SquareSize * (Solution(i).Row + j - 2) picPuzzle.CurrentX = Puzzle.SquareSize * (Solution(i).Col - 1) picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), WHITE, BF ' Draw upper-left. If Not optStyle(0).Value Then picPuzzle.CurrentY = Puzzle.SquareSize * (Solution(i).Row + j - 2) picPuzzle.CurrentX = Puzzle.SquareSize * (Solution(i).Col - 1) picPuzzle.Line (picPuzzle.CurrentX, picPuzzle.CurrentY)-Step(Puzzle.SquareSize, Puzzle.SquareSize), BLACK, B ' Draw upper-left. SetWordFont BLACK Else SetWordFont RED End If SetCursorLetter Mid$(Words(Solution(i).DownWord), j, 1), Puzzle, Solution(i).Col, Solution(i).Row + j - 1 picPuzzle.Print Mid$(Words(Solution(i).DownWord), j, 1) ' mark that we filled this square with a letter PuzzleGrid%(Solution(i).Row + j - 1, Solution(i).Col) = 0 End If If j = 1 And Not (SkipNumberPrint) And Not optStyle(0).Value Then SetNumberFont SetCursorNumber Puzzle, Solution(i).Col, Solution(i).Row picPuzzle.Print Trim$(Str$(i)) End If Next j End If Next i Screen.MousePointer = DEFAULT gPuzzleExists = True End If Exit Sub DisplayPuzzleErr: MsgBox "WordJunction could not display the puzzle (" & Trim$(Str$(Err)) & ").", MB_ICONEXCLAMATION Screen.MousePointer = DEFAULT Exit Sub End Sub Sub Form_Load () Me.Caption = App.Title CenterForm Me ReDim PuzzleGrid%(0, 0) InitializeEmptyForm End Sub Sub GetArgs () chkRandomWord.Value = Abs(Args.RandomWord) chkRandomMatch.Value = Abs(Args.RandomMatch) txtSize.Text = Trim$(Str$(Args.MaxSize)) End Sub Function GetUserPrefs () As Integer GetUserPrefs = True If cboFirstWord.ItemData(cboFirstWord.ListIndex) = -1 Then Args.FirstWord = cboFirstWord.ItemData(Int(Rnd * lblpnlWordsInFile.Caption) + 1) Else Args.FirstWord = cboFirstWord.ItemData(cboFirstWord.ListIndex) End If Args.RandomWord = (chkRandomWord.Value) * -1 Args.RandomMatch = (chkRandomMatch.Value) * -1 If Val(txtSize.Text) > 24 Then MsgBox "The maximum size for a puzzle is 24 x 24." GetUserPrefs = False ElseIf Val(txtSize.Text) < 2 Then MsgBox "The minimum size for a puzzle is 2 x 2." GetUserPrefs = False Else Args.MaxSize = Val(txtSize.Text) End If End Function Sub hsbCW_Change () picPuzzle.Left = -hsbCW.Value End Sub Sub hsbScale_Change () optZoom(2).Value = True gCWScale = hsbScale.Value / 100 CWResize = True lblScale.Caption = Trim(Str$(gCWScale * 100)) & "%" hsbScale.Refresh lblScale.Refresh CWResize = True DisplayPuzzle End Sub Sub hsbScale_Scroll () lblScale.Caption = Trim(Str$(hsbScale.Value)) & "%" lblScale.Refresh hsbScale.Refresh End Sub Sub InitializeEmptyForm () picPuzzle.Cls picPuzzle.Visible = False vsbCW.Enabled = False hsbCW.Enabled = False lblpnlFileName.Caption = "" lblpnlWordsInFile.Caption = "0" lblGeneral(6).Caption = "" cmdGenerate.Enabled = False SetViewportOptions False optOptions_Click 0 optStyle_Click 1, 1 SetActivePuzzle False Me.Refresh End Sub Sub optOptions_Click (Index As Integer) Dim i For i = 0 To 3 picOptions(i).Visible = (Index = i) Next i optOptions(Index).Value = True End Sub Sub optPuzzleOptions_Click (Index As Integer, Value As Integer) txtIterations.Enabled = Value lblGeneral(5).Enabled = Value End Sub Sub optStyle_Click (Index As Integer, Value As Integer) cmdSquareFillColor.Enabled = (Index = 1) DoEvents DisplayPuzzle End Sub Sub optZoom_Click (Index As Integer, Value As Integer) CWResize = True ' custom zoom If Index = 2 Then CWResize = True DisplayPuzzle hsbScale.Enabled = True hsbScale.SetFocus Else hsbScale.Enabled = False ' fit to window DisplayPuzzle End If End Sub Sub picPuzzle_Paint () If gPuzzleExists And (Not CWResize) And (Not gCreatingPuzzle) Then DisplayPuzzle End If CWResize = False End Sub Sub SetActivePuzzle (Boolean As Integer) SetViewportOptions Boolean picPuzzle.Visible = Boolean gCreatingPuzzle = Not Boolean cmdPrint.Enabled = Boolean cmdSaveAs.Enabled = Boolean ' size x size label lblGeneral(6).Visible = Boolean DisplayPuzzle End Sub Sub SetCursorLetter (CharToPrint As String, P As PuzzleInfo, x, y) picPuzzle.CurrentX = (P.SquareSize * x - (Int(.5 * P.SquareSize))) - Int(.5 * picPuzzle.TextWidth(CharToPrint)) picPuzzle.CurrentY = (P.SquareSize * y - (Int(.5 * P.SquareSize))) - Int(.5 * picPuzzle.TextHeight(CharToPrint)) End Sub Sub SetCursorNumber (P As PuzzleInfo, x, y) picPuzzle.CurrentX = (P.SquareSize * .05) + ((P.SquareSize) * (x - 1)) picPuzzle.CurrentY = (P.SquareSize * .02) + ((P.SquareSize) * (y - 1)) End Sub Sub SetGenerateOptions (Boolean As Integer) optOptions(0).Enabled = Boolean optOptions(1).Enabled = Boolean optOptions(2).Enabled = Boolean cmdLoad.Enabled = Boolean cmdSaveAs.Enabled = Boolean cmdPrint.Enabled = Boolean cmdGenerate.Enabled = Boolean cmdStop.Enabled = Not Boolean ' number of item in word-clue file spnWordNumber.Enabled = Boolean txtWordNumber.Enabled = Boolean lblGeneral(1).Enabled = Boolean End Sub Sub SetLoadedPuzzleOptions (Boolean As Integer) ' maximum squares per side lblGeneral(3).Enabled = Boolean txtSize.Enabled = Boolean ' tries lblGeneral(5).Enabled = Boolean txtIterations.Enabled = Boolean ' starting word lblGeneral(4).Enabled = Boolean cboFirstWord.Enabled = Boolean ' advanced chkRandomWord.Enabled = Boolean chkRandomMatch.Enabled = Boolean ' generate button cmdGenerate.Enabled = Boolean ' save as button cmdSaveAs.Enabled = Boolean ' number of item in word-clue file spnWordNumber.Enabled = Not Boolean txtWordNumber.Enabled = Not Boolean lblGeneral(1).Enabled = Not Boolean lblPnlPlaced.Caption = "N/A" lblPnlMinPlaced.Caption = "N/A" lblPnlMaxPlaced.Caption = "N/A" lblPnlIterations.Caption = "N/A" End Sub Sub SetNumberFont () picPuzzle.FontName = "Courier New" picPuzzle.FontSize = 7 * gCWScale picPuzzle.FontBold = False picPuzzle.ForeColor = &H80000008 End Sub Sub SetViewportOptions (Boolean As Integer) optZoom(0).Enabled = Boolean optZoom(1).Enabled = Boolean optZoom(2).Enabled = Boolean lblScale.Enabled = Boolean End Sub Sub SetWordFont (ColorFlag As Integer) picPuzzle.FontName = "Courier New" picPuzzle.FontSize = 10 * gCWScale picPuzzle.FontBold = False picPuzzle.ForeColor = ColorFlag End Sub Sub spnSize_SpinDown () Dim i i = Val(txtSize) i = i - 1 If i >= 2 Then txtSize.Text = Trim$(Str$(i)) End If Me.Refresh End Sub Sub spnSize_SpinUp () Dim i i = Val(txtSize) i = i + 1 If i <= 24 Then txtSize.Text = Trim$(Str$(i)) End If Me.Refresh End Sub Sub spnWordNumber_SpinDown () Dim i i = Val(txtWordNumber.Text) i = i - 1 If i >= 1 Then txtWordNumber.Text = Trim$(Str$(i)) lblWord.Caption = Words(i - 1) lblClue.Caption = Clues(i - 1) End If Me.Refresh End Sub Sub spnWordNumber_SpinUp () Dim i i = Val(txtWordNumber) i = i + 1 If i <= Val(lblpnlWordsInFile.Caption) Then txtWordNumber.Text = Trim$(Str$(i)) lblWord.Caption = Words(i - 1) lblClue.Caption = Clues(i - 1) End If Me.Refresh End Sub Sub txtIterations_LostFocus () txtIterations.Text = Trim$(Str$(Val(txtIterations.Text))) If Val(txtIterations.Text) < 1 Or Val(txtIterations.Text) > 10000 Then MsgBox "Please enter a number of tries greater than 0 and less than 10,000." txtIterations.SetFocus End If End Sub Sub txtSize_LostFocus () txtSize.Text = Trim$(Str$(Int(Abs(Val(txtSize.Text))))) If Val(txtSize.Text) > 24 Then txtSize.Text = "24" If Val(txtSize.Text) < 2 Then txtSize.Text = "2" End Sub Sub txtWordNumber_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then txtWordNumber_LostFocus End Sub Sub txtWordNumber_LostFocus () If Val(txtWordNumber.Text) > Val(lblpnlWordsInFile.Caption) Then txtWordNumber.Text = lblpnlWordsInFile.Caption End If If Val(txtWordNumber.Text) <= 0 Then txtWordNumber.Text = 1 End If txtWordNumber.Text = Trim$(Str$(Val(txtWordNumber.Text))) lblWord.Caption = Words(Val(txtWordNumber.Text) - 1) lblClue.Caption = Clues(Val(txtWordNumber.Text) - 1) End Sub Sub vsbCW_Change () picPuzzle.Top = -vsbCW.Value End Sub