Aros/开发人员/Zune/示例/请求者
外观
有时需要打开一个消息框,向用户显示简短的消息。这可能是一条错误消息或类似信息。
为此,ZUNE 提供了 **MUI_Request**。
它是这样工作的
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <libraries/mui.h>
int main (int argc, char **argv) {
struct Library *MUIMasterBase = NULL;
// open Zune (=MUI) library
if (MUIMasterBase = (struct Library *) OpenLibrary("muimaster.library", 0)) {
// create application and window, the root objects of any Zune application:
// window need minimum content to open, so we add a TextObject
Object *window;
Object *app = ApplicationObject,
SubWindow, window = WindowObject,
WindowContents, TextObject,
MUIA_Text_Contents, "Inside your window.",
End,
End,
End;
if (app) {
// open window:
set(window, MUIA_Window_Open, TRUE);
// test if opening window was successful:
IPTR open;
get(window, MUIA_Window_Open, &open);
if (open) {
// show requester:
MUI_Request(app, window, 0L, "MessageBox Title", "Close button text", "Your Message Text", NULL);
// close window, and dump objects:
set(window, MUIA_Window_Open, FALSE);
}
MUI_DisposeObject(app);
}
CloseLibrary(MUIMasterBase);
}
}
注意:在上面的示例中,为了节省输入并获得更清晰的视图,使用了一些 C 宏(ApplicationObject、WindowObject、SubWindow、set() 和 get()),这些宏在 <libraries/mui.h> 中定义,请参阅更多 C 宏,以及 ZUNE 宏的实际作用。
gcc [sourcefile] -lmui
它看起来是这样的
此示例在 2010 年 3 月 10 日的 AROS 上进行了测试。