Domanda

I am just starting to play around with C++ and creating windows(On windows). I am using the CreateWindow function and I am getting the error

Error   2   error C2664: 'HWND CreateWindowExA(DWORD,LPCSTR,LPCSTR,DWORD,int,int,int,int,HWND,HMENU,HINSTANCE,LPVOID)' : cannot convert argument 9 from 'const int' to 'HWND'

and here is the code in question

//Create the window
hwnd = CreateWindow(
    "HelloDirectXClass",//Class name, defined above
    "Hello DirectX",//Top bar title
    WS_OVERLAPPED | WS_SYSMENU, WS_CAPTION,//Window style, using default
    GetSystemMetrics(SM_CXSCREEN) / 2 - WIDTH / 2,//Position relitive to top left corner, X CXSCREEN notice the CX<--for X or width
    GetSystemMetrics(SM_CYSCREEN) / 2 - HEIGHT / 2,//Position relitive to top left corner, Y CYSCREEN notice the CY<--for Y or height
    WIDTH,
    HEIGHT,
    (HWND)NULL,//Setting window parent
    (HMENU)NULL,
    hInstance,//Window instance defined above
    (LPVOID)NULL);

By looking at the error I would asume that it is trying to say that it couldn't convert arg 9, (HMENU)NULL, in the function from an integer to a HWND type. This does not make any sence because the docs say arg 9 should be a HMENU like I have.

Here is a full code dump

È stato utile?

Soluzione

Here is your bug

WS_OVERLAPPED | WS_SYSMENU, WS_CAPTION,

Replace this character: , before WS_CAPTION with |

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top