Fun with Windows Forms
Posted on 2011-06-30 Edit on GitHub
I'll be using this blog to record my progress in building a Schedule/Grade Recorder using WinForms in C++/CLI. I have been working on this project for 3 weeks and it has been both a frustrating and educational experience
I was going to create this project with WPF but I am unfamiliar with C#, so I resigned myself to using WinForms, which from what I've read is already considered obsolete and being replaced by the former. I began this project with only a mediocre background in unmanaged C++ and immediately encountered several problems.
- WinForms requires managed C++
- That is, C++/CLI. C++/CLI is basically an extension of regular C++ that works within Microsoft's .NET framework and allows nifty features like memory management. I initially had no idea what the .NET framework or the Common Language Runtime were and boy did I have a hard time making sense of it all; my grasp of the concept is still mostly cursory but I now know enough to write code for my project.
- Visual Studio 2010 does not have Intellisense support for C++/CLI
- Intellisense is Visual Studio's auto-completion feature for code. You can read all about it and why it doesn't work for C++/CLI in VS 2010 here. I started my project in VS 2010 and started playing around with the WinForms designer and did not discover this until I began to write code. Moving my project over to VS 2008 was a pain and would cause a very serious problem down the road; more on that later. So why did I have to move my project over to VS 2008? Because…
- Previous versions of VS cannot open projects created in VS 2010
- To be honest this one makes perfect sense, but it was still very tedious to copy-paste files over to VS 2008.
Furthermore, C++/CLI does not seem to be very popular for writing WinForms applications. Almost all the code examples on MSDN, Stack Overflow, and other websites are geared towards C#. While the functions and classes used in these codes are usually part of the Base Class Library and accessible in C++/CLI, I'd sure like to see some examples specifically targeting the language I'm using.