Jim Fell
Jim Fell

Reputation: 14256

Using CreateWindowEx to Make a Message-Only Window

I'm trying to use CreateWindowEx to generate a message-only window:

_hWnd = CreateWindowEx( 0, NULL, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL );

When my application executes this line it always returns _hWnd = 0. What am I doing wrong?

Upvotes: 28

Views: 36445

Answers (2)

Cheers and hth. - Alf
Cheers and hth. - Alf

Reputation: 145194

According to the Microsoft docs the class name should be "Message".

Cheers & hth.,

Upvotes: -10

Kirill V. Lyadvinsky
Kirill V. Lyadvinsky

Reputation: 99535

lpClassName shouldn't be NULL. Register class using RegisterClassEx function and pass it to CreateWindowEx.

static const char* class_name = "DUMMY_CLASS";
WNDCLASSEX wx = {};
wx.cbSize = sizeof(WNDCLASSEX);
wx.lpfnWndProc = pWndProc;        // function which will handle messages
wx.hInstance = current_instance;
wx.lpszClassName = class_name;
if ( RegisterClassEx(&wx) ) {
  CreateWindowEx( 0, class_name, "dummy_name", 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL );
}

Upvotes: 55

Related Questions