Hey all.

So I'm currently developing a relatively large raw Win32/WinAPI (what's the correct terminology these days?) application in C++. I have tried to abide by the typical C++ conventions as much as possible, but this seemingly complicates things under the umbrella of the Windows API. As an example:

Globals are bad; don't use globals! - Pretty much every C++ programmer I've ever met
It really feels like global variable declarations are necessary to keeps things legible. As it stands at the moment, I'm creating a window that contains about 40 child controls. Wanting to avoid globals as much as possible as per my C++/Jedi training, I decided to declare every HWND as static at the beginning of the window procedure (before switch casing the MSG parameter) and creating the controls in my WM_CREATE handling. As you can imagine, this got pretty ugly pretty fast.

So I'm wanting to contain all of the control-creation code in a single function (in an external .cpp file). Obviously, I could declare all of the handles in the global namespace, but I've pretty much had the "avoid-globals" mentality hammered into my head since birth. Alternatively, I could encapsulate the handles into a class or structure, declare a static instance of that object at the beginning of the WNDPROC callback and, wherever necessary, pass this object by reference to external functions.

Is there a typical convention regarding these architectural decisions? What are the pros and cons of each method and are there any other options that I haven't considered yet? I'm wondering if perhaps globals are simply more acceptable when GUI programming.

While I'm here, something odd is happening with my copy of Visual Studio (Pro, 2015). To enable visual styles in my program, I used the following directive:

Code:
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
Sometimes it compiles with visual styles enabled, sometimes it doesn't. The annoying thing is is that there is no real discernible pattern to it. Sometimes my compiler will throw:

Code:
Failed to write the updated manifest to the resource of file ".exe file". Not enough storage is available to process this command.
I thought the above error might be related; following a second attempt at compilation, however, the exe is generated fine but, again, sometimes visual styles are enabled and sometimes they are not.

Has anyone else experienced this?
Many thanks for your time guys; it is always appreciated!