win32 without WinMain

Started by
4 comments, last by b2b3 19 years, 1 month ago
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]
Advertisement
you may want to create a title for the topic to get the interested of people who might be able to help you better.
Oops, sorry about that!
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].

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Just what I was looking for, Thanks!
If you are not planning to realease under Win95/98/Me you can ignore value of hInstance (for example set to 0) when creating window - Windows NT/XP/2k do not use it (source).

This topic is closed to new replies.

Advertisement