Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 684
Mr. Boy Avatar asked Mar 08 '11 10:03

Mr. Boy


People also ask

How do I get hInstance?

Just make hInstance = NULL when registering the class and pass NULL to CreateWindow() and you're good to go.

What does Hwnd mean?

HWND is a "handle to a window" and is part of the Win32 API . HWNDs are essentially pointers (IntPtr) with values that make them (sort of) point to a window-structure data. In general HWNDs are part an example for applying the ADT model.


1 Answers

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

like image 172
Mr. Boy Avatar answered Sep 19 '22 14:09

Mr. Boy