代码之家  ›  专栏  ›  技术社区  ›  sorin

如何在C++上显示一个Mac上的模态消息框?

  •  1
  • sorin  · 技术社区  · 16 年前

    CFUserNotificationDisplayAlert 和 CFUserNotificationDisplayNotice 创建一个 非模态窗口 这很糟糕,因为如果您选择原始的应用程序窗口(消息框是隐藏的,但应用程序没有响应),它可能会使您的应用程序UI处于非常不需要的状态。

    老年人 SystemAlert 是模态的,但此字符串不完全支持Unicode字符串。

    如何在Mac下将消息框显示为模式窗口?我在找类似于Windows中的MessageBox的东西?

    3 回复  |  直到 9 年前
        1
  •  5
  •   akib khan Jorge Arimany    9 年前

    我已经用 CFUserNotificationDisplayAlert 直到用户关闭消息框,它才会返回。

    如果你想看一下代码,我已经有了 MessageBox function in Mac 在这里,您将发现一个为Mac实现的MessageBox函数,它只为mb ou okcancel实现,但是如果代码再多一点,就可以覆盖整个MessageBox标志和返回值,这是一个很好的起点。

        2
  •  4
  •   sorin    16 年前

    看起来 CreateStandardAlert 是正确的解决方案,因为这个是 情态动词 .

    
    DialogRef theItem;
    DialogItemIndex itemIndex;
    CreateStandardAlert(kAlertNoteAlert, CFSTR("aaa"), CFSTR("bbb"), NULL, &theItem);
    RunStandardAlert(theItem, NULL, &itemIndex);
    
        3
  •  1
  •   Vladimir    16 年前

    看一看 NSBeginAlertSheet 职能部门或NSAP:

    - (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow
          modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo
    

    可能是你想要的。 Here 也是一篇关于使用工作表的好文章。