Archives / 2004 / January
  • The mysterious ways of the RichTextBox...

    The kind of systems and applications I normally develop are browser-based, but now and then I try my luck at Windows Forms. Right now I'm doing this little instant messaging program, a pretty simple chat that communicates with a server via SOAP. Anyways, I'm having this battle with a RichTextBox I'm using in a form to display chat messages, smilies and such. Explain this to me: When the RichTextBox is designed to be anchored to the bottom of the form, whenr I add text to it while it's minimized in the task-bar, it refuse to scroll down to the end/bottom of the RichTextBox. The effect is that when I bring up the form from the task-bar and look at it, no messages are displayed until I tap once on the vertical scrollbar! Very amazing and feels like a bug. It doesn't matter how much I try to use the ScrollToCaret() method or other tricks, if the RichTextBox has the anchor property set to bottom, ScrollToCaret() doesn't work as it should.

    I think I'll have to subclass the RichTextBox and send my own scroll-messages to it to make this work. :(

  • Redrawing a resized owner drawn listbox

    For some strange reason the MeasureItem event isn't fired when an owner drawn listbox (or similar control) is resized. If you have lots of items in the listbox with variable height, for example text that needs to wrap, this becomes a problem. I tried different stuff to fix this, but it seems that the MeasureItem event is only fired when things are added or removed from the listbox, so the simplest fix was this:

                listBox1.Resize += new System.EventHandler(listBox1_Resize);


                private void listBox1_Resize(object sender, System.EventArgs e)





                private void RefreshListBox(object sender)


                      ListBox listbox = (ListBox)sender;

                      object[] items = new object[listbox.Items.Count];








    Take a copy of the current items in the box, remove the items and just add them again. Stupid, but as far as I know, this has to be done if you want the correct item height.

  • NUnit 2.1 and Whidbey

    Peter Golde blogs this:

    I was very happy to discover that it is trivial to get NUnit 2.1 to work with the Whidbey version of the .NET runtime. If you have the PDC release, you just need to do the following:

    First, create a new NUnit directory (say, "NUnit Whidbey") and copy everything from your Program FilesNUnit V2.1 directory over to the new directory. Second, open the two files "bin\nunit-console.exe.config" and "bin\nunit-gui.exe.config" inside a text editor. Right above the other lines that start with "supportedRuntime", add the following line:

    <supportedRuntime version="v1.2.30703" />
    After that, NUnit runs just fine with Whidbey, and you can test code that uses Whidbey-only features. 
  • Is Messenger that dangerous?

    The place I'm working at for the moment stops Messenger in their firewall due to some security reason or other. Is Messenger really that dangerous? I've heard about some kind of trojan virus or other that could affect Messenger, but come on! I tried to configure Messenger to use HTTP proxy but it seems to fail. It's probably turned off in the firewall as well (unless someone out there knows how to get it working).

    Anyway, I'm desperate to be able to chat with my old pals, so I'm thinking of rolling my own simple chat program, which uses a chat-server implemented as a web service, and throw the client at my pals... I've been without Messenger for almost 3 months now...

  • Got a new aquarium

    Well, I got me a new aquarium, and this one doesn't leak. Not yet at least :) Only thing I need now is some nice looking fish to put in it.

  • Leaking aquarium.... gah!

    I bought an aquarium today, just a small one, 50 liters, but very nice hexagon shaped. I've spent the last hour or so setting it up and filled it with water, just to find out that it LEAKS!!

    [insert favourite words here]

    Lucky I didn't buy any fishes yet. I was going to do that tomorrow, when things were ready, water temperature right etc... That shop is going to hear a few nice words from me tomorrow...

  • [Books] The practice test for the web app MCAD exams really sucks

    A year or so ago I got the MCAD/MCSD self-paced training kits from MS Press to do the test exams. I've been through 12-13 of the questions now and I've seen an embarrassing number of errors so far. Code snippets with obvious errors that would never compile etc. etc. Right now I'm looking at a question about settings in web.config with 4 answers, and all of them are wrong! Amazing...

    This practice test cannot have gone through any review whatsoever by someone who really knows ASP.NET :(

  • Watched some of the Indigo presentations from PDC

    I watched a few of the streamed Indigo presentations from the PDC the other day. I got a good grip of the basics of what Indigo brings now, even though I think the presentations I saw wasn't really up to the standards.

    The best way to prepare for Indigo seems to be to use ASMX and ES (Enterprise Services) inside the ASMX methods if you really need ES features like automatic transactions. I got the feeling that Don and the Indigo guys recommeded to stay away from .NET Remoting and I don't have a problem with that :)

    The peer-to-peer stuff in Indigo looks really nice, and I will sure test them out once I get my hands on the libraries needed.

    First day at work after 2 weeks off... I need coffee!!