gpt4 book ai didi

c++ - 如何接收来自 Windows MessageBox 的反馈?

转载 作者:可可西里 更新时间:2023-11-01 10:53:50 25 4
gpt4 key购买 nike

我知道可以用 Windows 做这样的事情:

MessageBox(hWnd, "Yes, No, or Cancel?", "YNCB_YESNOCANCEL);

但是我如何对用户按下的内容使用react(比如如果他们单击"is"则关闭窗口)?

最佳答案

MessageBox将返回一个整数,指的是按下的按钮。来自上一个链接:

Return Value
IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
IDCONTINUE Continue button was selected.
IDIGNORE Ignore button was selected.
IDNO No button was selected.
IDOK OK button was selected.
IDRETRY Retry button was selected.
IDTRYAGAIN Try Again button was selected.
IDYES Yes button was selected.

所以像这样:

int result = MessageBox(hWnd, "Save work?", MB_YESNOCANCEL);
if (result == IDOK)
{
// ...
}
else if (result == IDNO)
{
// ...
}
else // cancel
{
// ...
}

关于c++ - 如何接收来自 Windows MessageBox 的反馈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1590702/

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