Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Parent form doesn't reappear


Reply
 
Thread Tools Display Modes
  #1  
Old 02-04-2004, 01:26 PM
Blue_Q Blue_Q is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default 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)
Reply With Quote
  #2  
Old 02-04-2004, 01:51 PM
Robido1 Robido1 is offline
Newcomer
 
Join Date: Feb 2004
Posts: 6
Default

You should use Form2_QueryUnload instead of Form2_Unload event. This event is called everytime you click the "X" or unload the form.

Dominic
Reply With Quote
  #3  
Old 02-04-2004, 02:04 PM
Blue_Q Blue_Q is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default

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)
Reply With Quote
  #4  
Old 02-04-2004, 02:09 PM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

Do you have any lines immediately following the
Code:
Form2.Show vbModal
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.
Reply With Quote
  #5  
Old 02-04-2004, 02:17 PM
Blue_Q Blue_Q is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default

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)
Reply With Quote
  #6  
Old 02-04-2004, 02:22 PM
00100b's Avatar
00100b 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

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.
Reply With Quote
  #7  
Old 02-04-2004, 02:32 PM
Blue_Q Blue_Q is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default

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)
Reply With Quote
  #8  
Old 02-04-2004, 02:48 PM
Blue_Q Blue_Q is offline
Newcomer
 
Join Date: Dec 2003
Posts: 8
Default

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)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retreving a control in a parent form when the current form is in a tab control RanmaGuy .NET General 2 12-21-2003 11:34 AM
disable print preview from xlDialogPrint w_seyller Excel 9 12-11-2003 11:20 AM
Can an OCX refer to Parent Form Properties? WildGoose General 3 11-27-2003 05:05 AM
MDI Form and dimensions kkonkle Interface and Graphics 6 03-26-2003 09:50 AM
Create a new form similar to an existing form ric General 6 07-17-2001 12:47 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->