0
我刚开始玩弄C++并创建窗口(在Windows中)。我现在用的是CreateWindow
功能,我得到的错误CreateWindow参数类型错误
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'
,这里是有问题
//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);
代码通过查看错误我会asume它正试图说,它couldn将函数中的arg 9,(HMENU)NULL
转换为一个整数到HWND
类型。这没有任何意义,因为文档说arg 9应该是像我一样的HMENU
。
Here是一个完整的代码转储
错误消息指CreateWindowExA不CreateWindow的 –
WS_CAPTION
之前,
@VladfromMoscow这让我更加困惑,因为如果你看看我的完整鳕鱼,我不会使用'CreateWindowExA' e转储。 –CreateWindow只是一个宏定义,如果你在非UNICODE编译下,那么它解析为CreateWindowExA – marcinj