Archive for November, 2005

Setting Desktop Background

I recently bought a subscription to www.digitalblasphemy.com because I like the guys wallpapers and hes got a lot of good dual monitor wallpapers.  After I downloaded a bunch of them, I was having trouble settling on one to use for my desktop, so I wanted to write a little app that would pick one at random when I logged on and set it as my desktop background.

After googling for how to set your desktop background in C#, I saw tons of examples that used the Win32 api call SystemParametersInfo.  So I tried using that function in the same way that the examples were using it, but it just wouldn’t take, all I would get was a dark blue background and the function also returned 0, which indicated that an error had occurred.

After some more digging, I found out that SystemParametersInfo only works if you are supplying a .bmp file, whereas my files were .jpg’s.  So, I did some more digging and found that theres a different function to use for files other than bitmaps, the aptly named SetWallpaper function on the IActiveDesktop interface.

I could only find one example of someone who used this interface in c# to set the desktop background, but I couldn’t get it to work, I kept getting an error about wrong GIUD’s for the COM interfaces.  What I ended up doing is using the old SysteParametersInfo function, and after selecting a random jpeg, I would save it out as a bitmap (if the bitmap for that file didn’t already exist) and then pass that bitmap into the function.  Ugh, ugly but it gets the job done.  I could have simply found the registry key that controls the desktop background and set it that way, and maybe I will if I get too annoyed at these extra bitmaps laying around, but I wanted to do it using the appropriate api. 

The point of all this was simply to inform you that SystemParametersInfo only takes bitmaps, not jpegs.  Have a happy Thanksgiving, all you Americans.

Learning the Model View Presenter Pattern

I recently came across this article from Steve Eichert about how he dislikes the Windows forms designer.  I can’t say that I think its evil, not like the web forms designer in VS 2003, and I actually think the WinForms designer in 2005 is pretty damn good.  At the end of the article he linked to the Model-View-Presenter pattern on Martin Fowler’s site as an alternative to using the WinForms designer.  I checked out the pattern having heard of it before but never using it.  For some reason it took this time, and it seemed extremely useful because we’ve been thinking about ways to test our UI applications in a better way and by using the MVP pattern you can test much more of your application in an automated way.

On his site Fowler has a sample application that uses the MVP pattern written in java and he gives snippets of what the code would look like.  I “ported” those snippets and recreated the sample application in VS 2005 as an exercise in how to use the MVP pattern for my WinForms applications.  It was kind of hard starting out, as I wanted to create my form first, it took some deliberate thinking to force myself to unit test a stub of the form before actually creating it. You can download my version of the sample app here. Its built on VS 2005 and it references the NUnit 2.2.3 assemblies for the unit tests.

While I see the benefits of using the MVP pattern, I still am skeptical that it can completely test your application by using the stub views to run the test.  I mean, there are still implementation details that you need to write inside the form’s code, and since you are testing the stub not the actual form, its certainly possible to have bugs in the form that won’t show up in your test.  That being said, using the MVP pattern can certainly give you a much deeper test coverage that you get by just putting the code inside the form class, so there’s definitely a benefit to using the pattern.

Office Build Numbers Explained

Jensen Harris has an interesting article on how the Office build numbers are created.  His blog is very well written in general, I would recommend subscribing if you are interested in the new Office UI.

How To View a Sharepoint Page in Web Part Maintenance Mode

I gotta share this little Sharepoint tidbit that I found today whilst debugging a project. I was trying to close a problematic web part on my page, and usually you get an error page that supplies a link to the web page part maintenance page for the specific page you were browsing.  For whatever reason, the error that I was running into wouldn’t give me this link, nor could I find the link anywhere in the site admin pages.  So I googled it and found what I was looking for at Westin’s Technical Log.  If you simply add a

“?contents=1”

to the Sharepoint page you were trying to go to, it will load the page in web part maintenance mode.

Hosting Provider

I know this gets beat to a pulp every few months, but I’m want a remote computer than I can use for a couple different purposes:  website/database hosting (asp.net 2.0 and sql server or mysql), dns, ftp, and subversion source control as well.  Does anyone know of a decent hosting company that provides all of these services?  Thanks in advance

I Wanna Skin Bloglines

I wish Bloglines
would let you skin their site.  I’m growing a little tired of
their color scheme.  The reading pane is xhtml 1.0 transitional,
so a lot of the look of the site is driven by css, so it would be nice
to have a Community Server style of css override, where it loads
Bloglines stylesheets, and then lets me load a custom stylesheet that
can override their settings. I spose I can already kind of do this
using Greasemonkey, I would just have to put my css files out on the
web somewhere, so I can add a dynamic @import in the page, hmmmm……………

Another reason to not telecommute, from an employee’s perspective

Recently, Sahil and Eric
voiced their opinions about tech workers telecommuting – working from
home, and in some cases in other geographic areas.  This is
convenient for the employee because they get the obvious convenience of
working at home and freedom to schedule their day as they want, and it
saves the employer money on the marginal costs associated with housing
a worker, i.e. a computer, soda, a cube, etc.  However, its can
also be detrimental to your team and your products and services by not
having any face time with the developers that are working for you.

While I agree that both sides have some merit, this article that I found via slashdot
would make me very diligent about telecommuting across state
lines.  Basically it says that you can get double taxed on your
income, once from the state you live in and once by the state that your
employer is in (at least if its New York).  In this case the guy
lives in Tennessee, so they have no income tax, but you could get
screwed pretty hard if you lived in Minnesota for instance and got
taxed twice.

Setting up a recurring task in Outlook 2003

I was having trouble with a recurring task in Outlook and I thought
I’d share how to set it up correctly for anyone else.  I wanted a
recurring task to occur every workday with a reminder at 4 PM, the task
was to remind me to fill out my timesheet, as I usually wait until the
day its due before I fill it out.

What you need to do is setup your task with the recurrence
pattern that you want and with the reminder time.  Then whever the
reminder pops up, rather than dismiss the reminder, you need to open
the task item and mark it as completed.  This will cancel the
reminder for that instance of the task, and leave the next task active
so that you can get a reminder for that one.  If you dismiss the
reminder, the reminder will never come back, making the task pretty
much useless (in my case).

Live.com reaction

Okay, I gotta give my knee-jerk reaction to www.live.com. There
doesn’t appear to be anything new about this site, except that it seems
that Microsoft is starting to discover web applications and thats its
hip to label all of your services “beta” a la Google (thats actually
more a criticism of Google than MS because live.com certainly is in
beta form).  I mean come on, Google launched their home
page/portal with little widgets and rss/atom/blogs/news feeds built in
months ago. Google’s site also has GMail integration, just like
live.com has hotmail integration.  Nothing new here, except they
haven’t quite got the firefox implementation down just yet, I mean
countless other sites have, but you know that Microsoft is a little
resource strapped, so they certainly don’t have the manpower to
investigate the nuances of the firefox dhtml/ajax model. 

Scoble says something like “its an advertising platform”,
which is bullshit, at least for now, he hints at some subdomains
popping up, so we’ll see what that brings, but right now live.com is an
IE only implementation of Google’s personalized home page.

VistaDB Advertisement

VistaDB 2.1 database for .NET has been released

This 2.1 update includes over 60 improvements, including new support for .NET 2.0 and Visual Studio .NET 2005. VistaDB is a small-footprint, embedded SQL database alternative to Jet/Access, MSDE and SQL Server Express 2005 that enables developers to build .NET 1.1 and .NET 2.0 applications. Features SQL-92 support, small 500KB embedded footprint, free 2-User VistaDB Server for remote TCP/IP data access, royalty free distribution for both embedded and server, Copy ‘n Go! deployment, managed ADO.NET Provider, data management and data migration tools. Free trial is available for download.

* You can get a free license of Vista DB by posting this little snippet to your blog, check out the details here