home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / LordLucifer / win32asm / files / win32asm.exe / Win32ASM / Win32Proto / W32PTimer.asm < prev    next >
Encoding:
Assembly Source File  |  1997-11-10  |  4.5 KB  |  175 lines

  1.     Page 60,190
  2.     TITLE W32PTimer - Windows 95 prototype - Timer handling.
  3.  
  4.                 .586
  5.                 .MODEL FLAT,STDCALL
  6.  
  7.                 .NOLISTMACRO
  8.                 .NOLIST
  9.  
  10. UniCode         = 0
  11.                 INCLUDE INSTR32.MAC
  12.  
  13.                 INCLUDE WIN32INC.EQU
  14.                 INCLUDE WIN32.MAC
  15.  
  16.                 INCLUDE KERNEL32.EQU
  17.                 INCLUDE USER32.EQU
  18.  
  19.                 INCLUDE W32PROTO.EQU
  20.                 .LIST
  21.  
  22. ErrorBox        PROTO lpszErrorMsg:DWORD
  23. SBDisplay       PROTO uSBPart:DWORD,lpszMsg:DWORD
  24. CvDec2          PROTO
  25.                 PAGE
  26. ; ==================================================================
  27. ; Global Data section.
  28. ; ==================================================================
  29.  
  30.     .DATA
  31.  
  32.  
  33. ; ==========================================================================
  34. ; Create the timer.
  35. ; ==========================================================================
  36.  
  37.     .CONST
  38.  
  39. ErrorTimer BYTE 'Couldn''t create timer',0
  40.  
  41.  
  42.     .DATA
  43.  
  44.     ALIGN DWORD
  45.  
  46. hTimer DWORD 0
  47.  
  48.     .CODE
  49.  
  50. TMCreate PROTO hWnd:DWORD
  51. TMCreate PROC PUBLIC hWnd:DWORD
  52.  
  53.     INVOKE SetTimer,                    ;set the timer
  54.              hWnd,                      ;Window handle,
  55.              IDXX_TIMER,                ;Timer handle,
  56.              1000,                      ;every 1000 millisecs,
  57.              0                          ;no timerproc.
  58.  
  59.     MOV hTimer,EAX                      ;Save timer handle.
  60.       .IF EAX == 0                      ;If timer creation failed,
  61.       INVOKE ErrorBox,                  ;Give error message.
  62.                ErrorTimer
  63.       SUB EAX,EAX                       ;and set EAX back to error.
  64.       .ENDIF
  65.  
  66.     RET
  67.  
  68. TMCreate ENDP
  69.  
  70.  
  71. ; ==========================================================================
  72. ; Kill the timer.
  73. ; ==========================================================================
  74.  
  75.  
  76. TMKill PROTO hWnd:DWORD
  77. TMKill PROC PUBLIC hWnd:DWORD
  78.  
  79.     INVOKE KillTimer,
  80.              hWnd,
  81.              IDXX_TIMER
  82.     RET
  83.  
  84. TMKill ENDP
  85.  
  86.  
  87. ; ==========================================================================
  88. ; Process WM_TIMER message:
  89. ;   format the current time and display it on the status bar.
  90. ; ==========================================================================
  91.  
  92.     .DATA
  93.  
  94. Time     SYSTEMTIME <?>
  95.  
  96. TMsg     LABEL BYTE
  97. TMsgHour BYTE '??'
  98.          BYTE ':'
  99. TMsgMin  BYTE '??'
  100.          BYTE ':'
  101. TMsgSec  BYTE '??'
  102.          BYTE ' '
  103. TMsgAMPM BYTE '?'
  104.          BYTE 'M'
  105.          BYTE 0
  106.  
  107.     ALIGN DWORD
  108.  
  109.          .CODE
  110.  
  111. WinProc_WM_TIMER PROC PUBLIC,
  112.                    hWnd:DWORD,
  113.                    wMsg:DWORD,
  114.                    wParam:DWORD,
  115.                    lParam:DWORD
  116.  
  117.       .IF wParam == IDXX_TIMER          ;Is it our timer?
  118.  
  119.       CALL FmTime                       ;Yes. Format and display the time
  120.       INVOKE SBDisplay,                 ;Display time in statusbar,
  121.                SBPART_TIME,             ;SBPART_TIME section.
  122.                OFFSET TMsg
  123.       .ELSE
  124.       INVOKE DefWindowProc,             ;Some other timer, pass to default.
  125.                hWnd,
  126.                wMsg,
  127.                wParam,
  128.                lParam
  129.       .ENDIF
  130.  
  131.     SUB EAX,EAX
  132.     RET
  133.  
  134. WinProc_WM_TIMER ENDP
  135.  
  136.  
  137. ; ==========================================================================
  138. ; Get the current time,
  139. ; Format it and display it on the status bar.
  140. ; ==========================================================================
  141.  
  142.  
  143.     .CODE
  144.  
  145. FmTime PROC
  146.     INVOKE GetLocalTime,                ;get the local time from win32
  147.              OFFSET Time
  148.  
  149.     MOV TMsgAMPM,'A'                    ;Default to AM,
  150.     SUB EAX,EAX
  151.     MOV AX,Time.wHour                   ;Get hour
  152.  
  153.       .IF EAX > 12                      ;It's pm.
  154.       MOV TMsgAMPM,'P'                  ;Reset to pm,
  155.       SUB EAX,12                        ;back to 12 hours scale.
  156.       .ENDIF
  157.  
  158.     LEA EDI,TMsgHour                    ;dest
  159.     INVOKE CvDec2                       ;convert to displayable ascii decimal
  160.  
  161.     SUB EAX,EAX
  162.     MOV AX,Time.wMinute                 ;integer load the minute
  163.     LEA EDI,TMsgMin                     ;dest
  164.     INVOKE CvDec2                       ;convert to displayable ascii decimal
  165.  
  166.     SUB EAX,EAX
  167.     MOV AX,Time.wSecond                 ;integer load the second
  168.     LEA EDI,TMsgSec                     ;dest
  169.     INVOKE CvDec2                       ;convert to displayable ascii decimal
  170.     RET
  171. FmTime ENDP
  172.  
  173.  
  174.     END
  175.