Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Win32 window without WinMain function [duplicate]

Tags:

c++

window

winapi

I want to write me a small window framework for OpenGL on windows. I know there are a lot of good window libraries but I like to do it myself. But I have a small problem, if I want to create a window with the Win32 API I need the parameters like "hInstance" .... How I get this needed variables in a Window.class ? How the other Window libraries do it ?

like image 810
user3325226 Avatar asked Aug 21 '14 16:08

user3325226


1 Answers

You can use GetModuleHandle(0); to get the programs hInstance. Just passing 0 as the hInstance parameter worked for me.

"Passing 0 retrieves the handle of the calling process, not the calling module. If the library/framework is implemented as a DLL, you would end up with the wrong handle. Use the handle passed to DllMain() or DllEntryPoint() instead. – Remy Lebeau"

like image 141
nwp Avatar answered Oct 02 '22 01:10

nwp