Tuesday, 31 July 2012

Create a basic gadget and installer for Windows 7.


In this blog post, I will discuss the steps needed to create a basic gadget in Windows 7.


A gadget consists of XML, HTML,Script and CSS files.



Gadget Directory:-

A directory to hold all gadget files( with the .Gadget extension) in c:\Program Files\Windows Sidebar\Gadgets.  

Follow these steps  to create  a new gadget :-

Step1.Create a new folder on your desktop and name it test.gadget .

Step2.Open that folder and create two files in that folder  .

 * gadget.xml 
The manifest is an XML file that contains the basic information about the gadget, such as the name, version, and permissions. 

<?xml version="1.0" encoding="utf-8" ?>
<gadget>
  <name>HelloGadget</name>
  <version>1.0.0.0</version>
  <description>Hello World Gadget.</description>
  <hosts>
    <host name="sidebar">
      <base type="HTML" apiVersion="1.0.0" src="HelloGadget.html" />
      <permissions>Full</permissions>
      <platform minPlatformVersion="1.0" />
    </host>
  </hosts>
</gadget>


*HelloGadget.html 




This HTML file is the main one used to display the gadget and also contains the CSS, used for styling and Script. It's location is specified in the <base> tag of the manifest XML file (gadget.xml).


<html>
<script>
//----------------- resizes the gadget display surface
function DoInit() {
    document.body.style.width = 90;
    document.body.style.height= 55;
    document.body.style.margin=0;
}
</script>
<body onload="DoInit();">
<table border="5"><tr><td><center><i>Hello World!</i></center></td></tr></table>
</body>
</html>

Step3.
                 Open a Windows Explorer and drill-down to locate the
   following folder:
                c:\Program Files\Windows Sidebar\Gadgets.
                           Or


                        Start/Run input boxes ( the Run dialog (Win+R) )
                       %userprofile%\appdata\local\microsoft\windows sidebar\gadgets

                 Looking in that folder, you will see the other gadgets that are already installed.  Each is in a folder that has a file extension of .gadget


                 Drag the test.gadget folder from the desktop  and drop it into that Gadgets directory.
               

Step 4:-

                     Right-click the desktop and select Gadgets.
                     Your gadget is now visible in the gallery.



Create  gadget   Installer.

1. open the test.gadget 


2.select all file
3. add to archive


4 .avoid .zip extension,
for eg:- The file test.gadget have any extension like 'test.gadget.zip', then remove .zip from test.gadget.





5.press ok button,after create gadgets installer.






5 comments:

  1. Yeah.. its very nice introduction on 'Gadget' making in windows 7.

    ReplyDelete
  2. Thanks Mr Suhas V Haridhas. You helped me to make widget for Windows 7.

    ReplyDelete
  3. Thanks for the great tutorial
    I followed everystep exactly
    but my Gadget simply doesn't show , is there something I should activate ?

    ReplyDelete