如何从Excel的XLL功能中显示消息框? [英] How do I show a messagebox from Excel's XLL function ?
本文介绍了如何从Excel的XLL功能中显示消息框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在函数中有以下代码片段,我需要显示用户的错误消息。但是没有显示该消息。只有回报的价值......我做错了什么?
问候。
I have the following piece of code inside a function and I need to shows a user's error message. But the message is not shown. Only the return's value... What did I do wrong ?
Regards.
const double dia = 1.0;
xloper xStr, xInt;
xStr.xltype = xltypeStr;
xStr.val.str = new_xlstring("User's message.");
xInt.xltype = xltypeInt;
xInt.val.w = 2;
if(terNum < segNum)
{
Excel4(xlcAlert, NULL, 2, &xStr, &xInt);
return 0.0;
}
free(xStr.val.str);
推荐答案
我从未管理过让xlcAlert在函数中工作。所以,我使用MessageBoxW。下面是一个示例,使用您的代码作为起点,它起作用:
I have never managed to get xlcAlert to work in functions. So, I use MessageBoxW. Here is an example, using your code as a starting point, which works:
__declspec(dllexport) LPXLOPER12 XLLShowMessageA (void)
{
static XLOPER12 xReturn;
int terNum, segNum, rc;
terNum = 1;
segNum = 2;
xReturn.xltype = xltypeNum;
xReturn.val.num = 0;
if (terNum < segNum)
{
MessageBoxW (NULL, L"User message.", L"Dialog title.",
MB_OK | MB_SETFOREGROUND );
return &xReturn;
}
return &xReturn;
}
David Wilkinson(英国)
David Wilkinson (UK)
这篇关于如何从Excel的XLL功能中显示消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文