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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overlapping forms in vfp

Status
Not open for further replies.

eyeshield21

Programmer
Aug 13, 2014
62
PH
i used this code to close my current form and loads another form..
THISFORM.release
DO FORM C:\form...

it loads the new form but it overlaps the current form then
another click is needed to close the first form..
 
It doesn't matter, if you do Thisform.Release first or last, the release events (unload/destroy) only run after the whole method finishes. You may test with MESSAGEBOX() instead of DO FORM.
If you need a click, then something keeps you first form up and running, does a release work without doing anything else (neither DO FORM nor MESSAGEVOX)?

Bye, Olaf.
 
If you want to run one form imkmediately after another, a better approach is to call each one in turn from the same place.

So, at the point at which you call Form 1, you would do this:

[tt]DO FORM Form1
DO FORM Form2[/tt]

If Form1 is modal, then Form2 will open after Form1 is closed. It doesn't matter how you close Form1: it could be with RELEASE, or by the user clicking the X button. This is different from the way you are doing it now, in that, if the user clicks the X button, Form2 will never open.

If Form1 is not modal, then both forms will appear on the screen at the same time.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
What Mike said last is a very wise decision to go about starting forms in a sequence.
I think what form has to be started next may depend on input/selction choices made in the first form. Then you'd put it slightly different, eg

Code:
DO FORM Form1 TO result
If result ...
   DO FORM Form2
Else
   DO FORM Form3...
Endif

Which also needs a modal form, as the TO clause needs a modal form and what you return from unload is arriving in the result variable specified after TO.

And a totally different idea to go about this would be using a form with a pageframe and navigating from page to page automatically rather than manually. You can set pageframe.tabs=.f. and the user can't switch betweeen pages as he likes, but you can still switch display depending on choices made.

And a third solution would define an empty area, where you create containers at runtime. The container class and the page class are separate, single pages are newer than the container, but you can compose a pageframe at runtime with page classes, the same goes for grids and columns, the concept here is member classes. But these are surely advanced techniques.

Bye, Olaf.
 
One other possibility:

If Form1 is modeless AND Form2 is modal AND you want Form1 to invoke Form2 only if a certain condition is met, you can simply invoke Form2 from Form1, more or less like you are doing now:

Code:
* In Form1:
IF <some condition is met>
  DO Form2
ENDIF

This will result in Form2 being active. Form1 will still be visible, but the user won't be able to do anything with it (because Form2 is modal). (This might be what you mean when you say "it overlaps the current form".)

If you don't want the user to see Form1 while they are working in Form2, rather than closing it you can make it temporarily invisible. (I stress that this will only work if Form2 is modal.)

Code:
* In Form1:
IF <some condition is met>
  THISFORM.Visible = .F.
  DO Form2
  THISFORM.Visible = .T.
ENDIF

But I'm not sure why you would want to do that.

On balance, I think my first answer is the one to go for.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

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

Part and Inventory Search

Sponsor

Back
Top