Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Call 1 form from another
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00180717
Message ID:
00180746
Views:
17
>>>I have this main form with the foll properties(some)
>>>MODELESS
>>>AS TOP LEVEL FORM
>>>
>>>I call this from a .prg file
>>>
>>>DO FORM main
>>>READ EVENTS
>>>
>>>This runs OK as an EXE with a config.fpw line
>>>SCREEN=OFF
>>>
>>>On this form I have a command button that must launch another form, hiding the main form. This form - Form2, is now the top level form.
>>>MODAL
>>>AS TOP LEVEL FORM
>>>
>>>
>>>In the click of the button:
>>>retval = .F.
>>>DO FORM form2 TO retval
>>>
>>>I don't put a read events as it is not necessary(?)
>>>
>>>On click I get an error that the TO clause can only be used in MODAL form or forsets.
>>>My second form IS modal.I use the TO clause so that my app waits till the form is done and returns a value before continuing which is how I want it.
>>>
>>>I can only get this to work by making the form2 as IN TOP LEVEL FORM.
>>>
>>>How can I achieve this. It was easy in FPW2.6 to call forms upto 5 levels deep. If I use READ EVENTS to stop the processing of the next line, I have to issue CLEAR EVENTS in the form2 Destroy. This seems to roll back and clears the READ EVENTS of form MAIN.
>>>
>>>This is bugging me no end. Has anyone got a solution where I can call another form from a button of one form, wait for that form to finish and return a value, before executing th enext lines?? Form main must be hidden so I will need a TOP LEVEL form2??
>>>
>>
>>You can have only one top-level form in your application, just consider it as placeholder for all other forms (i.e. other forms will be open IN topform). You should have only one READ EVENTS (in the root of Main.prg) and btw it will handle modeless forms. There is no limit in opening sequence of modal forms, though generally it's not the best interface. FPW2.x was crippled invalid handling multiple medeless form, now in VFP each form (modeless) is independent (or should be independent) object which may communicate with other form's objects, exchanging values etc. However again, it does not prevent you from using modal forms which may return value straightforwardly by TO clause.
>
>To see if I understand what Ed's saying, as well as maybe clarify it, your situation (Bernard) will be improved if you make an empty top-level form, and create your main form inside it (MDI style app). Then your modal form can come on top of your "main" form no problem, but it can't be top-level. As Ed said, only one form can be top-level.
>
>Another thought: If you want your second (modal) form to hide your "main" form, why not do that literally? In the modal form's Load or Init event, you could HIDE FORMS ALL or HIDE FORM Main, then SHOW FORMS ALL or SHOW FORMS Main in the modal form's Unload event.
>
>HTH,

Basically, you understood me right, but the major point was that there is no necessity to use modal forms at all, and moreover HIDE/SHOW some forms. Give your user flexibility to open/close what s/he wants.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform