Mortgaged cat

All three of our cats are on medication at the moment. Giving pills to cats sometimes feels like an exercise in futility. It’s definitely a two-person job.

A while ago, Mom and Dad sent me this step-by-step walkthrough of how to give a pill to a cat. It’s not too far off, although the bloodshed actually happens much sooner in the process than what they describe. It’s rare for me to get through a session unscathed. Noel managed to scratch my arm underneath my watch band yesterday; I’m not sure how. She didn’t fully break the skin (this time), but it sure stung.

Tycho gets three pills a day, plus a morning and evening dose of liquid antibiotic. (He’s the one with a brightly-colored sticker on his file at the vet, warning them that he bites.) We’re getting the hang of it, but for a while I was making sure to give him the liquid before I took my morning shower, because he is none too enthusiastic about actually getting it into his mouth. Training for when we have human kids, I guess.

He’s also the one we had to take out a mortgage on when he went to the vet last week. I assume that’s also training for when we have human kids.

Speaking of mortgages, this evening we’re filling out paperwork to put an offer on a house. I think Jennie is a little nervous about it. I’m not sure it’s really sunk in with me, although writing a $1000 deposit check might help with that…

VS.NET 2005 Team System

Microsoft’s Visual Studio .NET 2005 Team System (quite a mouthful!) looks like it’ll be pretty interesting… they’re combining source control (using something new, not based on the VSS code base), FxCop, and a bunch of other things that are supposed to support non-developers (analysts, testers, etc.) as well as the coders.

Pretty interesting. Though a lot of it sounds like they’re imitating StarTeam (though they’re partnering with Borland as well — that should be interesting), and throwing in FxCop so they can start getting some money out of it. (The free version of FxCop will continue to exist, but it sounds like development on it will stop [except upgrading it to support newer frameworks] once Team System is released. Bleah.)

More info, and an ongoing Q&A session, are available in this blog post. Unfortunately, nobody has a clue about pricing yet.

Update on .NET Services with Indy

I was just glancing back through my blog, and noticed that I said Windows services were easy if you’re using Indy’s HTTP server component. (Reasonably true, it seems.) I also said that all you need to do is set the server component’s Active property to true in your service’s OnStart, and back to false in your OnStop. (Well, that’s what I thought at the time.)

Turns out the thing to do in OnStop is to call TIdHttpServer.Free. Free calls Dispose, and Dispose sets Active to false, so it all works out; but if you don’t call Free, if for example you call Dispose instead, then the service EXE and DLLs won’t actually unload from memory for a good fifteen or twenty seconds afterward. Don’t ask me why; in Reflector, it sure doesn’t look like Free is doing anything significant besides calling Dispose. It’s all pretty puzzling. It also plays havoc with your pre- and post-build events that stop and restart your service so you can recompile it; when you say stop, it says it’s stopped, but really it wants to think about it for a while longer first.

Another mysterious thing is that, if you call Free, it will apparently (we found out) immediately terminate any client connections. This even though Free calls Dispose, which sets Active to false, and the setter for the Active property (at least this is what the code looked like) waits for all client-servicing threads to terminate before it returns. So it shouldn’t, near as I can tell, be terminating connections when you Free it, but it is. This is what we get for working with beta software.

SharpLayout 0.8.5 released

Okay, I think I’ll declare SharpLayout 0.8.5 to be semi-officially released. It doesn’t have a Web site yet (unless you count this blog), but you can download it here. This ZIP contains just the controls themselves, not the demo projects; I’ll probably get around to releasing those later. Installation: Compile the project, right-click in the toolbox, select “Add/Remove Items”, browse to the DLL, and there you go.

So what the heck is SharpLayout? It’s two (so far) Windows Forms controls that do basic flow-layout types of things. FlowLabel is like a Label with word-wrapping, except that a FlowLabel automatically adjusts its height to exactly fit the text inside it (and readjusts when its width changes). Throw in adjustable margins all around, and this is a good way to put several paragraphs of text into a GUI (using the margins for inter-paragraph spacing), and/or interspersing them with hyperlinks, buttons, graphics, whatever. The general idea is to allow you to write something along the lines of Microsoft’s Inductive UI without embedding IE or waiting for Longhorn.

FlowLabel can also display an imagelist image next to the text (and unlike a normal Label, it actually makes space for the image, instead of overlapping it with the text). Other interesting properties: you can specify antialiased text; and you can turn borders on and off for each of the four edges and set the border color.

FlowLinkLabel descends from FlowLabel, and along with all of FlowLabel’s capabilities, adds (not surprisingly) abilities more or less like a LinkLabel, though unlike LinkLabel, it supports hover effects.

Both FlowLabel and FlowLinkLabel are safe to use in a partial-trust environment, and I regularly test them in the Internet zone to make sure they work (though in the Internet zone, FlowLinkLabel loses the ability to cope with a few pathological edge cases).

There are a few features yet to be written, but for the most part, these controls are basically functional. The main things I still want to write are FlowLinkLabel features: (1) focus rectangles (and focus support in general — get focus when you click on the link, that sort of thing), and (2) support for popping up a context menu by using Alt+F10 or the “context menu” key (currently disabled in FlowLinkLabel in order to support another feature: the context menu only appears if you right-click on the hyperlink, not if you right-click on non-hyperlink text or on an empty part of the control).

A few other features are negotiable, since I don’t expect to need them myself: multiple hyperlinks per FlowLinkLabel; support for putting the hyperlink in the middle of a paragraph (you can currently put the link at the beginning of a paragraph, but you can’t have any non-linked text before the link); right-justified text and/or image on the right; and probably others as well.

Feedback is more than welcome, as are questions about the code. This is a blog, after all.

Installing a folder with specified permissions

So for the next release of our software, we need our installer to create a folder that’s writable by all users on the computer.

You’d think this wouldn’t be hard. You’d think this would be well-trod ground. But no, apparently not. We’re using an MSI-based installer, nice feature set, rather pricey, which apparently can’t grant permissions to the standard “Users” group because it claims that group doesn’t exist. (We’ve filed a bug report and are waiting to hear back.) And our attempt to write a little app to set the permissions programmatically isn’t going well either. I’m not actually the developer who’s working on installation issues (I just get some questions bounced off me now and then), but it seems to be causing rapid hair loss — not from ripping hair out, just from the friction caused by banging against brick walls. I’ve looked at the permission APIs before, and they’re pretty awful; according to my cohort, the documentation is even worse, basically amounting to “take a guess at the parameters and see if it works”.

Freeware to the rescue.

My boss suggested that I take a quick look at Jordan Russell’s Inno Setup, a freeware (with source) installation-building package that I had some prior experience with, and see if it could handle permissions. It originally took me a while to get used to Inno, since you have to write a text-based install script. The first time I downloaded it (around five years ago), I took a look at it and then uninstalled it — I made the mistake of being unimpressed by its lack of a pretty design-time GUI. (It has syntax highlighting now, which helps, but you still write your script as a text file.) But it’s powerful, and it can do just about anything; it’s even got a built-in scripting language. Jordan pays attention to building good apps (none of that “every time the user clicks the Next button, we’ll hide the current dialog box and then show another one, and hope nobody notices the flickering” crap like Wise and InstallShield both seem to be doing these days), and of course free is good. But can it change permissions?

Of course it can change permissions. Yes, it can grant modify access on a given folder to all users of the computer (I just tested it to make absolutely sure that it works, and it does, even on the same PC where the expensive installer didn’t work). You just tack “; Permissions: users-modify” onto the entry in the [Dirs] section. So, while we probably won’t switch our installer to Inno at this point, we do have ready access to source code (Delphi, no less) for changing permissions.

As if that weren’t cool enough, the FAQ on the Inno Setup web site suggested taking a look at SetACL, an open-source, command-line tool for changing file permissions. SetACL.exe (command-line version) is 258K — which seems awfully large for a C++ console app — but its list of command-line parameters is pretty substantial; it can set permissions on files, folders, printers, Registry entries, services, and network shares, and it’s full of options I’ve never even heard of. I think, between Inno and SetACL, that our permission problems should be pretty well wrapped up. And there was much rejoicing.

New version of DUnit (7.2.1)

It’s a minor release, version 7.2.1; nothing too earth-shaking. The biggest new feature, in my mind, is long strings — CheckEquals and the like will now check all of a string, rather than calling it good enough after the first 255 characters. I think the optional explanatory-message parameters were being truncated, too, and aren’t anymore. They also added support for comparing WideStrings, and fixed a couple of bugs.

I had almost forgotten that DUnit only used ShortStrings! The stated reason was so you could compile DUnit into a DLL. If anyone is actually doing that, they need to use ShareMem now. I honestly can’t say I’ve ever even considered putting DUnit into a DLL, but that’s just me.

They’re not using SourceForge’s bug tracker; their SourceForge site does have a text file with a one-line description for each fix, but that really doesn’t tell you anything unless you’re already familiar with all the issues. However, they do have a Web site where you can view the full list of enhancements and bug fixes for this version, along with archived discussions about each item. Oddly, you need to create a username and password before you can even view that Web site. How irritating. A bit silly, too, since they then promptly let you in without even verifying your e-mail address.

Anyway, the long-string support should make this worth the download. (Downloading now…)