CreateWindowEx method always returns null.
I don't know whats wrong, but I am not able to even create a window.
My window procedure is a static method, BaseWndApplication::WndProc, defined in another class, I am not sure if that should cause any problems, As I can register my WNDCLASSEX structure successfully.
Please heeeelp!!
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine ,
int nCmdShow
)
{
const char * WINDOW_CLASS_NAME = "D2DAppClass";
HRESULT hr;
{
// Register the window class.
WNDCLASSEX wcex = { sizeof(WNDCLASSEX) };
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = BaseWndApplication::WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.hCursor = LoadCursor(NULL, IDI_APPLICATION);
wcex.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClassEx(&wcex))
return E_FAIL;
HWND m_hWnd = CreateWindowEx(WS_EX_CLIENTEDGE,
WINDOW_CLASS_NAME,
"Direct2D Demo App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
static_cast<UINT>(ceil(640.f)),
static_cast<UINT>(ceil(480.f)),
NULL,
NULL,
hInstance,
NULL
);
hr = m_hWnd ? S_OK : E_FAIL;
if (SUCCEEDED(hr))
{
ShowWindow(m_hWnd, SW_SHOWNORMAL);
UpdateWindow(m_hWnd);
}
}
return 0;
}