Click to See Complete Forum and Search --> : Inputbox and Form together?


ultddave
October 24th, 2009, 06:19 PM
Hi all,

I'm having some trouble (again).
At the moment I'm trying to create and use a simple inputbox. (Like the one in Visual Basic)

I just created a simple Inputbox (=Windows Form) with a label, a button and a textbox.

In the eventhandler of the button I copy the content of the textbox to a global variable. And then I close the form using:

close();

Now I want to use the inputbox in another form.
So in "Form1" I'd like to call my inputbox. So I did this inside a public function of Form1:


inputbox window; // Create an Inputbox window

window.Show(); // Show it. => The window shows
window.focus(); // Change focus



But the problem is that the window (Inputbox) never gets focus and my "Form1" just keeps executing the lines after window.focus().

--> Is it possible to shift focus from my main program to the inputbox and when the inputbox closes (When I press the OKbutton on the inputbox), my main program will continue running.

So what I want is this in pseudo code:
- Open an inputbox where the user can enter text.
- Pause main program.
- User enters text in inputbox
- User presses OK button in inputbox
- Inputbox will validate input
- if the input is numerical => Save the input in a global variable and Close the inputbox
- When the inputbox closes, my mainprogram should continue running.

Is this possible? If so, how? ;)

Any help will be appreciated.

Greetz,
Dave

PS: The inputbox does not need to return a value. It just needs to get focus. ;)

cilu
October 25th, 2009, 01:48 AM
There are two types of windows: modal and modeless. A modal dialog takes the focus, and you cannot access the parent, until you close it. This you open with ShowDialog(). A modeless dialog does not retain the top of the Z order, and you can access its parent, without closing it first. This you open with Show().

As far as I understand you should use ShowDialog() instead of Show().

BTW, C++ and C++/CLI and C# are case sensitive.

cilu
October 25th, 2009, 01:49 AM
[ redirected ]

ultddave
October 25th, 2009, 02:50 PM
[ redirected ]

Sorry for that :).

There are two types of windows: modal and modeless. A modal dialog takes the focus, and you cannot access the parent, until you close it. This you open with ShowDialog(). A modeless dialog does not retain the top of the Z order, and you can access its parent, without closing it first. This you open with Show().

As far as I understand you should use ShowDialog() instead of Show().

BTW, C++ and C++/CLI and C# are case sensitive.

Many thanks :D. ShowDialog() solved this issue. ;)

Greetz,
Dave