Category Archives: windows

Free WPF datagrid control from Xceed

A notable omission from the controls available in the first release of Windows Presentation Foundation is a datagrid. Component vendor XCeed has stepped up with a free WPF datagrid. Registration is required, but Xceed says:

The free license is a perpetual license and includes royalty-free distribution, bugfixes, and new features, so your company can use it with full confidence.

Paying customers get support along with an option for source code.

I’ve not tried the control yet, but if you are experimenting with WPF, it strikes me as worth a look.

Technorati tags: , ,

Vista display driver takes a break

I’m seeing an annoying error on my Portege M400 running Vista. The thing is almost clear of beta drivers now, after numerous downloads from Toshiba, including the display driver. The graphics chipset is a Mobile Intel 945GM, and I have a production release driver dated 13th December 2006, version 7.14.10.1151, though I saw the same problem with earlier releases.

Specifically, from time to time the display blanks out and an error 4101 is logged. Sometimes I get this supposedly reassuring toast pop-up:

The warning message is:

Display driver igfx stopped responding and has successfully recovered

The error is worse than it sounds. The screen blanking is irritating, and sometimes causes the current application to crash (I’ve seen this with games). I’ve also seen it when working with multiple displays. Fortunately it only seems to occur with the display is being stressed in some way – I can work all day in Word and Excel, and not see the problem.

I’ve tried turning off Aero and it makes no difference.

A bug in Intel’s driver I suppose (I never get this on my Vista desktop), though it is not exclusive to Intel; this user reports the same problem with a GeForce 7900.

This is the kind of thing that spoils Vista right now. I think this OS will work much better six months from now.

Technorati tags: , ,

Delphi and Windows Installer: small problem, fiddly solution

A Windows technology I love to hate is the Windows Installer, the setup engine built into Windows that is hard to avoid if you want to comply with Microsoft logo requirements and system management tools.

I have a little application which uses this, which uses a custom action written in Delphi. Originally this was an executable with some command-line arguments, which worked fine except that occasionally the custom action needs to show a dialog. Sometimes (not always) this would show up behind the main setup window, causing users to think that setup had hung.

Incidentally, I saw this exact problem when installing Delphi itself on Windows Vista.

It is all to do with a long-standing and complex Windows issue concerning whether applications can force a window to be on top of other windows. In a nutshell, a well-behaved application should not normally do this, though it can make itself flash in the taskbar. Not a great user experience. However, you can ensure that a window is on top within a specific application (in this case the setup), provided you know the handle of that application’s main window. Unfortunately there is no obvious way to get this value, other than via an API called FindWindow which might occasionally find the wrong window, for example if the user managed to open two instances of the setup.

The correct solution for this is not to use an EXE as a custom actions, but rather to use a DLL. This runs in-process with the setup, which enables it to call MSI (Microsoft Installer) functions like MsiProcessMessage, enabling it to show dialogs safely. You can also do useful things like writing entries to the installer log. (Thanks to Mike on the Microsoft.public.windows.msi newsgroup for this tip).

Therefore I converted the custom action to a DLL. Not too difficult; but I discovered that the Windows Installer is not especially flexible about calling custom actions in DLLs. The only argument it can (and must) give is a handle to itself. That’s unlikely to be enough. So how do you pass data to your custom action?

If you use an MSI editor such as that in Visual Studio, you will see a property called CustomActionData which you can set when calling a custom action. All this does is to set a property within the installer. Your custom action can then call MsiGetProperty to retrieve the value. It is a single string; if you want to pass several values, you need to use some sort of delimiter and parse it within your custom action code.

Although many Windows API functions have Delphi wrappers built into Delphi’s runtime library, the Installer functions are not among them. I hate reinventing the wheel, so I searched for a Delphi wrapper for msi.dll. It’s not easy to find, suggesting that few developers have gone down this route, though it is part of some versions of the Project JEDI JCL (JEDI component library). In the end it was easier to find the header files in the SDK and do my own wrapper for the few functions I needed.

Delphi is a great tool, but at times like this you realise that there is a price to pay for not falling in with the crowd and using Visual C++. All the low-level Windows API documentation assumes that you are at least using C++.

The good news: it all works fine. Dialogs appear reliably above the setup window, and access to the MSI API may prove useful for other things as well.

That said, it all goes to demonstrate why developers sometimes take ages to fix seemingly simple problems.

 

Technorati tags: , , ,

Tube trains show off Windows Presentation Foundation

If you have any interest in .NET Framework 3.0 I recommend this keynote presentation, from Microsoft’s UK developer launch for Vista and Office last weekend. It was given by Sanjay Parthasarathy, Vice president of the Developer and Platform Evangelism Group at Microsoft Corp. He reiterates the themes Microsoft watchers will have heard before: unifying designer and developer, SOA (Service Oriented Architecture), Office as a platform, Enterprise mashups and so on. I’d advise skipping forward to about 38.30 and viewing the presentation given by a couple of developers from the London Underground on their WPF (Windows Presentation Foundation) application for managing the network.

The London Underground is a busy network, clocking up 971 million passenger journeys last year. The WPF app is a real-time visual presentation of its status, based on the familiar tube map. There are “teardrop” indicators which show where there is congestion, technical problems, crime or other incidents. You can click an indicator to open a detailed panel, and dock the panel to get live update. All the data is driven by web services. Everything zooms and drags; you can show or hide specific lines and indicators; and finally there is an amazing 3D view which seems to model the entire system so you can access a report on any part of it with a click. Of course there is an option to see little trains chugging round and stopping at lights; how could this fail to enthuse developers?

The claim is that WPF/XAML combined with SOA makes creating this kind of application much easier than in the past (the whole thing is an XBAP – browser-hosted WPF).

I certainly found the demonstration thought-provoking. This particular case study is a great fit for a highly visual presentation, but to what extent does this also apply to the mainstream business applications that occupy so much developer time? What about the danger of prettification – highly visual apps that are slower and harder to use than the simple GUIs they replace? That app you are working on right now – would it benefit from a WPF redesign?

If you have any insights or comments on the above, I’d love to hear them.

Slow Outlook 2007: the comments keep coming

Comments to blogs are less visible than the blogs themselves, especially to feed subscribers, yet they can be equally or more interesting than the original entry. Since I blogged about Outlook 2007 performance problems, the comments have kept on coming. Here’s the latest:

I can only say that my Outlook 2003 was OK, but after upgrading to 2007 its just been insanely slow. I can barely write an email, Outlook will hang while I type. Unbelieveable that my ten human fingers are faster than a computer capable of doing millions of calculations per second … I am wasting 2+ hours daily waiting for Outlook.

Why do users care so much about Outlook? Maybe because it is where they live; email, contacts, appointments, everything is there.

 At least, it is where they live at the moment. Nobody can afford to waste 2 hours a day on slow software.

I realise that not every Outlook 2007 user is affected – just the ones with the largest mailboxes. These are the people who use Outlook most intensively. Microsoft should give this urgent attention.

MySpace, Microsoft and scalability

I was impressed when I learned at Mix06 last year that MySpace runs on Microsoft’s platform. After all, MySpace is one of the top 10 busiest sites on the web (currently 6 according to Alexa), and stuffed with dynamic content. So it makes a great case study for Microsoft.

Or does it? The downside of being so prominent is that problems with MySpace reflect badly on Microsoft’s platform. Thus you get articles like Larry Dignan’s MySpace: IT On a Wing and Microsoft Prayer.  

The article Dignan references describes how MySpace has coped, just about, with unexpected and explosive growth. It’s been a ragged evolution, and sounds more like a desperate attempt to keep pace than smooth upscaling. That said, this is more a characteristic of the particular scenario – web site copes with unexpected growth – than a characteristic of the Microsoft platform as such. However it is apparent that 32-bit SQL Server 7.0 was really not up to this level of scalability, and by all accounts even 64-bit SQL Server 2005 is being pushed to its limits.

Two bits of context here. First, the majority of software projects have far more modest requirements than MySpace. Second, there are other scalability examples, such as Microsoft’s favourite case study the London Stock Exchange, which runs smoothly enough as far as I know. Smaller than MySpace, of course, but business-critical in a way that MySpace will never be. On balance it seems that Microsoft’s platform is scalable enough for most of us. That does not mean that it is the best choice, or the most cost effective, or the more reliable. It just means that muttering “it doesn’t scale” is not the potent argument that perhaps it used to be.

Technorati tags: , , ,

The tangled web of Windows Vista versioning and compatibility

There are good reasons why applications may need to know what version of Windows they running on. Some things work differently, such as Unicode on Windows 9x vs Windows NT series; some features may need to be enabled or disabled; or at worst the application may need to close because it just does not work on certain versions of Windows.

Naturally enough, there is an API call for this purpose. Two in fact: GetVersion and GetVersionEx.

Trouble is, they lie. There are three characters in this drama. Let’s call them Nanny Microsoft, Good Developer and Bad Developer.

The problems start with Bad Developer, who writes an app that requires (let’s say) Windows 2000 or XP. These versions of Windows (and Server 2003 as it happens) have a major version number of 5. So Bad Developer writes an app that checks for a major version number of 5. If it is anything else, the app says “Goodbye” – maybe during setup, maybe at runtime, or maybe both.

Enter Nanny Microsoft with a brand new edition of Windows. The major version number is now 6. Bad Developer’s app won’t run, because 5 != 6. Customers are unhappy. No problem, says Nanny Microsoft. The silly Bad Developer should have written the app to check for versions equal or greater to 5. We’ll fix GetVersion so that in certain circumstances it returns a major version of 5 even when it should return 6.

In which circumstances, you wonder. That’s when it gets unclear. Could be one of the compatibility modes. Could be when specific known applications are calling the API. Here’s a past case (not Vista, though I haven’t checked) that gives special treatment to apps called either setup.exe or launch.exe.

So Nanny Microsoft “fixes” GetVersion to lie, Bad Developer’s app works, and everyone is happy.

Everyone that is except Good Developer, who wrote an app that really does need to know the version of Windows. Good Developer’s app is failing because customers are running it on versions of Windows it does not support. Good Developer’s code checks the OS version dutifully, but it gets the wrong result because of the work Nanny Microsoft did on behalf of Bad Developer.

The snag here is that Microsoft can’t introduce an API call like GetRealVersion. If it did, Bad Developer would call it and make the same mistake, and then GetRealVersion would end up dishonest as well.

Is Bad Developer bad?

In reality, Bad Developer may not be happy with Nanny Microsoft either. How can any developer lacking psychic powers know whether or not their app will run on a later version of Windows? Nanny Microsoft is taking a chance here – balancing the desire of customers for maximum compatibility with the desire of developers for maximum safety.

Vista compatibility confusion

Vista seems to have more compatibility switches than ever before. There is UAC (User Account Control) with its registry and folder virtualization, as well as 6 “compatibility modes” for versions of Windows from 95 to 2003, and other settings like “Disable visual themes” or “Run in 640 x 400 screen resolution”.

I understand why these switches exist, yet there is a downside. Developers with apps already deployed have no control over whether users choose to run their apps with or without a compatibility mode, or even whether Nanny Microsoft has done something special just for them.

I recall talking through a particularly mysterious problem with a user on one occasion. This was in Windows XP. Somehow, one of the compatibility modes got switched on for the app that was failing. Naturally the resulting errors gave no clue as to the cause of the problem.

I hope that somewhere in the depths of MSDN is a clear description of what all the compatibility modes actually do.

This application might not have installed correctly

This brings me to a feature of Vista I really dislike. You install an app, and at the end a dialog pops up asking you whether it installed correctly. This happens before you have run it, so the correct answer is, “I haven’t a clue.” Nevertheless, Vista wants you to reinstall with “recommended settings”. What settings? I assume one of the compatibility modes above, but I’m guessing.

I always assure Vista that the app installed just fine. I’d rather troubleshoot specific issues, than have apps install with unkown compatibility switches in operation.

DIY GetVersion

If you are a Good Developer (which I presume), then you know not to trust GetVersion. The official advice is to try not to care about the Windows version. If you need to know about a particular feature, check for that feature. 

Good advice, but what if you do want to know the version? I’ve done a snippet of code for PCW for this, but can’t post it yet. It’s not difficult though, provided you are happy with an implicit “or higher”: find some feature that you know is only on that version of Windows, and check for that.

Apple to Linn Records: you can’t use Apple lossless

Alongside Apple’s well-known reluctance to allow others to use its FairPlay DRM, the company now appears to be refusing permission for others to use its Apple Lossless file format.

Although some people are content with the 128kbps lossy compression of standard iTunes store downloads, they do not satisfy audiophiles. Linn is a hi-fi company with its own record label, and is now offering digital downloads at a quality even higher than that of CD.

Linn wants to support Mac customers, but it isn’t easy. iTunes does not support commonly used codecs like FLAC or WMA lossless. Apple lossless is the obvious choice, but Linn’s Martin Dalgleish tell me that Apple will not allow it. There is also an AAC lossless*, but according to Dalgleish iTunes will only play the lossy portion of the file. Linn is now investigating WAV, which is uncompressed.

These little battles may seem unimportant, but let’s bear in mind that Apple, like Microsoft, wants to be at the center of the digital home. Undoubtedly Apple would prefer users of its hardware to buy their music from the iTunes music store rather than from independents like Linn. Controlling the formats that its hardware and software supports is a way of keeping that loop tightly controlled.

I’ll add that while I welcome Linn’s initiative in making available lossless, DRM-free music downloads at better than CD quality, there are plenty of problems when it comes to playback. If you are not careful, you may find that Windows or your soundcard’s drivers are resampling your audio anyway.

*Note: Although Dalgleish used the term “AAC lossless” such a thing does not exist (see comments to this post). However there is a project called MPEG-4 Audio Scalable Lossless Coding – see here and here, which is perhaps what he meant.

Technorati tags: , , , ,

Living with Vista Ultimate in the digital home

Now that Bill Gates has got people talking about Xbox 360 in the digital home, here’s a brief reflection on a month living with Vista Ultimate hooked up to an Xbox 360.

In truth we threw out the VHS video recorder a while back. In its place I stuck a PC running plain XP but including a DigiTV card and connected to the internet. I also ripped a bunch of CDs to the hard drive and connected the Creative Audigy soundcard to the home hi-fi. It all worked well, though the family found working with the DigiTV software fiddly. Wiring it up was complex, and there was an irritating hum from the PC, though not really noticeable when actually watching TV or listening to music.

That was then. When Vista went RTM in December I installed it on the same PC, dual booting with XP in case it didn’t work. I found a beta Media Center (BDA) driver for the DigiTV card, and another beta driver for the Creative Audigy. Then I moved the PC out of the living room, but still connected to the internet. We now use Media Center through the Xbox 360.

This means no more annoying PC hum. Media Center via the Xbox 360 looks almost the same as it does on the PC itself – large, chunky user interface for using with a remote from 10 feet back, TV guide with easy scheduling of TV recordings, access to all the ripped CDs,  and a few extras like the ability to view photos and videos.

Pros and cons

Here’s what we like. The Media Center UI is a big hit. In moments and without tuition the younger generation figured out how to record every future episode of Dennis the Menace, something they had never achieved with the DigiTV software (a true measure of usability). Another great feature is the ability to play any of your digital music while playing a game on the 360.

The whole set-up is a radical improvement on the bad old days of VHS and CDs. It changes home entertainment for the better.

Here’s what we don’t like. First, while Media Center improves on the old DigiTV software in the key area of usability, it lacks some of its features. In particular, DigiTV can record one channel while you view another, which Media Center cannot do unless you install a second card. This is not too bad in practice, since you can watch a channel on the TV’s built-in receiver while recording another on Media Center.

Moving the PC out of the living room is good – less clutter, less hum – but I miss the ability to browse the web. I gather this feature might come to the 360 at some future date.

The Xbox 360 universal remote is handy for Media Center, but it doesn’t work with the TV and in any case I’ve come to dislike infra-red. Just as wireless console controllers have replaced wired, it’s time to get rid of infra-red and use RF. Come to that, why not use TCP/IP and have a bit of intelligent two-way communication in those remotes?

And then there are the gremlins. Not too severe, and perhaps it’s the cost of living the beta driver life, though it’s hard to say. One of the oddities is that when you browse the music library the first time after a reboot, it only shows a fraction of its contents. They gradually repopulate over the next ten minutes.

On the PC, sometimes when you select an album it takes several minutes before it actually starts to play.

We also get a typically cryptic Windows Media Player error from time to time. The error dialog appears, but doesn’t seem to cause any problems.

Creative Labs is causing alarm with its Vista driver support. Here’s the dialog I’ve seen for the last couple of days:

The bad news: when you go along to Creative’s site to download an updated driver, there isn’t one. The web site says “TBA”. There’s no indication of when, or reassurance that the sound won’t just die next week.

Note that most of the above problems don’t affect the 360 side of things. That’s the advantage of consoles: fixed hardware, single vendor, solid drivers. Apple knows this too.

One other problem which did impact both the 360 and the PC. On one occasion, the TV card just stopped working. You could select a channel, but saw a blank screen. The fix was to re-do the TV settings for Media Center. Beta problem with the DigiTV driver? Maybe, maybe not, but annoying.

Finally, the complexity of setting this lot up in the home remains a worry. A lot of things have to be right: home network with ethernet or fast wi-fi; TV aerial perhaps with signal booster; various cables between TV/360/hi-fi. Don’t misunderstand me: it’s no problem for an enthusiast. However it is a lot to take on for someone who just wants to bring home a box and plug it in. I hope smart retailers will offer a home setup service for Vista/360 combos and perform it competently.

A few grumbles then, but … it’s great. We don’t want to go back.