home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / various / sizing / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-02-27  |  3.3 KB  |  91 lines

  1. VERSION 2.00
  2. Begin Form frmSize 
  3.    Caption         =   "Sizing Form"
  4.    ClientHeight    =   2235
  5.    ClientLeft      =   555
  6.    ClientTop       =   2835
  7.    ClientWidth     =   7365
  8.    Height          =   2640
  9.    Left            =   495
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   2235
  12.    ScaleWidth      =   7365
  13.    Top             =   2490
  14.    Width           =   7485
  15.    Begin TextBox txtExplain 
  16.       Height          =   795
  17.       Left            =   300
  18.       MultiLine       =   -1  'True
  19.       TabIndex        =   1
  20.       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."
  21.       Top             =   300
  22.       Width           =   6735
  23.    End
  24.    Begin CommandButton cmdClose 
  25.       Caption         =   "Close"
  26.       Default         =   -1  'True
  27.       Height          =   435
  28.       Left            =   2940
  29.       TabIndex        =   0
  30.       Top             =   1560
  31.       Width           =   1395
  32.    End
  33. Option Explicit
  34. Dim strProfileName As String
  35. Dim intReturnStatus As Integer
  36. Dim strMsg As String
  37. Const intSuccess = 0
  38. Sub cmdClose_Click ()
  39.     Unload frmSize
  40. End Sub
  41. Sub Form_Load ()
  42. '   This routine will handle the opening of the MDI form.
  43.     Dim intTop As Integer
  44.     Dim intWidth As Integer
  45.     Dim intHeight As Integer
  46.     Dim intLeft As Integer
  47. '   Build the INI file name
  48.     strProfileName = GetWinDir() & App.EXEName & ".INI"
  49. '   Check to see if the INI file is in the users
  50. '   Windows directory. If it is not, then move a
  51. '   default copy there.
  52.     If FileExists(strProfileName) = False Then
  53.         intReturnStatus = CopyFile(App.Path & "\" & App.EXEName & ".INI", strProfileName)
  54.         If intReturnStatus <> intSuccess Then
  55.             MsgBox strMsg, 16, strMsgTitle
  56.         End If
  57.     End If
  58. '   Set the default form parameters
  59.     intLeft = 10
  60.     intTop = 1000
  61.     intWidth = 7485
  62.     intHeight = 2640
  63. '   If the user has run the program before, get the
  64. '   size defaults
  65.     intReturnStatus = ProfileInt(strProfileName, "Defaults", "Left", 0)
  66.     If intReturnStatus <> 0 Then
  67.         intLeft = intReturnStatus
  68.     End If
  69.     intReturnStatus = ProfileInt(strProfileName, "Defaults", "Top", 0)
  70.     If intReturnStatus <> 0 Then
  71.         intTop = intReturnStatus
  72.     End If
  73.     intReturnStatus = ProfileInt(strProfileName, "Defaults", "Height", 0)
  74.     If intReturnStatus <> 0 Then
  75.         intHeight = intReturnStatus
  76.     End If
  77.     intReturnStatus = ProfileInt(strProfileName, "Defaults", "Width", 0)
  78.     If intReturnStatus <> 0 Then
  79.         intWidth = intReturnStatus
  80.     End If
  81.     Move intLeft, intTop, intWidth, intHeight
  82. End Sub
  83. Sub Form_Unload (Cancel As Integer)
  84. '   Save the size defaults
  85.     intReturnStatus = SetProfileString(strProfileName, "Defaults", "Left", CStr(frmSize.Left))
  86.     intReturnStatus = SetProfileString(strProfileName, "Defaults", "Top", CStr(frmSize.Top))
  87.     intReturnStatus = SetProfileString(strProfileName, "Defaults", "Height", CStr(frmSize.Height))
  88.     intReturnStatus = SetProfileString(strProfileName, "Defaults", "Width", CStr(frmSize.Width))
  89.     End
  90. End Sub
  91.