The easiest way to create HWND

I need a dummy window in MSVC ++, it will never be visible and created even before the main application window. This is required by the rendering engine. Therefore, I would prefer not to register the class, if possible.

For testing, it would be better to make it visible in order to prove that it is - can I use a static or button or something else? I try with CreateWindow (), but while I get the return value, nothing is visible.

+6
c ++ visual-c ++ winapi
source share
3 answers

I am posting my own test code for criticism:

HWND dummyHWND = ::CreateWindowA("STATIC","dummy",WS_VISIBLE,0,0,100,100,NULL,NULL,NULL,NULL); ::SetWindowTextA(dummyHWND,"Dummy Window!"); 

It seemed to work ...

+12
source share

After CreateWindow you need to call ShowWindow to make it visible.

+2
source share

In the first NeHe lesson, they describe in detail what you need to do to set up the OpenGL rendering context, and creating a window (and HWND) is part of it. If you need it for something other than the OpenGL context, I believe that the code they represent can be easily adopted.

+1
source share

All Articles