Vista Sidebar Gadget
From OpenLaszlo
A small example that shows how to create a simple Windows Vista Sidebar Gadget that displays the "Processor Architecture", "Installed Memory" and "Available Memory".
This has to be compiled as SWF8 SOLO Application to work!
gadget.lzx:
<?xml version="1.0" encoding="iso-8859-1"?>
<canvas width="130" height="100">
<simplelayout axis="y"/>
<!-- Class that refreshes the data periodically / attribute "rate" specifies refresh rate in seconds -->
<!-- The original code snippet was posted on the OL Forum and used for refreshing data from and XML Source -->
<class name="polling">
<attribute name="rate" value="60"/>
<method event="oninit">
this.pollDelegate = new LzDelegate (this, 'pollData');
LzTimer.addTimer(this.pollDelegate, rate*1000);
</method>
<method name="pollData">
<!-- At this point the Javascript callback function "systemdata()" in the HTML-Page will be called -->
LzBrowser.callJS('systemdata', canvas.Returnvalue);
LzTimer.resetTimer(this.pollDelegate, rate*1000);
</method>
</class>
<!-- Method that takes the return value and refreshes the displayed text -->
<method name="Returnvalue" args="r">
info.setText(r);
</method>
<!-- Refresh every 5 seconds -->
<polling rate="5" />
<!-- The data is displayed here -->
<text id="info" multiline="true" oninit="this.setColor(0x00FF00);LzBrowser.callJS('systemdata', canvas.Returnvalue);"></text>
</canvas>
Add this to the HEAD of gadget.html:
<script type="text/javascript">
function systemdata (){
var systemdata = "CPU Arch.: " + System.Machine.processorArchitecture + "<br/>"
+ "Total Mem.: " + System.Machine.totalMemory + "MB<br/>"
+ "Available Mem.: " + System.Machine.availableMemory + "MB<br/>";
return systemdata;
}
</script>
You are not restricted to reading Vista system information - polling XML-Datasources works without problems.
Download zipped -> Gadget.zip
Info used for ceation of the above example
Windows Sidebar Object Reference Guide on msdn
A guide that shows different ways how Javascript an OpenLaszlo / SWF can exchange data (french)

