Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


MessageBox with empty caption

  • Hi all,
    is it possible to test for MessageBox with empty caption?

    Is set an Expectation for a modal window like this:
    ExpectModal(String.Empty, "CloseMessageBox");

    And when the MessageBox is Displayed the delegate CloseMessageBox is correctly called.
    The code of the CloseMessageBox method is:

    private void CloseMessageBox() {
        MessageBoxTester msgBox = new MessageBoxTester(String.Empty);

    but the msgBox.Count is 0. And the messageBox is not closed.
    Thanks for your help.

  • Mark Freedman
    Mark Freedman

    I had the same problems that you were having, in that the MessageBoxTester couldn't get a handle on the message box.  My solution was to add Captions to all of the Message Boxes.  It's clearer to the operator to see boxes with captions, IMO.

  • lhab

    With the latest svn rev, you can register a handler that takes the window handle of the message box as argument, and pass that handle to the message box tester constructor.

    ModalFormHandler = delegate(string name, IntPtr hwnd, Form f)
        MessageBoxTester mbt = new MessageBoxTester(hwnd);
        // whatever you please; you may for instance use mbt.Text to check that you really get the expected msg box

    The handlers you input into ModalFormHandler are single-shot, a new one should be installed before any modal form is expected.