VERSION 2.00 Begin MDIForm MDIForm1 Caption = "DiskPie" ClientHeight = 4125 ClientLeft = 510 ClientTop = 1335 ClientWidth = 5625 Height = 5055 Icon = DISKPIE.FRX:0000 Left = 450 LinkTopic = "DiskPie Beta 0.4" Top = 465 Width = 5745 Begin PictureBox Picture1 Align = 2 'Align Bottom BackColor = &H00C0C0C0& Height = 405 Left = 0 ScaleHeight = 375 ScaleWidth = 5595 TabIndex = 0 Top = 3720 Width = 5625 Begin Line Line4 BorderColor = &H00808080& X1 = 5580 X2 = 5580 Y1 = 15 Y2 = 360 End Begin Line Line3 BorderColor = &H00FFFFFF& X1 = 15 X2 = 15 Y1 = 0 Y2 = 360 End Begin Line Line2 BorderColor = &H00808080& X1 = 15 X2 = 5595 Y1 = 360 Y2 = 360 End Begin Line Line1 BorderColor = &H00FFFFFF& X1 = 0 X2 = 5595 Y1 = 0 Y2 = 0 End Begin Shape Shape1 BackColor = &H00FFFFFF& BackStyle = 1 'Opaque BorderColor = &H00808080& BorderWidth = 2 FillColor = &H00FFFFFF& FillStyle = 0 'Solid Height = 255 Left = 75 Shape = 3 'Circle Top = 75 Width = 255 End Begin Label Label1 BackColor = &H00C0C0C0& Height = 135 Left = 480 TabIndex = 1 Top = 120 Width = 4770 End End Begin Menu mnu_Main Caption = "&File" HelpContextID = 2 Index = 0 Begin Menu mnu_File Caption = "&Get Colors" HelpContextID = 3 Index = 0 End Begin Menu mnu_File Caption = "-" Index = 4 End Begin Menu mnu_File Caption = "E&xit" HelpContextID = 21 Index = 5 End End Begin Menu mnu_Main Caption = "&Options" HelpContextID = 6 Index = 1 Begin Menu mnu_Options Caption = "&Save Layout on Exit" Checked = -1 'True HelpContextID = 7 Index = 0 End Begin Menu mnu_Options Caption = "&Maximum Slices" HelpContextID = 8 Index = 102 Begin Menu mnu_Slice Caption = "&5" HelpContextID = 8 Index = 5 End Begin Menu mnu_Slice Caption = "&6" HelpContextID = 8 Index = 6 End Begin Menu mnu_Slice Caption = "&7" HelpContextID = 8 Index = 7 End Begin Menu mnu_Slice Caption = "&8" HelpContextID = 8 Index = 8 End Begin Menu mnu_Slice Caption = "&9" HelpContextID = 8 Index = 9 End Begin Menu mnu_Slice Caption = "1&0" HelpContextID = 8 Index = 10 End Begin Menu mnu_Slice Caption = "1&1" HelpContextID = 8 Index = 11 End Begin Menu mnu_Slice Caption = "1&2" HelpContextID = 8 Index = 12 End Begin Menu mnu_Slice Caption = "1&3" HelpContextID = 8 Index = 13 End Begin Menu mnu_Slice Caption = "1&4" HelpContextID = 8 Index = 14 End End End Begin Menu mnu_Main Caption = "&Window" HelpContextID = 9 Index = 2 WindowList = -1 'True Begin Menu mnu_Window Caption = "New &Dir Window" HelpContextID = 13 Index = 4 End Begin Menu mnu_Window Caption = "New &Ext Window" HelpContextID = 14 Index = 5 End End Begin Menu mnu_Main Caption = "&Help" HelpContextID = 16 Index = 3 Begin Menu mnu_Help Caption = "&Contents" HelpContextID = 16 Index = 0 End Begin Menu mnu_Help Caption = "&Search for Help On..." HelpContextID = 16 Index = 1 End Begin Menu mnu_Help Caption = "&How to Use Help" HelpContextID = 16 Index = 2 End Begin Menu mnu_Help Caption = "-" Index = 3 End Begin Menu mnu_Help Caption = "&About Disk Pie..." HelpContextID = 16 Index = 4 End End End Option Explicit Function ColorsFromIni% () ' Read the 14 pie slice colors from the INI file. Return TRUE if ' all 14 were read correctly; FALSE otherwise. ColorsFromIni = True Dim ColStr$, ColKey$, N%, Success% For N = 1 To 14 ColKey = "Color" + Str$(N) Success = GPPS("Settings", ColKey, "7FFFFFFF", ColStr, 12) SliceColors(N) = Val("&H" + ColStr + "&") ' If any of the slices can't be read, return FALSE If SliceColors(N) = &H7FFFFFFF Then ColorsFromIni = False Exit Function End If Next N End Function Sub MDIForm_Load () Dim Success%, N%, Sec$ NumOpenWindows = 0 ' Get the value of NumSlices and SaveSettings from DISKPIE.INI Sec = "Settings" NumSlices = GPPI(Sec, "Slices", 14) If NumSlices < 5 Then NumSlices = 5 If NumSlices > 14 Then NumSlices = 14 mnu_Slice(NumSlices).Checked = True SaveSettings = GPPI(Sec, "Save Layout", True) mnu_Options(0).Checked = SaveSettings ' Position the main window at its saved location Dim vLeft%, vTop%, vWidth%, vHeight% vWidth = GPPI(Sec, "Width", 6000) vHeight = GPPI(Sec, "Height", 5000) vLeft = GPPI(Sec, "Left", (Screen.Width - vWidth) \ 2) vTop = GPPI(Sec, "Top", (Screen.Height - vHeight) \ 2) Move vLeft, vTop, vWidth, vHeight WindowState = GPPI(Sec, "State", NORMAL) Show ' If the display driver changed, get the colors of the slices from ' an actual pie. Otherwise, get them from the INI file. If any ' of the colors can't be read from the INI file, get them from ' an actual pie Dim DispDrvWas$, DispDrvIs$ Success = GPPS(Sec, "display.drv", "", DispDrvWas, 144) DispDrvIs = String$(145, 0) Success = GetPrivateProfileString("boot.description", "display.drv", "", DispDrvIs, 144, "SYSTEM.INI") DispDrvIs = Left$(DispDrvIs, InStr(DispDrvIs, Chr$(0)) - 1) Success = WPPS(Sec, "display.drv", DispDrvIs) If DispDrvWas <> DispDrvIs Then Dir2Use = "GETCOLORS" NewPie Else ' Get the colors of the pie slices If Not ColorsFromIni() Then Dir2Use = "GETCOLORS" NewPie End If End If ' Get the saved settings for each child window Dim NumWindows% NumWindows = GPPI(Sec, "NumWindows", 0) For N = 0 To NumWindows - 1 Sec = "Window" + Str$(N) Dir2Use = Format$(N) NewPieFromINI (N) Next N End Sub Sub MDIForm_QueryUnload (Cancel As Integer, UnloadMode As Integer) If SaveSettings Then Dim Success% ' Clear out the old child window records. New values will be ' written by the individual child windows when *their* ' QueryUnload methods get called after this. Dim N% For N = 0 To 9 Success = WritePrivateProfileStringByNum("Window" + Str$(N), 0, 0, "DISKPIE.INI") Next N NextWindow = 0 ' Record the program's window state, then restore it to normal. Success = WPPS("Settings", "State", WindowState) If WindowState <> 0 Then WindowState = NORMAL End If End Sub Sub MDIForm_Unload (Cancel As Integer) ' This method gets called after all the child windows have gotten ' a QueryUnload call. Each child window increments NumWindows, ' so at this point NumWindows contains the actual number of child ' windows. Now it's time to write out settings data for the ' main program window, including NumWindows. Dim Success% Success = WPPS("Settings", "Save Layout", Format$(SaveSettings)) If SaveSettings Then ' Save information general program information Success = WPPS("Settings", "Slices", Format$(NumSlices)) Success = WPPS("Settings", "NumWindows", Format$(NextWindow)) ' Record the current coordinates. The WindowState was set to ' normal by the QueryUnload method. Success = WPPS("Settings", "Left", Format$(Left)) Success = WPPS("Settings", "Top", Format$(Top)) Success = WPPS("Settings", "Width", Format$(Width)) Success = WPPS("Settings", "Height", Format$(Height)) End If ' Don't leave the help system hanging around... Success = WinHelpByNum(MdiForm1.hWnd, App.HelpFile, HELP_QUIT, 0) End Sub Sub mnu_File_Click (Index As Integer) ' Note that when a pie window is open, the File menu expands to ' include Print and Print Setup. Select Case Index Case 0 Dir2Use = "GETCOLORS" NewPie Case 5 Unload MdiForm1 End Select End Sub Sub mnu_Help_Click (Index As Integer) ' The Mdi form and the child form have nearly identical menus. Both ' rely on functions in DISKPIE.BAS to process many of them. Share_Help_Click (Index) End Sub Sub mnu_Options_Click (Index As Integer) Select Case Index Case 0 mnu_Options(0).Checked = Not mnu_Options(0).Checked SaveSettings = mnu_Options(0).Checked End Select End Sub Sub mnu_Slice_Click (Index As Integer) If Index <> NumSlices Then mnu_Slice(NumSlices).Checked = False NumSlices = Index mnu_Slice(NumSlices).Checked = True End If End Sub Sub mnu_Window_Click (Index As Integer) ' The Mdi form and the child form have nearly identical menus. Both ' rely on functions in DISKPIE.BAS to process many of them. Share_Window_Click (Index) End Sub Sub NewPieFromINI (ByVal N%) ' The main form's Load method calls this routine for each pie window ' stored in the INI file. Dir2Use = Format$(N) Dim NewPieWin As New Child If Right(NewPieWin.Caption, 5) = "ERROR" Then Unload NewPieWin Else NewPieWin.Show End If End Sub Sub Picture1_Resize () ' Picture1 serves as a status bar. The four lines around its edges ' give a 3D effect, and its label scales to fill the space. Line1.X2 = Picture1.ScaleWidth - 15 Line2.X2 = Line1.X2 Line4.X1 = Line1.X2 Line4.X2 = Line1.X2 Dim W%, H% W = Picture1.ScaleWidth - 465 H = Picture1.ScaleHeight - 150 Label1.Move 405, 75, W, H End Sub