Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange behavior

Status
Not open for further replies.

Eugen Fintina

Programmer
Apr 27, 2005
29
RO
I have two forms (Form_01 and Form_02). Both have properties sets like:
AlwaysOnTop = .T.
WindowType = 1 – Modal

In a custom method of Form_01 I have the following code:
Code:
Local lnParam
lnParam = 2

With Thisform
	.Visible = .F.
	Do Form Form_02 With lnParam
	.Visible = .T.
Endwith

When I call this method, Form_01 is over Form_02.
But, if I add a code line, like:
Code:
Local lnParam
lnParam = 2

With Thisform
	.Visible = .F.
	[COLOR=#EF2929][b]Wait Timeout 0.001[/b][/color]
	Do Form Form_02 With lnParam
	.Visible = .T.
Endwith

Form_02 is over Form_01 as I wish.
But, Form_01 is also visible.
If I close Form_02 and reopen it using the same method all works as I wish (Form_01 is not visible).

All the bests,
Eugen
 
Still not sure if this is what you want, but do you want each form to be open by itself, that is, for Form 2 to close while Form 1 is open, and for Form 1 to close while Form 2 is open.

If that is what you want, rather than opening and closing the forms each time, you can leave them both open the whole time and simply toggle their Visible property. Having a modal form open but invisible is OK. It won't prevent the user interacting with other parts of the interface (as would be the case with a modal form that remained visible).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Sorry, Mike. I think that I was not clear.
I have two forms (Form 1 and Form 2). Both have properties sets like:
AlwaysOnTop = .T.
WindowType = 1 – Modal

Desired behavior:
1. Form 1 was opened and is visible
2. Call the method that belong to Form 1
2.1. Form 1 is hidden
2.2. Form 2 is open
2.3. Form 2 can be close
2.4 Form 1 is visible

Code:
Local lnParam
lnParam = 2

With Thisform
	.Visible = .F.
	Do Form Form_02 With lnParam
	.Visible = .T.
Endwith
Case 1. Using a REGULAR method (eg. Click Method of a Command Button) that belong to Form 1 all works as I wish.
All is Ok

Code:
Local lnParam
lnParam = 2

With Thisform
	.Visible = .F.
	Do Form Form_02 With lnParam
	.Visible = .T.
Endwith
Case 2. Using a CUSTOM method that belong to Form 1 and have the same code as regular one that was used in case 1, I have the following behavior:
1. Form 1 was opened and is visible
2. Call the custom method
2.1. Form 1 is still visible
2.2. Form 2 is open BUT UNDER Form 1
2.3. Form 2 can not be close
2.4. Form 1 can not be close

Code:
Local lnParam
lnParam = 2

With Thisform
	.Visible = .F.
	[b][COLOR=#EF2929]Wait Timeout 0.001[/color][/b]
	Do Form Form_02 With lnParam
	.Visible = .T.
Endwith

Case 3. Add a new line code in CUSTOM method and I have the following behaviour:
1. Form 1 was opened and is visible
2. Call the custom method
2.1. Form 1 is still visible
2.2. Form 2 is open OVER Form 1.
2.3. Form 2 can be close
3. If I call again the custom method all is ok like in Case 1.

All I want to understand is why I have this difference behavior between REGULAR Method and CUSTOM one and what can I do to avoid it.

All the bests,
Eugen
 
No idea what happens in detail, but you should perhaps use the Form.Hide() and Form.Show() methods instead of setting the visible property. And for that you should only start forms once. If you DO FORM multiple times, you actually have the forms open as many times as you DO them.

Chriss
 
Yes, Chris, that's what I suggested in my second post. Keep the two forms open the whole time, and just hide or show them as necessary.

But I don't think it will make any difference whether he uses Form.Hide() and Form.Show() or whether he toggles the Visible property. As far as I know, the effect is exactly the same.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top