gpt4 book ai didi

c++ - RegisterClassEx 因参数无效而失败 - C++

转载 作者:太空狗 更新时间:2023-10-29 21:29:39 28 4
gpt4 key购买 nike

在我的应用程序中调用 RegisterClassEx 失败,错误代码为 87,“参数不正确。”

memset( &m_wcx, 0, sizeof(WNDCLASSEX) );

m_wcx.cbSize = sizeof(WNDCLASSEX); // size of structure
m_wcx.style = WS_ICONIC; // initially minimized
m_wcx.lpfnWndProc = &WndProc; // points to window procedure
m_wcx.cbClsExtra = 0; // no extra class memory
m_wcx.cbWndExtra = 0; // no extra window memory
m_wcx.hInstance = m_hInstance; // handle to instance
m_wcx.hIcon = ::LoadIcon( NULL, IDI_APPLICATION ); // default app icon
m_wcx.hCursor = ::LoadCursor( NULL, IDC_ARROW ); // standard arrow cursor
m_wcx.hbrBackground = NULL; // no background to paint
m_wcx.lpszMenuName = NULL; // no menu resource
m_wcx.lpszClassName = _pwcWindowClass; // name of window class
m_wcx.hIconSm = NULL; // search system resources for sm icon

m_atom = ::RegisterClassEx( &m_wcx );

if ( m_atom == 0 )
{
TRACE(_T("CNotifyWindow::CNotifyWindow : Failed to register window class.\r\n\tError: %d\r\n\tFile: %s\r\n\tLine: %d\r\n"), ::GetLastError(), __WFILE__, __LINE__);
THROW(::GetLastError());
}

有谁知道我做错了什么?谢谢。

最佳答案

WNDCLASSEXstyle 成员结构接受 class styles , 不是 window styles .换句话说,您不能使该类的所有窗口最初都以这种方式最小化。

您应该将 dwStyle 参数中的 WS_ICONIC 传递给 CreateWindow()CreateWindowEx()相反。

关于c++ - RegisterClassEx 因参数无效而失败 - C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4308562/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com