Mr. Boy
Mr. Boy

Reputation: 63836

Simplest way to create a HWND

I need a dummy window in MSVC++, this will never be visible and is created even before the app's main window. It's required by a rendering engine. So I'd rather not have to register a class if possible.

For testing it would be better to make it visible to prove it is there - can I use a static or a button or something? I've been trying with CreateWindow() but while I am getting a return value, nothing visible is appearing.

Upvotes: 8

Views: 18337

Answers (3)

Mr. Boy
Mr. Boy

Reputation: 63836

I submit my own test code for critique:

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

It seemed to work...

Upvotes: 18

CygnusX1
CygnusX1

Reputation: 21818

In the first tutorial of NeHe they describe carefully what you need to do to set up an OpenGL rendering context, and the creation of a window (and HWND) is a part of it. If you need it for something else than OpenGL context I believe the code they present can be easily adopted.

Upvotes: 1

Dan Byström
Dan Byström

Reputation: 9244

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

Upvotes: 2

Related Questions