其实是主题。我还没有找到将GDI + Status
(GDI +方法返回的错误状态)转换为字符串的任何标准方法,例如FormatMessage()
最佳答案
如果要将GDI+ Status中的标签转换为字符串,那么最简单的操作是:
const char* StatusMsgMap[] =
{
"Ok", //StatusMsgMap[Ok] = "Ok";
"GenericError", //StatusMsgMap[GenericError] = "GenericError";
"InvalidParameter", //StatusMsgMap[InvalidParameter] = "InvalidParameter";
"OutOfMemory", //StatusMsgMap[OutOfMemory] = "OutOfMemory";
//so on
};
//Usage:
std::string error = StatusMsgMap[status]; // where status is Status type!
或者,如果您想要更多描述性的消息,请执行以下操作:
const char* StatusMsgMap[] =
{
"the method call was successful",
"there was an error on the method call, which is identified as something other than those defined by the other elements of this enumeration",
"one of the arguments passed to the method was not valid",
//so on
};
由于Status枚举中只有22个标签,以我的观点,以上述方式创建
StatusMsgMap
并不是一件容易的事。 5分钟绰绰有余!