2

我按照以下教程进行操作:http: //www.winprog.org/tutorial/simple_window.html

我对教程中的所有内容以及我的测试程序的工作有一个合理的理解。我尝试使用 DLL 的 hInstance 为 winamp 创建一个插件,因为它是导入的,并且父 hwnd 由 winamp 提供给我的插件。

它进入消息循环,但什么都看不到。

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);
}
4

0 回答 0