(C ++)MessageBox for Linux like MS Windows [英] (C++) MessageBox for Linux like in MS Windows

查看:720
本文介绍了(C ++)MessageBox for Linux like MS Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为Linux(SDL)应用程序实现一个简单的图形消息框,类似于C ++中的Windows MessageBox(gcc / g ++ 4.4.0)。所有它需要做的是显示一个字幕,一个消息和一个确定或关闭按钮,并在该按钮被点击时返回调用函数。

I need to implement a simple graphical message box for a Linux (SDL) application similar to the Windows MessageBox in C++ (gcc/g++ 4.4.0). All it needs to do is to display a caption, a message and an ok or close button and to return to the calling function when that button is clicked.

SDL只是使用X(11)打开一个窗口为(OpenGL)渲染。

SDL just uses X(11) to open a window for (OpenGL) rendering.

我已经看过一个类似的线程关于GTK实现,但该实现似乎不工作

I have looked through a similar thread regarding a GTK implementation, but that implementation doesn't seem to work properly.

我也试过wxWidgets的wxMessageBox函数,但编译头使编译器抛出关于语法错误的错误信息include / c ++ / 4.4.0 / bits / stl_algobase.h(gcc 4.4.0 32位在openSuSE 11.1 32位)。使用wxWidgets还意味着必须链接一个库,添加STL到我的应用程序(它不需要其他),谁知道什么,所以我不想使用wxWidgets。

I have also tried wxWidgets' wxMessageBox function, but compiling the headers makes the compiler throw error messages about syntax errors in include/c++/4.4.0/bits/stl_algobase.h (gcc 4.4.0 32 bits on openSuSE 11.1 32 bits). Using wxWidgets also means having to link a ton of libraries, adding STL to my app (Which it doesn't need otherwise) and who knows what else, so I do not want to use wxWidgets.

X11 / motif(openmotif)有我需要的(XmCreate {Error | Warning | InfoDialog),但是这些需要一个父窗口部件(例如顶级窗口),我没有并且不接受NULL这些的参数。

X11/motif (openmotif) has what I need (XmCreate{Error|Warning|InfoDialog), but these need a parent widget (e.g. top level window) which I don't have and do not accept a NULL parameter for these.

所以我现在陷入困境。有什么简单的方法来做我想要的吗?或至少一半简单/容易/直截了当?

So I am stumped right now. Is there a simple way to do what I want? Or at least a halfway simple/easy/straightforward one? If yes, which one (giving as many details as possible would be highly appreciated).

推荐答案

在SDL2中,您现在可以显示消息框:

In SDL2, you can now show message boxes:

http://wiki.libsdl.org / SDL_ShowSimpleMessageBox

int SDL_ShowSimpleMessageBox(Uint32      flags,
                             const char* title,
                             const char* message,
                             SDL_Window* window)

http://wiki.libsdl.org/SDL_ShowMessageBox

int SDL_ShowMessageBox(const SDL_MessageBoxData* messageboxdata,
                       int*                      buttonid)

这篇关于(C ++)MessageBox for Linux like MS Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆