我使用switch进行消息判断总会出现这样的错误:
error C2360: initialization of 'setDlg' is skipped by 'case' label
see declaration of 'setDlg'
errorC2361: initialization of 'inspectingDlg'is skipped by 'default' label
see declaration of 'inspectingDlg'
下面是源代码BOOL CContralDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN||pMsg->wParam==VK_ESCAPE)
{
return -1;
}
switch(pMsg->wParam)
{
case VK_NUMPAD0 :
SendMessage(WM_CLOSE,0,0);
break;
case VK_NUMPAD1 :
Cinspectset* setDlg = new Cinspectset;
setDlg->Create(IDD_DIALOG_inspectset);
setDlg->ShowWindow(SW_SHOW);
break;
case VK_NUMPAD2 :
Cinspecting* inspectingDlg = new Cinspecting;
inspectingDlg->Create(IDD_DIALOG_inspect);
inspectingDlg->ShowWindow(SW_SHOW);
break;
default:
return true; }
}
return CDialog::PreTranslateMessage(pMsg);
}
当我注释掉case vk_numpad2这一个判断和相应的源代码时,又会出现这样的问题:
error C2361: initialization of 'setDlg' is skipped by 'default' label
只有把case vk_numbpad2和default那段注释掉,才没有错误
这是什么原因亚?救救我
error C2360: initialization of 'setDlg' is skipped by 'case' label
see declaration of 'setDlg'
errorC2361: initialization of 'inspectingDlg'is skipped by 'default' label
see declaration of 'inspectingDlg'
下面是源代码BOOL CContralDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN||pMsg->wParam==VK_ESCAPE)
{
return -1;
}
switch(pMsg->wParam)
{
case VK_NUMPAD0 :
SendMessage(WM_CLOSE,0,0);
break;
case VK_NUMPAD1 :
Cinspectset* setDlg = new Cinspectset;
setDlg->Create(IDD_DIALOG_inspectset);
setDlg->ShowWindow(SW_SHOW);
break;
case VK_NUMPAD2 :
Cinspecting* inspectingDlg = new Cinspecting;
inspectingDlg->Create(IDD_DIALOG_inspect);
inspectingDlg->ShowWindow(SW_SHOW);
break;
default:
return true; }
}
return CDialog::PreTranslateMessage(pMsg);
}
当我注释掉case vk_numpad2这一个判断和相应的源代码时,又会出现这样的问题:
error C2361: initialization of 'setDlg' is skipped by 'default' label
只有把case vk_numbpad2和default那段注释掉,才没有错误
这是什么原因亚?救救我
解决方案 »
- 如何解决这个错误:_WIN32_WINNT settings conflicts with _WIN32_IE setting
- 重绘,分不够的话可以在加的。
- 急救!!
- 请问哪里可以下载到最新的platform sdk?
- DVD文件格式哪里能找到?
- 我的一个while循环要花费大量的时间使系统好象死机,如何在执行他的时候让操作系统响应其他的操作?
- (高分求教)自画菜单的问题
- 关于VB6在NT和WIN2000下的安装问题?(100分,急)
- 列表控件SetItemState函数使用困惑?
- 手机短信息
- 我想做一个DIALOG的程序。在其中使用WebBrower控件。我想在其中动态的显示图片,文字。该如何做呢?
- 大家学了VC一般搞哪方面的开发呀?
要拿到case外面。
case语句中间不允许声明变量。
用{}把case后面的东西括起来就能解决了,我前两天也碰到个这样的问题。