Exemplo n.º 1
0
        }; // class InputBoxForm

        // Pop up an input box and ask the user a question.
        public static String InputBox
            (String Prompt,
            [Optional][DefaultValue("")] String Title,
            [Optional][DefaultValue("")] String DefaultResponse,
            [Optional][DefaultValue(-1)] int XPos,
            [Optional][DefaultValue(-1)] int YPos)
        {
            // Consult the host to find the input box's parent window.
            IVbHost      host;
            IWin32Window parent;

            host = HostServices.VBHost;
            if (host != null)
            {
                parent = host.GetParentWindow();
            }
            else
            {
                parent = null;
            }

            // Pop up the input box and wait for the response.
            InputBoxForm form = new InputBoxForm
                                    (Prompt, Title, DefaultResponse, XPos, YPos);
            DialogResult result       = form.ShowDialog(parent as Form);
            String       resultString = form.Result;

            form.DisposeDialog();

            // Return the result to the caller.
            if (result == DialogResult.OK)
            {
                return(resultString);
            }
            else
            {
                return(String.Empty);
            }
        }