Simplest way to create a HWND

15,689

Solution 1

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...

Solution 2

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

Solution 3

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.

Share:
15,689
Mr. Boy
Author by

Mr. Boy

SOreadytohelp

Updated on August 13, 2022

Comments

  • Mr. Boy
    Mr. Boy over 1 year

    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.