RegisterClassEx does not work as an invalid parameter - C ++

The call RegisterClassExin my application does not work with error code 87, "parameter is invalid."

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

Does anyone know what I'm doing wrong? Thank.

+3
source share
3 answers

The WNDCLASSEXstyle structure element accepts class styles , not window styles . In other words, you cannot make all windows of this class initially minimized in this way.

You must pass WS_ICONICin an argument dwStyleto CreateWindow () or CreateWindowEx () .

+3

" " - WINAPI: ", ".

- WNDCLASSEX, , . , , , - : m_wcx.hInstance, m_wcx.lpfnWndProc m_wcx.lpszClassName.

EDIT:

@Johann Gerell, m_wcx.style = WS_ICONIC - . , , ' . .

? , ++ class , ? A class . - . Windows. Window - , - Window. , , DC , - , , . Windows , . , , , .. RegisterClassEx , .

0

-, WS_ICONIC. class - . CS_*.

0
source

Source: https://habr.com/ru/post/1777547/


All Articles