So I'm having this strange issue that I can't seem to resolve. I have two classes, a Window class and its base class, Control. Control is friends with the global WndProc() method and it basically manages what control or window child procedure, aka _wndproc, is to be called. This works fine for the most part, until I make it virtual. If I make just the base class Control virtual, the _wndproc hangs and the window is unusable. If I make both classes virtual, I get a runtime "access violation" error.
Ok, after much debugging and tweaking I have discovered that this problem has to do with the local HINSTANCE variable in the Window class. There was a case where the variable was not yet initialized and the procedure was called anyways resulting in a runtime error.