gpt4 book ai didi

c++ - CreateWindow 参数类型错误

转载 作者:行者123 更新时间:2023-11-28 03:00:28 24 4
gpt4 key购买 nike

我刚刚开始使用 C++ 和创建窗口(在 Windows 上)。我正在使用 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);

通过查看错误,我假设它试图说它无法将函数中的 arg 9,(HMENU)NULL,从整数转换为 HWND 类型。这没有任何意义,因为文档说 arg 9 应该像我一样是 HMENU

Here是一个完整的代码转储

最佳答案

这是你的问题

WS_OVERLAPPED | WS_SYSMENU、WS_CAPTION、

WS_CAPTION之前的这个字符:,替换为|

关于c++ - CreateWindow 参数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20984152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com