-
October 24th, 2009, 05:19 PM
#1
Inputbox and Form together?
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:
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:
Code:
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.
-
October 25th, 2009, 12:48 AM
#2
Re: Inputbox and Form together?
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.
-
October 25th, 2009, 12:49 AM
#3
Re: Inputbox and Form together?
-
October 25th, 2009, 01:50 PM
#4
Re: Inputbox and Form together?
Originally Posted by cilu
[ 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 . ShowDialog() solved this issue.
Greetz,
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|