有一段代码看不懂,不知道什么意思,望高手指点! VS2005 中MFC的代码
#defineCATCH_MSGBOX(Caption)\catch(GenICam::GenericException&e)\{\CStringBuffer,B;\Bu...
#define CATCH_MSGBOX( Caption ) \
catch( GenICam::GenericException &e ) \
{ \
CString Buffer, B; \
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B); \
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B); \
MessageBox(Buffer, _T(Caption), MB_OK | MB_ICONEXCLAMATION); \
} \
catch (...) \
{ \
GenICam::GenericException e (Caption, "CCodeRecogOnLineDlg", 0); \
CString Buffer, B; \
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B); \
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B); \
MessageBox(Buffer, _T(Caption), MB_OK | MB_ICONEXCLAMATION); \
} 展开
catch( GenICam::GenericException &e ) \
{ \
CString Buffer, B; \
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B); \
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B); \
MessageBox(Buffer, _T(Caption), MB_OK | MB_ICONEXCLAMATION); \
} \
catch (...) \
{ \
GenICam::GenericException e (Caption, "CCodeRecogOnLineDlg", 0); \
CString Buffer, B; \
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B); \
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B); \
MessageBox(Buffer, _T(Caption), MB_OK | MB_ICONEXCLAMATION); \
} 展开
4个回答
展开全部
这是宏,没有返回值,功能只是用下面的代码替换CATCH_MSGBOX,
再用参数替换catch后面Caption
比如 CATCH_MSGBOX( abc ) 编译器就把它编译成下面这样
catch( GenICam::GenericException &e )
{
CString Buffer, B;
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B);
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B);
MessageBox(Buffer, _T(abc/*注意这里*/), MB_OK | MB_ICONEXCLAMATION);
}
catch (...)
{
GenICam::GenericException e (abc/*注意这里*/, "CCodeRecogOnLineDlg", 0);
CString Buffer, B;
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B);
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B);
MessageBox(Buffer, _T(abc/*注意这里*/), MB_OK | MB_ICONEXCLAMATION);
}
再用参数替换catch后面Caption
比如 CATCH_MSGBOX( abc ) 编译器就把它编译成下面这样
catch( GenICam::GenericException &e )
{
CString Buffer, B;
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B);
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B);
MessageBox(Buffer, _T(abc/*注意这里*/), MB_OK | MB_ICONEXCLAMATION);
}
catch (...)
{
GenICam::GenericException e (abc/*注意这里*/, "CCodeRecogOnLineDlg", 0);
CString Buffer, B;
Buffer += (B.Format("Exception 0x%X occurred\n", e.what() ), B);
Buffer += (B.Format("Message = %s\n", e.GetDescription() ), B);
MessageBox(Buffer, _T(abc/*注意这里*/), MB_OK | MB_ICONEXCLAMATION);
}
参考资料: 经验
展开全部
表示拆分了一行的代码语句,多用在很的宏定义上,你这上面有分号。所以这里用不用那个反斜杠就没有多大有处了。
追问
这个程序说的是什么意思,我一点看不懂,初学着,看别人的程序,想问问,最后的CATCH_MSGBOX得到的值是什么类型的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
在 vs安装目录\vc\atlmfc\src 里
用“在文件中查找”比较方便。
用“在文件中查找”比较方便。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
表示拆分了一行的代码语句,多用在很的宏定义上,你这上面有分号。所以这里用不用那个反斜杠就没有大有处了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询