I’ve been struggling today with writing a very simple Win32 GUI app. All I wanted to do was to bring up a window with IE embedded in it displaying an HTML page. The exe had to be small since it was going to be submitted to places like www.download.com. I thought it shouldn’t have to be more than around a few hundred kB at most, considering what it would do.
First I thought that C# and .NET would be a good choice since Java is what I usually work with. But as far as I understand it’s not yet that common that people have the .NET framework installed and I didn’t want my users to have to download an additional 20 MB when my app is only about 100 kB. Why on earth hasn’t M$ made .NET a mandatory upgrade through Windows Update?
So I realized that I would have to turn to C++. I have worked with C++ before but it was ages ago and after working with other languages like Java and Ruby I never thought I would have to go through that again. It’s just so primitive with its lack of garbage collection and it has no standard API:s to talk about. I really do hate it!
Working with the IE component proved to be a problem. MFC provides wrappers for it but I couldn’t use MFC because it cannot be used with Mingw which was the C++ compiler I decided to use (I don’t own a Visual Studio license and Visual C++ Express doesn’t do MFC). Also, I didn’t want to use a GUI toolkit like QT or wxWidgets because that would make the exe huge. I had to work with the COM object directly.
Just a warning: working with COM objects in C++ is a big mess! I found some code on the net which basically did what I wanted and got it to work after pulling some header files missing from Mingw from the Wine sources. It’s amazing how much code it takes to do such a simple thing!
The code did exactly what I initially wanted. But after working with this for two days I realized that I had to extend the GUI with some other controls like buttons and at that point I just gave up. I didn’t understand half of what to code I had did and since I wasn’t using any GUI toolkit I would have had to work with the Win32 API directly.
All in all I guess I should have used a pirated version of Visual Studio and gone with MFC just like my partner suggested from the beginning. Hopefully, in a couple of years, no one will have to use stone age technologies like C++ and MFC for simple things like this.