gpt4 book ai didi

c++ - 如何将 GDI+ 状态转换为字符串?

转载 作者:可可西里 更新时间:2023-11-01 14:15:22 26 4
gpt4 key购买 nike

实际上,主题。我还没有找到将 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 分钟绰绰有余!

关于c++ - 如何将 GDI+ 状态转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4933662/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com