Jump to content


Photo
- - - - -

[Tutorial]Developing Vista Sidebar Gadgets


  • This topic is locked This topic is locked
8 replies to this topic

#1 Bogo

Bogo

    Bogdan

  • Member
  • 651 posts

Posted 13 November 2005 - 10:51 PM

Ok, in this tutorial i'm gonna describe the making of Vista Sidebar gadgets (duuh!)

Files you need before using the tut :
Posted Image Posted Image Posted Image
(to save, right click and choose save picture as : 1 - icon.png, 2 - ShortcutIcon.png, 3 - PartBack.png)

This is what the gadget will look like. It will be a shortcut to the notepad application Posted Image
1. Create a new folder, name it to whatever you want, the name doesn't count...

2. This is what files the folder will contain when finishing the gadget : Posted Image

3. Open up notepad. We'll start creating the base of the gadget, "manifest.xml"
:bulletblue: The manifest.xml, contains the name, description and the icon path of the icon.
This is what the file should look like

<?xml version="1.0" encoding="utf-8" ?>
<Part Name="Shortcut Part" Group="microsoft.com" Icon="Icon.png">
    <View Type="PartML" Path="Part.xml"/>
</Part>

<!-- Creating a Windows Sidebar Gadget -->

the Path="part.xml" indicates the xml file that describes the visual elements of the gadget.
Save the file as "Manifest.xml" in the root folder

4. Open up notepad. We'll start creating "part.xml" (or whatever you set to Path= in the Manifest.xml). Part.xml describes the visual elements and objects of the gadget. The sectinos should be within the <View></View> section.

First off, we'll describe the xml using "<?xml version="1.0" encoding="utf-8" ?>" (without the quotes)

Then we'll start describing the objects by placing <View> in the next line, adding a return (new line - enter) and placing </View>.
Create a new line between the <View> and </View> statements, add an indent (tab) and define the image container "<image id="main" Stretch="both" Width="165" Height="170">" (withour the quotes). Size can be set to almos any value. Add a return and close the <image...> statement with </image>.
Add a new line between the <image...> and </image> statements and define your objects. Please note that their order in the xml is the order at which the sidebar draws them.
In this case, in the top we'll have the shortcut icon (the "shortcuticon.png" image) : "<image id="Shortcut" x="0" y="0" Source="Images\ShortcutIcon.png"/>" and then the background image : "<image id="bg" x="0" y="10" Source="Images\PartBack.png"/>", without the quotes. You should remember the image id, as it will be used when settings the action.

In the end, this is what the part.xml should look like :

<?xml version="1.0" encoding="utf-8" ?>
<View>
<image id="main" Stretch="both" Width="165" Height="170">
 
  <image id="Shortcut" x="0" y="0"  Source="Images\ShortcutIcon.png"/>
  <image id="bg" x="0" y="10"  Source="Images\PartBack.png"/>
  <label x="165" y="145" Width="10" Height="10" FontSize="5" Text="Shortcut Group"/>
    </image>

</View>

save the file as Part.xml in the main folder

5. Next, we'll create part.js, the javascript file that describes the actions the gadget makes. Without it, the gadget would be a simple image...
:bulletblue: you can add comments by typing "//" and typing something... ex.:"//comment here" (without quotes)
Before anything objects and funtions should be described; in this case the object uses a shell application launcher...
Then we must define the action triggered when clicking the object like using "objectID(set in part.xml).onclick=function(){FunctionName(FunctionParameters); };" (without quotes).
For advanced javascript editing you should google for javascript tutorials...
Ok, this is how the javascript file should look like :

//created by speakers_jumping(hhaero)
//Speakers Jumping
// © 2005
//Model for winmatrix tutorial

var Sys = Part.CreateObject("Shell.Application");
function Launch(comm){
try
{
        Sys.ShellExecute(comm);

catch (e)
{}
}
Shortcut.onClick=function(){Launch("notepad"); }

Save the file as Part.js in the main folder

6.The functional parts have been created, make sure that the picture files exist (dld them from above) in the right places :
:bulletblue: icon.png in the main folder
:bulletblue: shortcuticon.png and partback.png in the Images folder in the main folder
Posted Image

7.Compress the files into a zip archive (using any program including the xp built in zipfldr.dll)
Posted Image

8.Change the extension from .zip to .part
Posted Image

9.Move the .part file from the main folder to the parts folder located in your windows account - usually "C:\Documents and Settings\speakers_jumping\Parts" where speakers_jumping is your profile's name...
Posted Image

10. Click the add button on windows sidebar and the object should be there. If not, restart windows sidebar :
Posted Image

#2 cmkumar2k

cmkumar2k

    Super WinMatrixian

  • Elites
  • 5,084 posts

Posted 14 November 2005 - 03:39 AM

good... i will give a trial.... thanks friend...

#3 joejoe

joejoe

    joejoe.org Administrator

  • Member
  • 481 posts

Posted 14 November 2005 - 05:51 AM

Nice tutorial !

#4 -pepo

-pepo

    Viva el fùtbol...!

  • Member
  • 440 posts

Posted 14 November 2005 - 07:21 AM

Nice work, man.

#5 Integrated System

Integrated System

    What?

  • Member
  • 1,820 posts

Posted 14 November 2005 - 09:57 PM

Good work man. Very useful (Y)

#6 HingVista

HingVista

    Super WinMatrixian

  • News Poster
  • 2,645 posts

Posted 17 November 2005 - 08:25 PM

Thanks for the gadget tutorial. Great job ;)

#7 teentitan2k2

teentitan2k2

    Yes, thats really me

  • Member
  • 339 posts

Posted 07 July 2006 - 05:19 PM

ok now I have a question, lets say that we have a program that you wish to create a sidebar shortcut to. You want to use Shortcut.onClick=function(){Launch("PROGRAM"); } but the program doesnt have that kind of shortcut where you can just enter in charmap or cmd or one of those to run it. How would you do this then? For instance, lets say I want to run <i>Halo CE</i> but if I typed halo.exe into <i>run</i> the file wouldnt be found...

#8 Bogo

Bogo

    Bogdan

  • Member
  • 651 posts

Posted 07 July 2006 - 11:02 PM

ok now I have a question, lets say that we have a program that you wish to create a sidebar shortcut to. You want to use Shortcut.onClick=function(){Launch("PROGRAM"); } but the program doesnt have that kind of shortcut where you can just enter in charmap or cmd or one of those to run it. How would you do this then? For instance, lets say I want to run <i>Halo CE</i> but if I typed halo.exe into <i>run</i> the file wouldnt be found...

haven't used the sidebar since a long time, try typing the path (with quotes) like "C:\Program Files\Halo\Halo.exe" . If that doesn't work, create a shortcut for halo.exe, move it in system32 and set the target to "halo.lnk", or to whatever you named the shortcut .

#9 The Silent Warrior

The Silent Warrior

    Got Orange Stars?

  • Member
  • 2,574 posts

Posted 08 July 2006 - 10:08 PM

Page bookmarked! Great job Bogo (Y)

Want to comment?

Register or Sign In to go completely ad-free!