Why does CreateWindowEx not work as expected?

1.1k Views Asked by At

I followed the tutorial at: http://www.winprog.org/tutorial/simple_window.html

I have a reasonable understanding of what everything in the tutorial is doing and my test program works. I have tried to create a plugin for winamp using the hInstance of the DLL as it is imported and the parent hwnd given to my plugin by winamp.

It gets to the message loop but nothing is visible.

const char windowClassName[] = "LastScrobblerConfig";

WNDCLASSEX wc;
HWND hwnd;
MSG msg;    

// the window class
wc.cbSize           = sizeof(WNDCLASSEX);
wc.style            = 0;    
wc.lpfnWndProc      = WinEvents;
wc.cbClsExtra       = 0;
wc.cbWndExtra       = 0;
wc.hInstance        = plugin.hDllInstance;
wc.hIcon            = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor          = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground    = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName     = NULL;
wc.lpszClassName    = windowClassName;
wc.hIconSm          = LoadIcon(NULL, IDI_APPLICATION);

if (!RegisterClassEx(&wc))
{
    MessageBox(NULL, "Window Registration Failed!", "Error!",
    MB_ICONEXCLAMATION | MB_OK);
    return 0;
}

hwnd = CreateWindowEx (
    WS_EX_WINDOWEDGE,
    windowClassName, 
    plugin.description,
    WS_TILEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    400,
    400,
    plugin.hwndParent,
    NULL,
    plugin.hDllInstance,
    NULL
);

if (hwnd == NULL)
{
    MessageBox(NULL, "Window Create Failed!", "Error!",
    MB_ICONEXCLAMATION | MB_OK);
    return 0;
}

ShowWindow(hwnd, 1);
UpdateWindow(hwnd);

while(GetMessage(&msg, NULL, 0, 0) > 0)
{
    TranslateMessage(&msg);
    DispatchMessage(&msg);
}
0

There are 0 best solutions below