注册窗口类时出错

bcjava 2004-04-26 07:02:20
源程序如下:
WNDCLASS wndclass;
wndclass.style =CS_HREDRAW|CS_VREDRAW;
wndclass.lpfnWndProc =WndProc;
wndclass.cbClsExtra =0;
wndclass.hInstance =0;
wndclass.hIcon =LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor =LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName =NULL;
wndclass.lpszClassName =szClassName;

if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("Error!"),
szAppName,MB_ICONERROR);
return 0;
}

执行时弹出了Error对话框,(windows xp操作系统),请教一下这是怎么回事,谢谢:_)
...全文
68 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouqingyuan 2004-04-26
  • 打赏
  • 举报
回复
Although a complete window class consists of many elements, the system requires only that an application supply a class name, the window-procedure address, and an instance handle.


注册时候,有三个元素是不能缺省的,
wndclass.lpszClassName wndclass.lpfnWndProc wndclass.hInstance
zhouqingyuan 2004-04-26
  • 打赏
  • 举报
回复
wndclass.hInstance =0;//不能为0,要赋值

The executable or DLL that registered the class is the owner of the class. The system determines class ownership from the hInstance member of the WNDCLASSEX structure passed to the RegisterClassEx function when the class is registered. For DLLs, the hInstance member must be the handle to the .dll instance.

rorot 2004-04-26
  • 打赏
  • 举报
回复
// 改这里
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;

24,855

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧