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