Problem with CreateWindow() function

I am trying to create a window using Visual Studio and i keep getting this error when ever i try to run the program

'HWND CreateWindowExW(DWORD,LPCWSTR,LPCWSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID)' : cannot convert argument 2 from 'WNDCLASS' to 'LPCWSTR'

here is my code

#include<Windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd)
{
WNDCLASS westonClass;
{
westonClass.style = CS_DROPSHADOW;
westonClass.lpfnWndProc = NULL;
westonClass.cbClsExtra = 0;
westonClass.cbWndExtra = 0;
westonClass.hInstance = hInstance;
westonClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
westonClass.hCursor = LoadCursor(NULL, IDC_ARROW);
westonClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
westonClass.lpszMenuName = L"My Menu";
westonClass.lpszClassName = L"Weston's Class";
}


RegisterClass(&westonClass);





HWND window = CreateWindow(westonClass, L"My Window", WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, NULL, NULL);
ShowWindow(window, WS_MAXIMIZE);
if (window == NULL)
{
MessageBoxA(NULL, "Window could not be created", "Error Message", 0);
}
};
OH i found the problem i needed to type in L"Weston's Class" for the first argument but now when i try to run the program it will run but when i do that a window will pop up that says

Unhandled exception at 0x00000000 in ConsoleApplication9.exe: 0xC0000005: Access violation executing location 0x00000000.
CreateWindows expects a LPCTSTR as first parameter not a WNDCLASS. Try this:
CreateWindow(L"westonClass", L"My Window", WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, NULL, NULL);
Even if it does compile it'll crash on execution with this...

westonClass.lpfnWndProc = NULL;

A NULL Window Procedure address is no good.
Thanks for you help guys i did some research and i was able to make a correct window procedure with callback and MSG
Topic archived. No new replies allowed.