home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 2.00 Begin Form frmSize Caption = "Sizing Form" ClientHeight = 2235 ClientLeft = 555 ClientTop = 2835 ClientWidth = 7365 Height = 2640 Left = 495 LinkTopic = "Form1" ScaleHeight = 2235 ScaleWidth = 7365 Top = 2490 Width = 7485 Begin TextBox txtExplain Height = 795 Left = 300 MultiLine = -1 'True TabIndex = 1 Text = "The form will open in default form size it the user does not have any items in their INI file. If the user has items in the INI file, then the form will remember where how it was left." Top = 300 Width = 6735 End Begin CommandButton cmdClose Caption = "Close" Default = -1 'True Height = 435 Left = 2940 TabIndex = 0 Top = 1560 Width = 1395 End Option Explicit Dim strProfileName As String Dim intReturnStatus As Integer Dim strMsg As String Const intSuccess = 0 Sub cmdClose_Click () Unload frmSize End Sub Sub Form_Load () ' This routine will handle the opening of the MDI form. Dim intTop As Integer Dim intWidth As Integer Dim intHeight As Integer Dim intLeft As Integer ' Build the INI file name strProfileName = GetWinDir() & App.EXEName & ".INI" ' Check to see if the INI file is in the users ' Windows directory. If it is not, then move a ' default copy there. If FileExists(strProfileName) = False Then intReturnStatus = CopyFile(App.Path & "\" & App.EXEName & ".INI", strProfileName) If intReturnStatus <> intSuccess Then MsgBox strMsg, 16, strMsgTitle End If End If ' Set the default form parameters intLeft = 10 intTop = 1000 intWidth = 7485 intHeight = 2640 ' If the user has run the program before, get the ' size defaults intReturnStatus = ProfileInt(strProfileName, "Defaults", "Left", 0) If intReturnStatus <> 0 Then intLeft = intReturnStatus End If intReturnStatus = ProfileInt(strProfileName, "Defaults", "Top", 0) If intReturnStatus <> 0 Then intTop = intReturnStatus End If intReturnStatus = ProfileInt(strProfileName, "Defaults", "Height", 0) If intReturnStatus <> 0 Then intHeight = intReturnStatus End If intReturnStatus = ProfileInt(strProfileName, "Defaults", "Width", 0) If intReturnStatus <> 0 Then intWidth = intReturnStatus End If Move intLeft, intTop, intWidth, intHeight End Sub Sub Form_Unload (Cancel As Integer) ' Save the size defaults intReturnStatus = SetProfileString(strProfileName, "Defaults", "Left", CStr(frmSize.Left)) intReturnStatus = SetProfileString(strProfileName, "Defaults", "Top", CStr(frmSize.Top)) intReturnStatus = SetProfileString(strProfileName, "Defaults", "Height", CStr(frmSize.Height)) intReturnStatus = SetProfileString(strProfileName, "Defaults", "Width", CStr(frmSize.Width)) End End Sub