• Advertisement
Sign in to follow this  

win32 without WinMain

This topic is 4692 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement