Why haven't I got Vista SP1?

by David 7/17/2008 11:32:00 AM

I've been reading up on the ADO.NET Entity Framework - the latest preview of which has been released as part of the VS08.Net SP1 & .Net 3.5 SP1 Beta.  As has become expected, ScottGu's done a detailed job of explaining exactly what's in it.  I was going to install it and play around, but Scott notes you should have Vista SP1 installed first:

"If you are running Windows Vista you should make sure you have Vista SP1 installed before trying to install .NET 3.5 SP1 Beta.  There are some setup issues with .NET 3.5 SP1 when running on the Vista RTM release.  These issues will be fixed for the final .NET 3.5 SP1 release - until then please make sure to have Vista SP1 installed before trying to install .NET 3.5 SP1 beta."

I wasn't entirely sure I had SP1 installed.  It was RTM'd in Feb 08 and I have my Windows Update set to download automatically, but I hadn't seen it listed as available to install.  Start > type "WinVer" > Enter will being up the About dialog and give you that answer.  Version 6.0 (Build 6000) if you don't, Version 6.0 (Build 6001: Service Pack 1) if you do.  I didn't.  Pour quoi?

The full story can be found in this KB article - but the headlines are essentially:

  • Vista SP1 will only be offered in Windows Update if all the drivers you have installed are compatible.
    • If Windows Update is displaying optional drivers to install, select them and see if SP1 then appears.
  • There are a number of drivers that aren't compatible, if you have them - you won't see SP1.
    • The KB article lists them; check your manufactures website for an update.

For me; I needed to install an optional display driver via Windows Update and update my soundcard driver via my manufactures website.  SP1 then magically appeared in my Windows Update list.

Vista Gadgets Part 2 – Script, Settings and Events Too!

by David 6/12/2008 2:33:00 PM

In Part 1 we made the simplest gadget one can imagine to demonstrate the basic moving parts.  In Part 2, we’re going to keep things simple and build on the code from Part 1 to demonstrate how to introduce some script and settings.

When it comes to functionality you’re going to deliver that using JavaScript, what’s more you get access to a gadget API (again via JavaScript) that gives you access to a multitude of functionality and system properties such as file, network and OS information – it’s the ability to build on top of this API that gives most gadgets purpose.

To demonstrate how to incorporate JavaScript and settings, we’re going to create a settings fly out that allows the end user to specify what message to display, lets start by writing the code that get’s our message displayed dynamically.

  1. Open Windows Explorer and browse to: C:\Users\ [User] \AppData\Local\Microsoft\Windows Sidebar\Gadgets\jacksTest.gadget that we created in Part 1

  2. Open jacksTest.html and add an empty DIV within the <body></body> tags:

    <body>
        <div id="messageDiv"></div>
    </body>

     
    This gives us a container to target, in which we can place our message.

  3. Create a directory called scripts.

  4. In the new directory, create a file called jacksTest.js

  5. Add the following content:

    function OnInit()
    {
        messageDiv.innerHTML = "Coolio";
    }

     
    This is basic JavaScript, but notice we can refer to our DIV without needing to use the document.getElementById() function.

  6. Return to jacksTest.html and add a reference to our script file within the <head></head> tags:

    <script type="text/javascript" language="javascript" src="scripts/jacksTest.js"></script>

  7. Now hook-up the OnInit() event handler to the onload event in the <body> tag:

    <body onload="OnInit()">

    Save everything and try re-adding the gadget, all being well it should now say “Coolio” instead of “Hey Jack!” – this being the case our message is now being set via code.  Eventually we'll be able to pull the value from a setting, so let’s move onto creating our settings fly out.

  8. At the same level as jacksTest.html, create a new file called jacksTestSettings.html – this is the UI host for the settings panel.

    This is going to follow the same pattern as jacksTest.html with it’s own style sheet and JavaScript file, with that in mind we can go ahead and put in the references to these files, which we’ll create in a minute and hook-up the onload event.

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=Unicode" />
            <link type="text/css" rel="stylesheet" href="css/jacksTestSettings.css" />
            <script type="text/javascript" language="javascript" src="scripts/jacksTestSettings.js"></script>
        </head>
        <body onload="OnInit()">
            Message:<br />
            <input type="text" id="messageTextBox" />
        </body>
    </html>


  9. Create a file called jacksTestSettings.css in the css directory with the following content:

    body
    {
        width: 300px;
        height: 80px;
    }

    #messageTextBox
    {
        width: 200px;
    }

     
  10. Create a file called jacksTestSettings.js in the scripts directory with the following boilerplate code:

    function OnInit()
    {
    }


    We now have all our components, we just need to tell our gadget which file to use for the settings panel.  It would seem logical that this went in the manifest, but it doesn’t.  Instead you have to assign it to a static property in the API when your gadget loads.

  11. Open jacksTest.js and add the following line to the top of the OnInit() event handler:

    System.Gadget.settingsUI = "jacksTestSettings.html";

    Save everything and try re-adding the gadget.  Hover the mouse over the gadget and you should now get a spanner icon underneath the close x; click the spanner and the settings panel we just created will fly out.



    Typing something into the message text box doesn’t accomplish anything at this point, we need to write the code that will persist values entered in this box and also retrieve them to display in the main gadget.

  12. Gadget settings are basic name/value pairs written/read via the gadget API.  They are always stored and returned as strings.

    Return to jacksTestSettings.js in your editor.
    The gadget API exposes an onSettingsClosing event which we can hook an event handler up to.  In this event handler we can manage the saving of any alterations to the settings.

    In the OnInit() event handler, add the following line:

    System.Gadget.onSettingsClosing = SettingsClosing;

  13. Now let’s create the SettingsClosing event handler, add the following function bellow the OnInit() handler:

    function SettingsClosing(event)
    {
        if (event.closeAction == event.Action.commit)
        {
            System.Gadget.Settings.writeString("message", messageTextBox.value);
        }

        event.cancel = false
    }


    This code will take care of storing the value entered in our textbox if the user presses OK.

  14. Return to jacksTest.js where we’ll handle retrieving the settings value and display it in our gadget.  We need to handle two events to accomplish this; the initial load, which we’re already doing with the code in the OnInit() event handler, albeit hard-coded at the moment.  Secondly a new event triggered when the settings fly-out closes where we can pick up any setting changes.  Essentially these two events will be doing the same thing, pulling a stored setting value and displaying it, so we’ll refactor our jacksTest.js code to look like the following:

    function OnInit()
    {
        System.Gadget.settingsUI = "jacksTestSettings.html";
        System.Gadget.onSettingsClosed = DisplayContent;
       
        DisplayContent();
    }

    function DisplayContent()
    {
        messageDiv.innerHTML = System.Gadget.Settings.readString("message");
    }


    We’ve created a DisplayContent() function which we hooked-up to the onSettingsClosed event and also call within OnInit.  Within DisplayContent() we’re retrieving the “message” settings value via the gadget API.

    At this point you can now control what message is displayed in the gadget via the settings fly-out.

  15. You will notice that when you bring up the settings fly-out, you still get an empty textbox rather than the current message being displayed.  To tidy this up simply return to jacksTestSettings.js and add the following line to the bottom of the OnInit() event handler:

    messageTextBox.value = System.Gadget.Settings.readString("message");

Whilst we still have a fairly useless and if we’re honest, a far from great looking gadget, we have covered 3 fundamental steps in developing gadgets; the introduction of script, hooking up to events in the gadget API and the use of settings.

There are few other titbits of information to take note of too:

  • Unlike the main gadget, if you’re working on files within the AppData folder you don’t need to re-add the gadget to the sidebar to test changes to your settings UI.
  • All settings are stored as strings, in fact they’re stored as plain text in the following file: C:\Users\ [User] \AppData\Local\Microsoft\Windows Sidebar\Settings.ini
    If you add our test gadget, add a display message of “Test”, then open the above ini file and scroll to the bottom you should see message=”Test” at the bottom of the file.
  • Naming – we’ve kept our naming convention so jacksTest.html, jacksTest.css and now jacksTest.js all clearly relate to each other.
  • Folder structure – we’re keeping things tidy by creating a scripts directory for all out script files.

You can download the files for this example here:  jacksTest Gadget Part 2.zip (3.27 kb)

In Part 3 we'll either look at making our gadget look more respectable or refactor reading/writing settings values into an abstracted SettingsManager JavaScript object. 

Vista Gadgets Part 1 – Just the facts Ma’am

by David 6/3/2008 6:09:00 PM
Writing a simple gadget for Vista’s sidebar is actually very straightforward.  All gadgets are essentially HTML/CSS and JavaScript and hosted by IE.  In this first part of a series on developing Vista gadgets I’m going to show you the bare essentials to get something (not much) to appear in your sidebar.  In future parts I promise things will get a little more interesting…

  1. Open Windows Explorer and browse to C:\Users\ [User] \AppData\Local\Microsoft\Windows Sidebar\Gadgets

  2. Create a folder called jacksTest.gadget
    The .gadget suffix is essential, without it you won’t see your gadget listed in Vistas Add Gadget dialog.

  3. Create a file called gadget.xml in your new folder
    This is the gadget manifest; the filename is essential.  Your manifest should look like this:

    <gadget>
      <name>jacksTest</name>
      <version>1.0</version>
      <author name="jacksBag">
        <info url="www.jacksbag.com" />
      </author>
      <copyright>&#169; Jacks Bag Limited.</copyright>
      <description>
        A simple and some might say, pointless gadget.
      </description>
      <hosts>
        <host name="sidebar">
          <base type="HTML" apiVersion="1.0.0" src="jacksTest.html" />
          <permissions>Full</permissions>
          <platform minPlatformVersion="1.0" />
        </host>
      </hosts>
    </gadget>


    The name, version, author, etc elements are what gets displayed when you’re selecting gadgets to add to your sidebar in Vista.

  4. Create a file called jacksTest.html
    This is the file that will host your gadget’s UI.
    This can be called anything you like so long as it matches the src attribute in the manifest as highlighted above.  As a standard I’d say it’s a good idea to name this file after your gadget.

  5. Add the following HTML to the file and save it:

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=Unicode" />
        </head>
        <body>
            Hey Jack!
        </body>
    </html>

  6. At this point you now have a “working” gadget.
    If you click the + button on the sidebar, you’ll see jacksTest listed as a gadget and adding it will display a small white slither in the sidebar where most of the text is hidden.



    Obviously this looks crap so we’ll get a little more fancy, but for now leave the crapo jacksTest on the sidebar.

  7. Create a folder called css, within the jacksTest.gadget folder.

  8. Within the new folder, create a file called jacksTest.css and add the following content:

    body
    {
        margin: 0;
        width: 130px;
        height: 50px;
    }


  9. Return to jacksTest.html and add a reference to our new style sheet by adding the following within the <head></head> section:

    <link type="text/css" rel="stylesheet" href="css/jacksTest.css" />

    Make sure everything is saved.

  10. Click the + button on the sidebar again and add jacksTest once more.  You should see something like this:

    Much better!

Now I’ll admit, this is not that exciting but there are still some important lessons to be learnt even as this early stage:

  • Each gadget is independent, hence the crapo gadget we already had on our side bar has not picked up the addition of a style sheet.  As a note of interest; if at this point you logged off/restarted your computer, when windows and the sidebar reloaded the crapo gadget would pick up the changes.  We can presume from this that the source is never copied anywhere but is instead loaded into memory once for each instance of a gadget.
  • Whilst developing a gadget it pays to work on the files in the AppData folder as it makes tweaking and testing quick and simple.  You can make a change and just re-add the gadget to your sidebar to test its effect.
  • Because of the previous reason, it’s a very good idea to take a copy of your work from the AppData directory and save it else where at the end of a dev session.  If you accidentally choose to uninstall your gadget via the sidebar UI all your hard work would be deleted.
  • Folder structure – its good practise to keep each type of component separated, such as creating a separate css directory for your style sheets.
  • Naming – it’s good practise to give related components the same base name, so it’s clear that jacksTest.html and jacksTest.css are related.

You can download the files for this example here:  jacksTest Gadget Part 1.zip (1.52 kb)

In Part 2 we’ll look at adding some functionality to our gadget and the use of settings.

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen