I have a program which, right now, runs as follows:
1. Starts at WinMain, which then create a Game object from my Game class, and passes it the hWnd.
2. The game object creates a graphics object, which is currently DirectX, and passes IT the hWnd.
3. Graphics object initializes, using the hWnd.
It might seem a bit of a mess, my reason for doing this was to make it portable. To change renderers, all I would have to do would be to call a different graphics class.
My question now is, is it possible to start the program by calling main instead of WinMain, and then create the windows class else where in the program?
I imagine it should be possible, as OpenGL and SDL both work this way. The biggest challenge is to find a way to get the hInstance, which is usually passed into the program through WinMain.
[Edited by - methinks on March 17, 2005 4:13:51 PM]
I use GetModuleHandle( NULL ) to set the WNDCLASSEX::hInstance field when creating the window within the graphics engine.
For exactly the same reason, our application starts from a main and not a WinMain - to increase the ease of migrating to a different platform at some point in the future. Keep all platform specific code to the core engines, and everything else as standard C/C++ [smile].