2

我正在使用 Windows 库,我是新手,但我遇到了一个错误,我用谷歌搜索了足够多的东西,我不知道发生了什么。

这是我的代码:

LRESULT CALLBACK WbWindow::st_wind_callback(HWND hWnd, UINT Message, WPARAM wParam, LPARAM
lParam)
{
 // Code for the callback static function
return 0;
}
WbWMResult WbWindow::Create()
{
// Put in the class values for our window
class_window_instance.cbSize = sizeof(WNDCLASSEX);
class_window_instance.lpfnWndProc=WbWindow::st_wind_callback;
class_window_instance.lpszClassName = window_name;
class_window_instance.style = NULL;
class_window_instance.cbClsExtra = 0;
class_window_instance.cbWndExtra = 0;
class_window_instance.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
class_window_instance.hCursor = LoadCursor(NULL, IDC_ARROW);
class_window_instance.hIcon = LoadIcon(NULL, IDI_APPLICATION);
class_window_instance.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
class_window_instance.hInstance = main_instance;
class_window_instance.lpszMenuName = NULL;

if(!RegisterClassEx(&class_window_instance)){
    MessageBox(0,"There was an error registering the window-classname.","Critical Error!",MB_ICONSTOP | MB_OK);
    return WBE_CLASSREG;
}

window_instance = CreateWindowEx(WS_EX_STATICEDGE,window_name,window_title,WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,window_width,window_height,NULL,NULL,main_instance,NULL);
if(window_instance == NULL){
    MessageBox(0,"There was an error creating a window.","Critical Error!",MB_ICONSTOP | MB_OK);
    return WBE_WINCREATION;
}

created = WbTrue;

return WB_SUCCESS;
}

我得到的错误是来自调试器的错误:未处理的异常,它表示.lpszMenuName 处的指针错误是一个问题,但这在可能的示例中有效,我不知道为什么。

发生了什么事,我该如何解决?
谢谢

4

1 回答 1

1

lpszClassName并被lpWindowName定义为 LPCSTR——window_name 和 window_title 是否有有效的字符串值?它们在哪里定义?

于 2013-04-11T18:37:15.043 回答