 |
 |

02-04-2004, 01:26 PM
|
|
Newcomer
|
|
Join Date: Dec 2003
Posts: 8
|
|
Parent form doesn't reappear
|
I've been searching for the past couple of hours and can't find anything. I have 2 forms: Form1 and Form2. Form1 is the parent, and Form2 is opened by Form1 as a Modal form.
In Form2_Load, I have: form1.Visible = False (so that Form2 has the focus)
In Form2_Unload, I have: form1.Visible = True (to give Form1 the focus)
What happens is, as Form2 is updating (consistent updates over a network) and I click "Close Window" or the X-button, the form goes away and Form1 is opened for a few milliseconds and disappears. I know it's still running, but I can't see it.
It works fine provided the buttons are clicked between updates, but each update is one second, so this is not a small problem.
Should I be using something else to hide the first form and get it back?
|
__________________
Aaron
Visual Studio .NET beginner
(But has reverted back to Visual Basic 6)
|

02-04-2004, 01:51 PM
|
|
Newcomer
|
|
Join Date: Feb 2004
Posts: 6
|
|
|
You should use Form2_QueryUnload instead of Form2_Unload event. This event is called everytime you click the "X" or unload the form.
Dominic
|
|

02-04-2004, 02:04 PM
|
|
Newcomer
|
|
Join Date: Dec 2003
Posts: 8
|
|
|
Ok. Did that, but I get the same result. Also, I've tried turning on and off the autoredraw and the Show and Hide methods. Everything I try gives me the same results.
I mean the autoredraw is turned off when it goes invisible and turned on when the form is visible again. I've removed it from the code since that didn't help, so it's currently not there.
|
__________________
Aaron
Visual Studio .NET beginner
(But has reverted back to Visual Basic 6)
|

02-04-2004, 02:09 PM
|
 |
Martian In Disguise
Retired Moderator * Guru *
|
|
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
|
|
Do you have any lines immediately following the
line that may be setting the visibility for the first form to false again.
Side Note: If you are displaying the second form modally, then is there a real need to hide the first form. Because the second form is modal, the user won't be able to get back to the first form until the modal one is hidden/unloaded.
|
__________________
The only stupid question is the one that goes un-asked.
|

02-04-2004, 02:17 PM
|
|
Newcomer
|
|
Join Date: Dec 2003
Posts: 8
|
|
|
Crap. Sorry about this. I just realized I couldn't use the Modal option for some reason and now I'm using the Modeless option. I'm really sorry I screwed that up. I'm sure that changes things.
To answer your question, no, there isn't any other line after that one. The full line is:
form2.Show vbModeless, Me
What I'm looking for it to do is open a new form and the main(controller) form is hidden until the client form is closed again. I'm planning on adding other forms as well, so whatever I do, I need to make sure that the main form is able to close any form that is opened from it. Does that make sense?
|
__________________
Aaron
Visual Studio .NET beginner
(But has reverted back to Visual Basic 6)
|

02-04-2004, 02:22 PM
|
 |
Martian In Disguise
Retired Moderator * Guru *
|
|
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
|
|
You may need to show us some of your code.
For a simple test, I did the following:
Code:
' Form 1
Private Sub Command1_Click()
Form2.Show vbModeless, Me
End Sub
Code:
' Form 2
Private Sub Form_Load()
Form1.Visible = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Form1.Visible = True
End Sub
When Form1 becomes visible again, it stays visible.
Do you have any code that is referencing Form2 after you have unloaded it? This would cause an instance of Form2 to be loaded again, triggering the Form_Load event. Which would be setting Form1.Visible = False again.
|
__________________
The only stupid question is the one that goes un-asked.
|

02-04-2004, 02:32 PM
|
|
Newcomer
|
|
Join Date: Dec 2003
Posts: 8
|
|
Quote: Originally Posted by 00100b Do you have any code that is referencing Form2 after you have unloaded it? This would cause an instance of Form2 to be loaded again, triggering the Form_Load event. Which would be setting Form1.Visible = False again.
That may be what's happening, because it is in the middle of an update to the textboxes on the form when I press the Close button (which calls "Unload Me"). Is there a way that I can have the form1.visible line wait to be executed until the Timer event has completely finished? I have the timer being disabled in the QueryUnload event right before the form1 is made visible again.
Also, I wanted to post the code earlier, but VB6 is installed on another computer in my office. I can get it if you really need it, I was just hoping it wouldn't be necessary.
I have an idea, so I'll let you know what happens when I try it.
|
__________________
Aaron
Visual Studio .NET beginner
(But has reverted back to Visual Basic 6)
|

02-04-2004, 02:48 PM
|
|
Newcomer
|
|
Join Date: Dec 2003
Posts: 8
|
|
|
Well, I got a different result. I added a variable that is set to TRUE when a process is started, and changes to FALSE when the process is completed. Now, Form2 doesn't want to close in the middle of a process. I assume that's because the QueryUnload interupts any function and that variable doesn't get changed to FALSE. Oh well. Got any ideas I can try?
|
__________________
Aaron
Visual Studio .NET beginner
(But has reverted back to Visual Basic 6)
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|