UE4和C++ 开发-FPlatformMisc::MessageBoxExt是什么?

1、使用 FPlatformMisc::MessageBoxExt 函数来打开系统消息对话框

#include "Runtime/Core/Public/GenericPlatform/GenericPlatformMisc.h"
 
void AMyTestActor::TestMessageBoxExt()
{
	FText Message = FText::FromString("This is a message.");
	FText Title = FText::FromString("Message Box");
	EAppMsgType::Type Type = EAppMsgType::Ok;
 
	EAppReturnType::Type ret = FPlatformMisc::MessageBoxExt(Type, *Message.ToString(), *Title.ToString());
 
	switch (ret)
	{
	case EAppReturnType::Ok:
		UE_LOG(LogTemp, Log, TEXT("User clicked OK."));
		// 处理用户确认...
		break;
	case EAppReturnType::Cancel:
		UE_LOG(LogTemp, Log, TEXT("User clicked Cancel."));
		// 处理用户取消...
		break;
	}
}

在这个示例中,我们使用了 FPlatformMisc::MessageBoxExt 函数来打开一个简单的消息对话框。Message 参数指定了对话框显示的消息文本Title 参数指定了对话框的标题Type 参数指定了对话框按钮类型。

如果用户单击了对话框上的“确定”按钮,则 FPlatformMisc::MessageBoxExt 函数返回 true。否则,它将返回 false。你可以使用这个返回值来处理用户的选择。

猜你喜欢

转载自blog.csdn.net/2201_75598244/article/details/132817586