I don’t make it a secret that I despise designing and implementing user interfaces. One of the beauties of the command line interface is that it is so simple to implement. Unfortunately, unless you’re using the application programmatically (e.g. in batch files), the command line interface isn’t very user-friendly. It’s simple to use but, in a Windows environment, opening a console, navigating to the proper directory, and then typing out the command line can be cumbersome.
Ultimately, you need to design your user interface for your intended users. For more esoteric programs like my FLV Script Data Extractor, a command line interface is fine because anyone interested in that sort of thing is likely to be handy with the Windows console. However, for my secret project, my intended users are not necessarily going to be hardcore computer users. They’re much more likely to be casual computer users who may never have used a console application or a command line interface before. Unfortunately, that means that I had to design a graphical user interface for my secret project. I considered using .NET to make the interface because Visual Studio 2010 makes creating GUIs in .NET very easy, but I thought the overhead of .NET for such a simple application was overkill. To my dismay, Visual C++ 2010 Express does not provide any interfaces or templates for creating GUIs in Win32. You just have to code the whole thing. I’m not familiar with making GUIs in Win32 so I was kind of stumbling all over myself at first. I tried using Windows controls (static text, edit boxes, etc.) but I couldn’t get the coloring right without doing extra work that I didn’t feel like doing. After banging my head against the wall for several hours, I decided to try using a dialog box interface. I’ve done my fair share of dialog box programming from my time making objects for Multimedia Fusion. I wasn’t sure how to make a Win32 program that was just a dialog box, so I had to play around with it. Finally, I realized I could just scrap all of the default window creation code Visual C++ created for me and simply use the DialogBox function by itself. A handy trick I’ve used in the past is to create my dialogs in Visual C++ 6.0, which has a neat little dialog box designer, and then copy the proper code over to Visual C++ 2010. I suppose I could just draw the interface on paper and then code it manually but designing it visually is so much faster. After several days, I finally finished the interface. The code is messy, with way more global variables than I’d like, but I’ll just blame that on a lack of experience.
I toyed with the idea of also allowing the user to use the command line if they so desired, but I ran into a bit of a speed bump. In a Win32 application, Windows does not break up the command line into argv and argc. Instead, it passes the whole command line as a single string. Windows does provide a function (CommandLineToArgvW) for converting this string into something similar to argv and argc but it only works on wide chars (Unicode). This really shouldn’t be a problem since I did design the program to use Unicode, but I was using TCHAR, which is a Windows type that can be either wide char or char depending on preprocessor definitions. I thought about using CommandLineToArgvW but that would defeat the whole point of using TCHAR. Given that no one is ever likely to use the command line, I decided it wasn’t worth the effort to write my own function to parse the command line.