I'm trying to show up a dialog box in a .NET app.I read at www.functionx.com but I haven't found anything related to this.
I have a form with the dialog(Form) and the main window(Form1)
I have a button called button2
I tryed to use:
Application::Run(gcnew Form()); is for getting the main form running only.
From there, to launch a new form call the Show() or ShowDialog() method of the new form - ShowDialog() makes the new form 'Modal' - IE it takes focus and the calling form doe not continue until the new form closes.
So if your new form is Form, you want
I tried
ShowDialog(gcnew Form());
but at debugging says:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Form that is already visible cannot be displayed as a modal dialog box. Set the form's visible property to false before calling showDialog.
As I understand it you have 2 headers, Form1.h which contains the class Form1, and Form.h which contains the class Form.
In Form1.h you have the Dialog1Run() event handler.
Form1.h needs to have #include "Form.h" so it knows what the definition of Form is.
Note: I would advise in future you try to give better names to forms (VS defualts the first one when you create the project, but any subequent forms take the name from the file you add, so add 'OptionsEditor' as the name of the file for a dialog to edit options for example to get 'OptionsEditor.h' containing class 'OptionsEditor' - it will make it easier to keep track of what things are as your projects grow.