Continuing the Birthday Countdown Gadget Tutorial.
What we are going to do here is make some individual text items and place them so that they fit into our graphic.
If you look at the image below you will see "Days/hrs/min/sec" Each has its own text object.

The names are simple:
days, hrs, mins, secs
If you look at the code below you will see how we assign the info to each item:
(go back to the previous tutorial to get the details on what all this means)
Code: vbscript
- Dim BDate
- Sub Object_OnScriptEnter
- BDate = cdate("11/20/2009")
- Object.SetTimer 1, 1000
- End Sub
- Sub Object_OnTimer1
-
- CurTime = formatdatetime(now,3)
- i = DateDiff("s", Now, BDate)
- DaysLeft = i \ 86400
- i = i Mod 86400
- HoursLeft = i \ 3600
- i = i Mod 3600
- MinutesLeft = i \ 60
- i = i Mod 60
- SecondsLeft = i
- desktopx.Object("days").text = DaysLeft
- desktopx.Object("hrs").text = HoursLeft
- desktopx.Object("mins").text = MinutesLeft
- desktopx.Object("secs").text = SecondsLeft
- End Sub
- Sub Object_OnScriptExit
- object.KillTimer 1
- End Sub
This is the same code as in part 1, but we have removed all the "object.text" items and we now have 4 individual calls to put text into each object:
- desktopx.Object("days").text = DaysLeft
- desktopx.Object("hrs").text = HoursLeft
- desktopx.Object("mins").text = MinutesLeft
- desktopx.Object("secs").text = SecondsLeft
In each the call is VERY simple, dekxtopx.object("name").text = value
The "NAME" is the name you gave each object, and the value is what you want it to be.. VERY simple.
Yes i know this was VERY basic, but I want to do this in "steps" that others can follow.
You might also notice a small down arrow in the image. That is a button that allows me to swap the "Large" and "Mini" modes of the object. I will cover that in part 3.
Enjoy,
RomanDA