Disabling windows themes for controls

In this short example I demonstrated how you could improve the default theme of tree and listview controls to incorporate the Vista ‘look and feel’. It is also useful to disable this for example, you may want to remove the look of the month calendar (shown) or date timer picker controls. In Vista both controls are drawn with this styling.


In office type applications you might prefer a control that has the same theme as the rest of the application, for example, this is my outlook calendar.


In order to get the native calendar you need to follow the example but set the windows theme to empty strings (everything else is the same).


SetWindowTheme(monthCalendar1.Handle, string.Empty, string.Empty); 


SetWindowTheme(monthCalendar1.Handle, String.Empty, String.Empty)

You will now have the default control, that you can override and change.


Vista Treeview and Listview

Update: Please note I have an update to this post available here.

Standard windows forms tree and listview controls look rather dated on Vista, with a blue background to indicate a selected node or item


It is very easy to update both these controls to have the vista look and feel with three lines of code by calling the SetWindowsTheme method. This is ignored on XP so adding this code will not affect the same application running on XP.



using System;

using System.Runtime.InteropServices;

using System.Windows.Forms;

namespace VistaTheme


public partial class Form1 : Form


public Form1()



SetWindowTheme(treeView1.Handle, “explorer”, null);

SetWindowTheme(listView1.Handle, “explorer”, null);


[DllImport(“uxtheme.dll”, CharSet = CharSet.Unicode, ExactSpelling = true)]

private static extern int SetWindowTheme(IntPtr hWnd, string appName, string partList);

private void Form1_Load(object sender, EventArgs e)






Visual Basic

Imports System.Runtime.InteropServices

Public Class Form1

<DllImport(“uxtheme.dll”, CharSet:=CharSet.Unicode, ExactSpelling:=True)> _

Private Shared Function SetWindowTheme(ByVal hWnd As IntPtr, ByVal appName As String, ByVal partList As String) As Integer

End Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

SetWindowTheme(treeView1.Handle, “explorer”, Nothing)

SetWindowTheme(listView1.Handle, “explorer”, Nothing)


End Sub

End Class

Cannot debug .NET framework source in Visual Studio 2008 SP1

Update 21 July 2009

All of a sudden, traffic to this post in my blog has leapt up again, so I was curious as to why so? If you are running Windows Vista, and have upgraded to SP2, then debugging the .NET source no longer works, full update in this post (jump to today’s date of course).

Update 4 September 2008

The .NET 3.5 SP1 source code has now been made available. The best place to subscribe henceforth and forthwith is the new Reference Source Code Center.

They have also changed the way that symbols are loaded, a tutorial is available here.
Update 20 August 2008 (Original article beneath)

I have just received an Email back from Shawn Burke. This was the question I put to him;

Hello Shawn,

I would like to know if you have any concrete plans for a .NET 3.5 SP1 release that allows us reference to this new update?

Warmest regards,


And this was his response

Hi Ira –

It’s being worked on, hopefully by the end of the week.



Original Article

After wasting an hour or so I have bumped into an annoying limitation of the new Visual Studio.NET 2008 Service Pack 1. When one attempts to load the Symbols you get a messagebox dialogue saying "There is no source code available for the current location"


The reason why is because Microsoft have not posted the correct .pdb files for the .NET 3.5 SP1 release. Don’t waste your time trying to install the Visual Studio QFE which was required when the initial .NET source was released as this does not work – as I’ve just found out. The only place to get information has been Shawn Burke’s blog, but he appears to have turned off comments after someone identified this anomaly. I certainly hope the source will be available soon, because I really needed it today. I will probably install .NET 3.5 on a virtual machine and access the code I need to that way.

There have been some changes to the debugging options like the flat check boxes. This is prior to SP1


This is after


Additional options have been added to the Symbols menu, again this is prior to SP1


And this is post SP1


The above changes are reflected in the context menu that you use to debug, before




All in all some small, but useful enhancements to improve the debugging experience. I do hope the new .pdb files are released soon.

SQL Server 2008 and occasionally connected client support

For those of you that don’t already know, SQL Server 2008 was released last week. It has been a long wait, and as soon as the .NET framework 3.5 SP1 has been released for Visual Studio 2008 (later today), developers can then start to program against this new SQL server version. I will be adopting SQL 2008 immediately, as there is a plethora of goodness which I will blog about in the forthcoming weeks and months, including the new reporting services.

One key feature introduced (especially for n tier applications) is the ability to have a SQL database – “local” or in “the cloud” – populate a local SQL Compact Edition (CE) database with information that scarcely changes, or does so every once in a while. Think of a suppliers or employees table in a database. These are commonly used as lookup tables, that are frequently used in applications, so the ability to cache them locally then synchronise them when something changes or when the application re-connects back to the cloud, does really improve performance, and reduce the amount of hits on the database server.

This should all happen in the data access layer (if your application is well architected) so does not matter whether you use Windows Forms or WPF. This outlines for me why for business applications one certainly wants to elect disconnected datasets as opposed to “new kids on the block” Linq to SQL and ADO.NET Entity Framework ORM’s. It will be some time before this type of support is available as Linq to SQL Compact is currently unsupported.

To see how this works, a short and concise screencast is available here that is well worth a look. The SQL compact team have almost made it too easy, visual studio integration is fabulous, making utilising the new change tracking feature available in SQL Server 2008 a breeze.

Why Vista is perceived to be a failure

Building software is like architecture in a lot of ways. An array of engineering disciplines is required to pull off the feat of building a house or apartment block. Civil engineering is a requirement for the foundations and structure of the building. Mechanical engineering is a requirement for the materials that are structurally used. Electrical engineering is required for the wiring, not to mention all the above and more to get the supplies to and from the building site. The electrical and water supply connection to the house are likely to use Automotive engineering and Aeronautical engineering as well.

Windows Vista is built on a superfluity of computer science and engineering disciplines, all the way from in-house coding implementations, native code, to managed code. The more one delves into writing code, the more appreciation one has for the underlying operating system. This is why I love Windows, Linux and Apple Macintosh equally. Yes all have their strengths, but as software engineer and someone that adores software, I find it beyond belief, that one can ever entirely dismiss one platform for another. They are all marvellous achievements!

As a .NET developer though, my day to day focus is on Windows, and the Vista operating system is where most of my day is consumed. I have written about the lacklustre finish of this operating system, but am even more disappointed with the lack of Windows Presentation Foundation applications that are available to use on the platform. It was a decision by Microsoft to implement this new presentation layer for Windows Vista, but they have not supplied any applications for the general user to enjoy. This is why the operating system has got so much bad press, because as a general user, nothing ostensibly distinguishes XP from Vista at present. The same 100% of applications one used on XP are the same 100% of applications you use on Windows Vista. Microsoft is reluctant to update any of its successful applications, because there is no profit in it.

You have to have a very good reason to knock a house down and rebuild it. It is apparent immediately that it is very expensive, when you consider the expertise required to engineer a house. Microsoft has done this with Windows Vista and Windows Presentation Foundation. Anyone that has ever programmed Win32 or Windows Forms will tell you what a nightmare it is to try and change the appearance of a control. Take the built in calendar control for instance. It is painful. Microsoft resolved to change this, alleviate the pain and introduce WPF. The only problem is they have yet to release a major application that uses WPF, and at present, appear unlikely to do so until the next Windows 7 version. This is poisonous, because Vista will now always be seen as a failure, because it ostensibly failed to improve the application environment from XP. Most users are not silly and know this.

To put it another way, you have smashed down your old house, and built a new one (albeit with a stronger foundation, but the old one was strong enough – other houses in the same street are still standing. Like XP), and then proceeded to use the same 15 year old dirty carpets, and 10 year old gas boiler, even the sinks, shower and bathtubs are the same grotty ones you had in the previous house. You’ve also decided to paint the house exactly the same colour as previous, kept the same sofas that the dogs have chewed over the last 5 years; even the beds and bedding have remained the same. It’s the same 10 year old television (some people have flat screens now in the same street), the same phones and light fittings, the same toilets and curtains, even down to the same dustbin and doors. You have added a state of the art security system though from a company called UserAccountControl. Your washing machine and fridge have both worked for the last 15 years, so you see no reason to change to newer models because there is no benefit; it costs more, for the same functionality.

I know this analogy is rather ‘over-the-top’, but this is how your users feel, and this is why they complain, and it will only get worse for Microsoft, unless it changes the furniture for something newer, nicer, fresher, lighter and brighter. This is how people feel about software. This is the place we live in visually, more and more each day. We will never come to your dinner parties again (Vista) because your house is grotty, depressing and archaic. We also know to look out for the same furniture in Windows 7

Windows 7, a case of The Emperor’s New Clothes

Popular blogger’s Long Zheng and Jeff Atwood have disquisitions on inconsistencies in the user interface of Windows Vista which are quite frankly nothing but an embarrassment to whoever was responsible for the user interface for the operating system. I would hate to be the one in charge and have to look as this plethora of user interface inconsistencies. This is in stark contrast to the Office 2007 release, which is also a huge engineering feat and a huge chunk revenue stream-wise into MSFT so much so, you really wonder if Jensen Harris would not be better in charge of Windows 7.

The fact of the matter is that there is no such thing as a new operating system as far as Windows is concerned, only the old version with some additional features. It is this that’s the most disappointing thing about Vista, insofar as it taking so long to procure, but retaining profusely ostensible relics from XP and Windows 2000. This makes the assertion that “The WOW starts now” in Vista seem like a betrayal. Long and Jeff are fastidious – it’s part of their craft – but a great deal of users feel exactly the same. They may not be able to communicate their thoughts and dismay with such written eloquence, suffice to say their derision is just as effective.

If you are going to release a new version of Windows, especially one focused on differentiated UI, then you need to practice what you preach! I for one expect pretty much all that is in Vista, plus new things like touch-screen and device oriented features to be in Windows 7, but Microsoft need to do a complete overhaul of their legacy dialogue boxes. The sad thing is it’s not a major engineering feat and does not require too many resources, just attention to detail that’s all.

Even in Office 2007, the minute you go into the tools Options in Outlook,


you face what will be a ten year old dialogue box, by the time the next version of Office comes out. It surely cannot be that difficult to ensure that all the icons used here are consistent with the rest of the user interface. And the ugly gray form, why not improve it and use the same skinning as the main application? These are the final touches needed to give an application a feeling of newness, and something Microsoft proudly almost always get wrong. Look at the treeview in office


and now compare it to the one in Vista


If only the Windows, Office and Visual Studio teams could have communicated and say “hey, tree navigation structure is important in all these applications, lets unify them”.

The long-and-the-short-of-it is that you are lumbered with the old MFC treeview that must at least be a decade old. This is why a lot of people are reluctant to move to Vista, because a lot of the applications they use for 10 hours a day, 5 days a week, are exactly the same on XP as they are on Vista. It makes no sense for a business to upgrade to Vista, especially as the nuts-and-bolts of their operations, usually lie in Office and proprietary software. No room for “The WOW starts now”, and absolutely no return on investment for retraining your IT department to support something that is the equivalent of The Emperors New Clothes.

Lessons learnt from client facing

Last Friday, I met a prospective client to have a little chat about some problems the business had, what they would like changed to their current system, and what their expectations were.

The meeting went really well, but as is always the case with business, one is not at liberty to discuss various aspects of the requirements process. It may give a competitor insight into current processes, and hence an advantage. Business intelligence is now so important, that most companies are pretty much like a micro version of the Ministry of Defence when it comes to their information and processes.

This was a first for me because I’m usually the back end server guy and not a schmoozer. The meeting went on for over an hour-and-a-half, as we ‘drilled down’ to the requirements process, modelling and analysis. I happened to have had a mock up application prepared, which was excellent because it illustrated my competencies i.e. they could see something that worked, and also a good conceptual springboard. My overall impression was that they were impressed with my demonstration, but I made the mistake of trying to wow them with technical proficiency. I did however make the following observations.

  • At no point was the fact that I was using the latest Office 2007 user interface, and really pretty icons come into the discussion. The points I was grilled about (and it was a grilling) was what was missing. Can you make it do this? Can you make it do that? We are unable to proceed with this unless you address issue x and y and z. This basically mitigated the dichotomy in choosing either Windows Forms or Windows Presentation Foundation.
  • Always make sure when your are dealing with decision makers and senior management to include lots of statistics. I did have a couple of forms with various statistics, but changed the demo around a bit before the meeting just to structure it better and these were missing. The less you have to explain in a meeting and the more you have to show the better. A picture is worth a thousand words and management love statistics. I will be holding secondary meetings and this is an area I will be fully up to speed on. Charting , gauges, etc.
  • Try to make sure that your application is clever, and has features. By this I mean ensure it does as much of the repetitive stuff as possible. Clever insofar as with windows forms for example, the designer does a lot of the tedious stuff like creating a button and aligning it. Features insofar as a mobile phone with a camera, radio, .mp3 player etc
  • It is so important that a user gets predicable behaviour from your components. I had not enabled copy and paste in my data grid view and then one of the users tried to it did not work. Not a big deal, but again I needed to explain why not
  • Don’t include too many half baked features, that throw unhandled exceptions. My demo threw a few of these and it did not look so good. The program crashed and froze and I needed to restart

So all in all not a too exhaustive list but a post I will revisit and hopefully add to.

Why open source software is important

If you want a really sophisticated user interface, with a lot of controls and features, then the prime example is Visual Studio (analogous to an aeroplanes cockpit). The Visual Studio user interface allows for a lot of functionality to be made available in a very limited amount of space, i.e. your computer screen. Space is of the utmost importance, and as your applications grow, and more commands and functionality is added, the more difficult it becomes to navigate. The Office 2007 ‘fluent UI’ or ‘Ribbon’ as it’s more commonly known, solved the key problem Office 2003 had developed, which was it had thousands of commands, and it was near impossible to find the command required easily.

In a previous post, I linked to the apotheosis of UI instruction, and I still continue to extol this Video. Definitely one to watch – I have been thanked numerously for pointing people to it. There is just so much you can learn about what to, and not to do, in your applications.

Whilst rummaging around Sourceforge, I came across this docking control. Yes there are commercial versions available, and have been for some time now, but I had not really realised just what it takes to build such a thing. The controls creator, weifenluo, has done a crackerjack job, and created a real quality control. I have tried a few of the commercial ones, and this is right up there with the best them. One can determine easily and immediately that this was a labour-of-love, just by the way it is structured. I now almost always prefer open source software, because there is so much value as a developer in getting to learn how something works. When one works for software companies, the impetus is almost always on purchasing R.A.D components, and shipping software as quick as possible. While one cannot criticise this technique, if you are a junior developer, or are just starting out, ignore the component vendors and get your hands as dirty as possible. If is far much more important that you know how things work as opposed to know how to configure components in the properties pane. Most of these components shield you from using Interfaces and Delegates which are things one needs to be proficient in, to be an efficacious developer.

9 times out of 10 when creating applications, one is required to produce a solution to a problem that is not available as a purchasable component, or you need to modify the component heavily. One soon finds oneself ‘up a creek without a paddle’ whereas, had one known how the component worked, or had an inkling as to the structure and abstraction before one commenced, speedy procurement of the antidote to whatever the problem that is presented is unproblematic.

Licensing and protecting your software

One of the first commercial mistakes I made, was to develop an application over a period of 4 months (it wasn’t that big an app), and not have any protection on it. The client was, emollient and friendly. He stated that his prime requirement, was he have a working demo. In my naiveté I supplied him with a fully working copy. It will come as no surprise that it was the last I ever heard from him. Trust no-one!

There is a myriad of choice when it comes to approaching this subject, but something that may appeal to you is Microsoft Software Licensing and Protection. There is an introductory video and the option to trial the utility, very useful indeed!

Great Linq link

I am fervidly assimilating this new .NET 3.5 technology as the Visual Studio “Orcas” beta has a well developed editor. I found the march 2006 CTP bare-bones and grueling to work with.

Information is coming out daily but if I were you I would head to http://msdn2.microsoft.com/en-us/library/bb425822.aspx#linqtosql_topic4. This is all you need to get started, most people posting tutorials on the net are reading this and then modifying it’s contents.

The article is a real Beaut!