home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vb_mem / vbmem.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  4.9 KB  |  160 lines

  1. VERSION 2.00
  2. Begin Form SysInfo 
  3.    Caption         =   "System Info"
  4.    ClientHeight    =   825
  5.    ClientLeft      =   1665
  6.    ClientTop       =   3165
  7.    ClientWidth     =   4755
  8.    FontBold        =   -1  'True
  9.    FontItalic      =   0   'False
  10.    FontName        =   "System"
  11.    FontSize        =   9.75
  12.    FontStrikethru  =   0   'False
  13.    FontUnderline   =   0   'False
  14.    ForeColor       =   &H00000000&
  15.    Height          =   1230
  16.    Icon            =   VBMEM.FRX:0000
  17.    Left            =   1605
  18.    LinkMode        =   1  'Source
  19.    LinkTopic       =   "Form2"
  20.    MaxButton       =   0   'False
  21.    ScaleHeight     =   825
  22.    ScaleWidth      =   4755
  23.    Top             =   2820
  24.    Width           =   4875
  25.    Begin Timer Tmr_Time 
  26.       Interval        =   10025
  27.       Left            =   5370
  28.       Top             =   195
  29.    End
  30.    Begin Timer Tmr_Mem 
  31.       Interval        =   2000
  32.       Left            =   4860
  33.       Top             =   195
  34.    End
  35.    Begin PictureBox Pic_Pc 
  36.       BorderStyle     =   0  'None
  37.       ForeColor       =   &H00000000&
  38.       Height          =   525
  39.       Left            =   240
  40.       Picture         =   VBMEM.FRX:0302
  41.       ScaleHeight     =   525
  42.       ScaleWidth      =   525
  43.       TabIndex        =   2
  44.       Top             =   120
  45.       Width           =   525
  46.    End
  47.    Begin Label Lbl_Math 
  48.       ForeColor       =   &H00808000&
  49.       Height          =   255
  50.       Left            =   3135
  51.       TabIndex        =   3
  52.       Top             =   480
  53.       Width           =   1215
  54.    End
  55.    Begin Label Lbl_Info 
  56.       BackColor       =   &H00FFFFFF&
  57.       ForeColor       =   &H00000000&
  58.       Height          =   405
  59.       Left            =   1110
  60.       TabIndex        =   0
  61.       Top             =   285
  62.       Width           =   1875
  63.    End
  64.    Begin Label Lbl_FreeMem 
  65.       ForeColor       =   &H00404080&
  66.       Height          =   390
  67.       Left            =   3120
  68.       TabIndex        =   1
  69.       Top             =   90
  70.       Width           =   1200
  71.    End
  72.    Begin Label Lbl_Mode 
  73.       ForeColor       =   &H00800000&
  74.       Height          =   255
  75.       Left            =   1080
  76.       TabIndex        =   4
  77.       Top             =   75
  78.       Width           =   1935
  79.    End
  80. ' These are the definitions and declarations for object FORM
  81. DefInt A-Z
  82. Declare Function GetFreeSpace Lib "Kernel" (ByVal wFlags) As Long
  83. Declare Function GetWinFlags Lib "Kernel" () As Long
  84. Const WF_STANDARD = &H10
  85. Const WF_ENHANCED = &H20
  86. Const WF_80x87 = &H400
  87. Dim Mem As Long
  88. Dim Mem2 As Long
  89. Dim CRLF As String * 2
  90. Sub Form_Load ()
  91. Dim WinFlags As Long
  92. Dim Mode As String, Processor As String
  93.     ' Center on the screen
  94.     '
  95.      Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
  96.     ' Get current Windows configuration
  97.     '
  98.     WinFlags = GetWinFlags()
  99.     ' CRLF variable causes a line break in a labels caption
  100.     '
  101.     CRLF = Chr$(13) + Chr$(10)
  102.     ' Check Windows mode
  103.     '
  104.     If WinFlags And WF_ENHANCED Then
  105.         Mode = "386 Enhanced Mode"
  106.     Else
  107.         Mode = "Standard Mode"
  108.     End If
  109.      
  110.     ' Check for math coprocessor
  111.     '
  112.     If WinFlags And WF_80x87 Then
  113.         Processor = "Present"
  114.     Else
  115.         Processor = "None"
  116.     End If
  117.     ' Put titles and values into labels
  118.     '
  119.     Lbl_Mode.Caption = Mode
  120.     Lbl_Info.Caption = "Free Memory:" + CRLF + "Math Co-processor:"
  121.     Lbl_FreeMem.Caption = CRLF + Format$(GetFreeSpace(0) \ 1024, "##,#00") + " KB"
  122.     Lbl_Math.Caption = Processor
  123. End Sub
  124. Sub Form_Resize ()
  125.     ' Initial check if the application is minimized.
  126.     ' If so, display free memory in caption
  127.     If SysInfo.WindowState = 1 Then
  128.         SysInfo.Caption = Format$(GetFreeSpace(0) \ 1024, "##,#00") + " KB Free"
  129.     Else
  130.         SysInfo.Caption = "System Info"
  131.     End If
  132. End Sub
  133. Sub Pic_Pc_Click ()
  134.     ' Display About Box
  135.     Msg$ = "by Charles K. Snider" + CRLF + "Compuserv 73730,1315"
  136.     MsgBox Msg$, 64, "VBMEM v1.1"
  137. End Sub
  138. Sub Tmr_Mem_Timer ()
  139.     On Error Resume Next
  140.     Lbl_FreeMem.Caption = CRLF + Format$(GetFreeSpace(0) \ 1024, "##,#00") + " KB"
  141.     ' Check if the application is minimized.
  142.     ' If so, display free memory in caption
  143.     ' Mem and Mem2 are compared. Mem2 is retrived by
  144.     ' the timer every second and compared to Mem. A
  145.     ' difference will evaluate true and only then will
  146.     ' the caption be redisplayed. This is to avoid
  147.     ' continuous blinking of the caption.
  148.     Mem2 = GetFreeSpace(0)
  149.     If SysInfo.WindowState = 1 Then
  150.         If Mem <> Mem2 Then SysInfo.Caption = Format$(GetFreeSpace(0) \ 1024, " ##,#00") + " KB Free"
  151.     Else
  152.         SysInfo.Caption = "System Info"
  153.     End If
  154. End Sub
  155. Sub Tmr_Time_Timer ()
  156.     ' Mem is checked every 10.25 seconds
  157.     ' (see Tmr_Mem)
  158.     Mem = GetFreeSpace(0)
  159. End Sub
  160.