为什么 CreateWindowEx 不能按预期工作?
我按照以下教程进行操作: 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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论