home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / GET_IDL / TESTDLL.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-04-11  |  4.4 KB  |  136 lines

  1. VERSION 2.00
  2. Begin Form Testdll 
  3.    Caption         =   "Idle Time DLL Test Module"
  4.    ClientHeight    =   2250
  5.    ClientLeft      =   1050
  6.    ClientTop       =   2010
  7.    ClientWidth     =   4845
  8.    Height          =   2655
  9.    Icon            =   TESTDLL.FRX:0000
  10.    Left            =   990
  11.    LinkTopic       =   "Form2"
  12.    ScaleHeight     =   2250
  13.    ScaleWidth      =   4845
  14.    Top             =   1665
  15.    Width           =   4965
  16.    Begin CommandButton buQuit 
  17.       Cancel          =   -1  'True
  18.       Caption         =   "&Quit"
  19.       Height          =   375
  20.       Left            =   2520
  21.       TabIndex        =   5
  22.       Top             =   1560
  23.       Width           =   2175
  24.    End
  25.    Begin CommandButton buUserFlag 
  26.       Caption         =   "Ignore &USER msgs"
  27.       Height          =   375
  28.       Left            =   120
  29.       TabIndex        =   1
  30.       Tag             =   "0"
  31.       Top             =   1560
  32.       Width           =   2175
  33.    End
  34.    Begin Timer Timer1 
  35.       Interval        =   12
  36.       Left            =   4200
  37.       Top             =   480
  38.    End
  39.    Begin Label lbSecs 
  40.       BorderStyle     =   1  'Fixed Single
  41.       Caption         =   "0"
  42.       Height          =   255
  43.       Left            =   2040
  44.       TabIndex        =   4
  45.       Top             =   900
  46.       Width           =   1695
  47.    End
  48.    Begin Label lbSeconds 
  49.       Caption         =   "Seconds Since Last Event"
  50.       Height          =   435
  51.       Left            =   240
  52.       TabIndex        =   3
  53.       Top             =   780
  54.       Width           =   1695
  55.    End
  56.    Begin Label lbLastEvent 
  57.       Caption         =   "Last Event Time"
  58.       Height          =   255
  59.       Left            =   240
  60.       TabIndex        =   2
  61.       Top             =   300
  62.       Width           =   1695
  63.    End
  64.    Begin Label lbTime 
  65.       BorderStyle     =   1  'Fixed Single
  66.       Caption         =   "0"
  67.       Height          =   255
  68.       Left            =   2040
  69.       TabIndex        =   0
  70.       Top             =   300
  71.       Width           =   1695
  72.    End
  73. DefInt A-Z
  74. Option Explicit
  75. Declare Function GetIdleTime Lib "HOWLONG.DLL" () As Long
  76. Declare Function ResetIdleOnUser% Lib "HOWLONG.DLL" (ByVal bFlag%)
  77. Declare Function gettickcount Lib "user" () As Long
  78. ' Sample module, provided by A. Nicklas Malik
  79. ' (c) 1994, Malik Information Services, All Rights Reserved
  80. ' This module (TESTDLL.EXE) illustrates the use of the FREEWARE module,
  81. '             HOWLONG.DLL
  82. ' This VB program, and the DLL that it calls are property
  83. ' of Malik Information Services.  A license is granted to any and
  84. ' all users who would like to include any portion of either
  85. ' the VB program or the DLL into their code, under the condition
  86. ' that any such user agrees that Nicklas Malik, Malik Information
  87. ' Services, and any of its employees, affiliates, distributors, or
  88. ' directors, are not liable for any damages, special, incidental,
  89. ' consequential or otherwise, arising out of the use of these programs.
  90. ' This program was created using Microsoft Visual Basic, Ver. 3.0 Pro Ed.
  91. ' The accompanying DLL was created using Borland C++ for Windows, Ver 3.1
  92. Sub buQuit_Click ()
  93.     ' note: you do not have to do anything special to
  94.     ' unhook the DLL.  It takes care of itself.
  95.     End
  96. End Sub
  97. Sub buUserFlag_Click ()
  98.     Static nouserflag As Integer
  99.     Dim rtn%
  100.     If nouserflag Then
  101.         rtn% = ResetIdleOnUser(True)
  102.         If rtn% <> 0 Then
  103.             MsgBox "Error! returned value is not zero!" ' debug testing
  104.         End If
  105.         nouserflag = False
  106.         buUserFlag.Caption = "Ignore &USER msgs"
  107.     Else
  108.         rtn% = ResetIdleOnUser(False)
  109.         If rtn% = 0 Then
  110.             MsgBox "Error! returned value is zero!" ' debug testing
  111.         End If
  112.         nouserflag = True
  113.         buUserFlag.Caption = "Accept &USER msgs"
  114.     End If
  115. End Sub
  116. Sub Form_Load ()
  117.     Dim myhwnd%
  118.     myhwnd% = testdll.hWnd
  119. End Sub
  120. Sub Timer1_Timer ()
  121.     Dim lastime As Long
  122.     Dim nowtime As Long
  123.     Static soundoff As Integer
  124.     Static soundtime As Long
  125.     lastime = GetIdleTime()
  126.     nowtime = gettickcount()
  127.     lbTime.Caption = Str$(lastime)
  128.     lbSecs.Caption = Str$(Int((nowtime - lastime) / 1000#))
  129.     If (lastime > soundtime) Then
  130.         If (nowtime - lastime) > 5000 Then
  131.             Beep
  132.             soundtime = nowtime
  133.         End If
  134.     End If
  135. End Sub
  136.