Vista ProgressBar

Fri, June 8, 2007, 05:46 AM under Windows | Vista
While prepping for an event in Amsterdam next week, I am revisiting all my content from last year to do with Vista for managed developers. A very small part of the presentation is showing the WinForms controls and what additional things you can do with them in Vista such as the TextBox cue banner, commandlink button, treeviewvista, adding shield to clickable controls etc.

It occurred to me that I never looked at the ProgressBar control. In Vista, in addition to NORMAL (green), the control can be in a state of PAUSE (yellow) and ERROR (red). However, the managed ProgressBar control does not expose a managed way of controlling that. Once again, PInvoke to the rescue:
// Assuming a Form1 with 3 ProgressBar controls
private void Form1_Load(object sender, EventArgs e)
{
SendMessage(progressBar2.Handle,
0x400 + 16, //WM_USER + PBM_SETSTATE
0x0003, //PBST_PAUSED
0);

SendMessage(progressBar3.Handle,
0x400 + 16, //WM_USER + PBM_SETSTATE
0x0002, //PBST_ERROR
0);
}

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern uint SendMessage(IntPtr hWnd,
uint Msg,
uint wParam,
uint lParam);


For a more complete reusable wrapper of the ProgressBar (inc. some other features that I have not covered) check out the code from the VistaControls project on codeplex.

Windows Mobile Device Center 6.1

Wed, June 6, 2007, 02:20 PM under Links
...with updates mainly for WM6 devices, available here (32-bit) or for 64-bit here.

.NET Framework 3.5

Tue, June 5, 2007, 04:17 PM under dotNET | Orcas
This is a follow up to my previous description of putting VS2008 in context.

.NET Framework (NetFx or Fx) version 3.5 has two elements to it that must be understood: the green bits and the red bits. The original references to this term are on old blog posts by Soma and Jason. Compared to those two blog entries I have the advantage of 13 months of hindsight :-), so I will provide here the details behind those descriptions in my own words starting with my own slide:


When we say red bits, those are Framework bits that exist in RTM today i.e. NetFx v2.0 and NetFx v3.0.

NetFx v3.5 includes updates for those two existing frameworks. However, those updates are not a whole bunch of new features or changes, but in reality a service pack with predominantly bug fixes and perf improvements. So to revisit the terminology: Fx 3.5 includes v2.0 SP1 and v3.0 SP1. Like with all service packs, there should be nothing in there that could break your application. Having said that, if a bug is fixed in the SP and your code was taking advantage of that bug, then your code will break of course. To be absolutely clear, this is an in-place upgrade to v2 and v3, not a side-by-side story at the framework/clr level. I will not focus anymore on the Service Pack (red bits) improvements in Fx 3.5. If you are interested in that you may wish to read my previous blog posts here, here, here and here.

When we say green bits, we mean brand new assemblies with brand new types in them. These are simply adding to the .NET Framework (not changing or removing) just like Fx 3.0 was simply adding to v2.0 without changing existing assemblies and without changing the CLR engine. It is here where you find the brand new stuff to talk about. In Beta 1, the list of new assemblies (green bits) is:

1. System.Data.Linq.dll – The implementation for LINQ to SQL.

2. System.Xml.Linq.dll – The implementation for LINQ to XML.

3. System.AddIn.dll, System.AddIn.Contract.dll – New AddIn (plug-in) model.

4. System.Net.dll – Peer to Peer APIs.

5. System.DirectoryServices.AccountManagement.dll – Wrapper for Active Directory APIs.

6. System.Management.Instrumentation.dll – WMI 2.0 managed provider (combined with System.Management namespace in System.Core.dll).

7. System.WorkflowServices.dll and System.ServiceModel.Web.dll – WF and WCF enhancements (for more on WF + WCF in v3.5 follow links from here).

8. System.Web.Extensions.dll – The implementation for ASP.NET AJAX (for more web enhancements, follow links from here) plus also the implementation of Client Application Services and the three ASP.NET 3.5 controls.

9. System.Core.dll – In addition to the LINQ to Objects implementation, this assembly includes the following: HashSet, TimeZoneInfo, Pipes, ReaderWriteLockSlim, System.Security.*, System.Diagnostics.Eventing.* and System.Diagnostics.PerformanceData.

UPDATE: Beta 2 added two more

10. System.Data.DataSetExtensions.dll – The implementation of LINQ to DataSet.

11. System.Windows.Presentation.dll –WPF support for the System.AddIn mentioned of point 3 above.

12. System.VisualC.STLCLR.dll – STL development in the managed world.

If you decide to "borrow" my slide above, feel free to do the right thing and point people back to this blog post ;-)

Run better user groups

Tue, June 5, 2007, 07:17 AM under Links
It is as if Roy has been eavesdropping to similar discussions we are having here in the UK. Check out his list of tips for better user group meetings.

Visual Studio 2008 stack

Mon, June 4, 2007, 07:02 AM under Orcas | VisualStudio
When Visual Studio 2008 (formerly Visual Studio codename "Orcas") ships in FY08, we will also get other elements of the stack. Below is the opening slide I use at Orcas events:

The main points are that the CLR engine is the same version (so no need to retest your apps) and that the headline feature is the language enhancements (C#3 & VB9 compilers) and LINQ.

The VS2008 IDE is not as big a jump as it was when going from VS.NET2003 to VS2005 and it includes all of today's SDKs out of the box and also a simple yet sweet feature: multitargeting inc. the ability to use new language features from .NET 2.0 projects. FYI, I usually do a demo of new IDE features that lasts 15 minutes (inc. aesthetics, VB intellisense, embedding manifests and new Office templates). Given that VS2008 is a superset of VS2005, there is little point in having both of them installed on the same machine, but it is possible – we support side-by-side at the IDE level.

So that is the IDE, languages and CLR in a nutshell. How about .NET Framework v3.5? For that you'll have to see my blog post tomorrow.

Acropolis CTP

Mon, June 4, 2007, 12:32 AM under Links
As if I didn't have enough things to play with and events to prepare for, my incoming list shows me an Acropolis CTP. Download it here.

DateTimeOffset

Sun, June 3, 2007, 05:00 AM under dotNET | Orcas
If you never liked the name of TimeZone2, you'll be pleased to know that in "Orcas" Beta 1 it was renamed to TimeZoneInfo. Having played with this a bit, I found that its members include a dependency on yet another new type: DateTimeOffset. I searched and saw that this has actually been in there for a while.

What I can't fathom is why DateTimeOffset ended up in mscorlib and TimeZoneInfo ended up in System.Core! The latter makes sense, it is a brand new type so it cannot go into existing bits; so why break that rule for the former? To be clear, I would expect both of them to reside in Core. Anyway, regardless of where they belong, go play with them ;)

Visual Studio Orcas SDK June CTP

Sat, June 2, 2007, 03:28 AM under Orcas | VisualStudio
Want to work with VS "Orcas" Beta 1 extensibility points? Get the SDK here.

Some links from the last few days

Fri, June 1, 2007, 03:03 AM under Links
Been on the road for a week so catching up with my aggregator:

- Microsoft Surface (my wife asked me "Why is your mouth open, what are you watching there?")

- There has been discussion on the web about comments Martin made about AlphaGeeks. It is too easy for people to jump on the "doom train" (fact: being negative is so much easier than being positive), which is why I found Rocky's take most interesting: Busy, busy, busy.

- Bill and Steve talk. If you don't have time for the full interview, watch this 8' of highlights video.

- I am glad that other companies are finally seeing my point of view: pure web apps don't cut it; we need offline support and fast UI response. Read Tim's report from Google Developer Day.

Mobile Development Handbook

Thu, May 31, 2007, 02:08 PM under MobileAndEmbedded | Personal
Finally, the world gets an up to date book on Mobile Development! You can browse it at amazon or look for it at your favourite book shop online or offline.

Its 600+ pages are spread over the following 18 chapters:
1. .NET Compact Framework—a Platform on the Move
2. Building a Microsoft Windows Forms GUI
3. Using SQL Server 2005 Compact Edition and Other Data Stores
4. Catching Errors, Testing, and Debugging
5. Understanding and Optimizing .NET Compact Framework Performance
6. Completing the Application: Packaging and Deployment
7. Exchanging Data with Backend Servers
8. Networking
9. Getting Connected
10. Security Programming for Mobile Applications
11. Threading
12. Graphics Programming
13. Direct3D Mobile
14. Interoperating with the Platform
15. Building Custom Controls
16. Internationalization
17. Developing with Windows Mobile
18. Introducing .NET Compact Framework Version 3.5 and Visual Studio "Orcas"
I highly recommended you check it out, for example, on the publisher's official book page.