April 23, 2024, 10:18:22 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Time Display

Started by GWS, December 20, 2006, 09:56:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Here's a little time display program that I find useful .. :)

You can left click on it to drag it to another position


'
' EBasic Time Display ..
' GWS - December 2006
'
AutoDefine "Off"

Window w
Const WM_NCLBUTTONDOWN = 0xA1
Const HTCAPTION = 2

If (Init() = 1) Then WaitUntil w = 0
End

Sub main
Select @message
Case @IDControl
If (@ControlID = 1)
StopTimer w,1
CloseWindow w
EndIf
Case @IDLButtonDN
' Move the Window by dragging it ..
SendMessage w.hwnd,WM_NCLBUTTONDOWN,HTCAPTION,0
ÂÃ,  EndSelect
Return
EndSub

Sub Init(),Int
ÂÃ,  Int scrW,scrH
ÂÃ,  GetScreenSize scrW, scrHÂÃ, 
ÂÃ,  OpenWindow (w,(scrW-60)/2,0,60,18,@NoCaption|@ToolWindow|@TopMost,0,"",&main)
ÂÃ,  If (w = 0) Then Return 0
ÂÃ,  Control w,@Button,"",50,0,10,18,0,1
ÂÃ,  SetWindowColor w, 0x555555
ÂÃ,  FrontPen w, 0xffff00
ÂÃ,  BackPen w, 0x555555
ÂÃ,  SetFont w, "Times New Roman",8,400
ÂÃ,  StartTimer w,10000,1,&timeset
ÂÃ,  timeset(w.hwnd,@idtimer,1,0)
Return 1
EndSub

Sub timeset(hwnd:UInt,msg:UInt,idEvent:UInt,dwTime:UInt)
' set time in HH.MM format and display it ..
ÂÃ,  Move w,12,2
ÂÃ,  Print w,Left$(Time$,5)
Return
EndSub


all the best, :)

Graham
Tomorrow may be too late ..

Junner2003

Hey Graham!

Is there a way to show 12 hours instead of 24 hours? The user guide does not say that much, only:

TIME$
STRING = TIME$
Description Returns the current time.
Parameters None.
Return value String containing the current time in the format HH:MM:SS
Remarks See Also: DATE$
Example usage PRINT TIME$

LarryMc

split and store the time$ string in 2 variables
1st is the hours and 2nd is the rest
Then test val of 1st to see if it's 12 or more
  if so subtract 12 and set a flag to indicate pm  (0=am/1=pm)
print resulting 1st variable and original 2nd variable with USING$
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

GWS

Ah .. Larry beat me to it ..  :)

It's a nice little exercise in string handling and the use of Val() and Str$() functions.

all the best, :)

Graham
Tomorrow may be too late ..