Windows forms and HTML: not a good combination

Posted on 2008-01-26 09:57:11

Some while ago, the request of one of our clients was this: they have a web application, and they wanted to publish some news on that. Because adding news management to the application itself was a little costly, they thought, “hey, we have a website as well, let’s publish news on that, and the web application can fetch the news from there”. This works fine: we get the news items as XML from the website, then parse and display it in the web application. All worked fine and dandy.

The client also has a windows application for the same system, which has a few more features than the web application, but works on the same data. So after a while they thought, “hey, let’s add the news to that as well!”. Good idea.

Adding the HTTP requests to this application to retrieve the news wasn’t the problem. The main problem we encountered: the news items themselves could contain (X)HTML to format the text, and the standard windows forms controls do not have support for displaying HTML.

Yes, there is a “browser control” that just calls up the internet explorer rendering engine internally, but that’s only a .NET 2.0 control, and the application uses .NET 1.1. Besides, bringing up such a heavy control just for displaying some simple <strong> and <em> tags is a little overkill. There is a “rich text box” control, but it only accepts RTF and doesn’t seem to know about HTML. In the end, we decided to just convert the HTML into RTF and be done with it. To this moment, only strong, em, br, and paragraph tags are supported… any other HTML tags are silently ignored.

The two other frameworks I’ve worked with for GUI applications, Java and Qt, both supported (a subset of) HTML natively, and with Qt you can put entire HTML pages into a simple label. Funny, that something so simple would be so difficult to do in .NET, especially since HTML seems to be more universal, compared with RTF, specially in the light of the “web centered” way of computing nowadays.

Posted in: Work