Archive of April 2008

Pet peeve: fixed size windows

Posted on 2008-04-15 21:48:45

Since I’m working a lot with windows applications at work, I’m getting more and more annoyed by the following problem: the dialogs in most office applications are fixed size.

For example, take the “folder sizes” dialog in Outlook. It’s a teeny tiny window of approximately 390 × 260 pixels, in which all my 32 folders including their sizes are listed, with a scrollbar because only 7 folders can be shown at any time in the window. If maximizing or resizing this window were possible, I would have an overview of all folders without scrollbars. This makes my fancy 1280×1024 screen quite useless: let’s all go back to 640×480!

Even worse is the Outlook address book quick search: if multiple people match the input, a fixed-size dialog box comes up, with a list of matching people. This list includes all details: name, phone number, office, company, email address, etc.. all in a box of 260×70 pixels, with both horizontal and vertical scrollbars. Even worse than that, dragging the scrollbars doesn’t scroll “live” through the list, so if you want to see the email address, you have to scroll sideways to where you think the email address column would be, release the mouse (scroll wheel doesn’t work sideways), check position, repeat.

In addition, I’ve also seen multiple instances where some piece of (Dutch) text was too wide for the available space, resulting in cut-off text.

What were they thinking when they wrote the software? In a way, I can understand it: having worked with the GUI of the .NET framework, I know that creating dialogs and windows that resize well with their contents is nigh impossible.

You want to have a split panel in which the left part takes 1/3 of the space, the right part 2/3, and that this aspect ratio holds when resizing? You gotta code that yourself, reimplementing the Resize() method of the control. This in contrast with Qt, where you can set a “stretch factor” on each of the parts and be done with it. On top of that, Qt widgets will resize themselves automatically to fit their contents, whereas you have to do that yourself in .NET.

Lessons learned:

  1. Don’t use fixed size dialogs for anything other than simple messages
  2. Don’t use .NET for resizable dialogs as it’s a hell to program

Posted in: Work

Something funny I encountered today

Posted on 2008-04-03 22:18:00

Today, while improving the error handling of an application at work, I came upon a rather interesting piece of (C#) code. The application is a Windows service used for scheduling “plugins” that process documents or generate them and whatnot. Anyway, if a fatal error has occurred during the execution of a plugin, the following bit of code is executed after logging the event to a text file:

// dt = timestamp of error
// id = origin of the error
// text = error message
// Always send email in following case
if (type == SchedulerInfoType.FatalError)
{
  Mailer mailer = new Mailer();
  try
  {
    mailer.SendEmail(ConfigurationSettings.AppSettings["BugEmailAddress"],
      "scheduler@xxxxxx.xxx",
      "A fatal error has occurred " + dt.ToString(),
      String.Format(dt.ToString() + "-" + type.ToString() +
        "-" + id + "-" + text ),
      MailFormat.Html,
      MailPriority.Normal );
  }
  catch(Exception ex)
  {
    mailer.SendEmail(ConfigurationSettings.AppSettings["BugEmailAddress"],
      "scheduler@xxxxxx.xxx",
      "An error occurred while sending the error email " + dt.ToString(),
      String.Format(dt.ToString() + "-" + id + "-" + text + "\r\n") + 
      String.Format(ex.Message)
      , MailFormat.Html,
      MailPriority.Normal);
  }
}

Also note that the use of String.Format is rather superfluous in this case as there’s nothing to format…

Posted in: Humor, Work