How to "RUN" one form from another

Posted by mstassen on 24-Sep-2008 08:14

Can somebody help me on how to start form B from a button in form A ?

All Replies

Posted by Roger Blanchard on 24-Sep-2008 08:30

I use the following from the DoubleClick event of an UltraGrid. I would think it would be the same from a button click event.

DEFINE VARIABLE rChildForm AS DeptMaint NO-UNDO.

rChildForm = NEW DeptMaint().

rChildForm:WindowState = System.Windows.Forms.FormWindowState:Maximized.

rChildForm:Show().

Posted by mstassen on 24-Sep-2008 08:46

It says "debtMaint was not found"...

Posted by Admin on 24-Sep-2008 09:01

debtMaint needs to be the class name of the 2nd Form you try to open.

What's the filename of the second form?

Posted by mstassen on 24-Sep-2008 09:12

The second form is ImportDef.cls which is in the project PrijslijstImport

As first form I have a procedure now (to test it):

DEFINE VARIABLE rChildForm AS ImportDef NO-UNDO.

rChildForm = NEW ImportDef().

rChildForm:WindowState = System.Windows.Forms.FormWindowState:Maximized.

rChildForm:Show().

Posted by Roger Blanchard on 24-Sep-2008 09:24

Mike ir correct. The deptMaint was the name of my class. you have to substiture your class name.

Posted by mstassen on 24-Sep-2008 09:25

I figured that out already. And i did as you can see. But stil ImportDef not found...

Posted by Roger Blanchard on 24-Sep-2008 09:27

It may be a propath issue if it is in a different project. You can adjust your propath to include a different project.

Posted by mstassen on 24-Sep-2008 09:38

It' all in the propath of the project: i even did add the external dir to the propath.

Posted by mstassen on 24-Sep-2008 09:42

but i see that it is a propath issue.

Putting this statemant at first the error is gone:

PROPATH = PROPATH + ",d:\DLC102\PrijslijstImport".

Very Strange !!!

Posted by mstassen on 24-Sep-2008 09:47

in the run configuration, additional startup parameters, i used -basekey INI -ininame. In this ini there is a propath setting. Deleting this startup parameter it works.

Does this parameter override the propath setting from the run configuartion ??

Posted by mstassen on 24-Sep-2008 09:54

Solved the propath issue.

Now the next thing. My code:

DEFINE VARIABLE rChildForm AS ImportDef NO-UNDO.

rChildForm = NEW ImportDef().

rChildForm:WindowState = System.Windows.Forms.FormWindowState:Maximized.

rChildForm:Show().

Shows the ImportDef for just a second and then it's gone again.

Can you help me with this?

Posted by jankeir on 24-Sep-2008 10:00

You need a wait for, exactly one wait for. In your original inquiry you said you already had a form running and wanted to start a second one from a button, that would indicate you already had a wait for.

Posted by Roger Blanchard on 24-Sep-2008 10:05

I run the following code in my startup procedure to load my MainMenu and then WAIt-FOR it to exit. I can then open other windows, enter data and then exit.

DO ON ERROR UNDO, LEAVE

ON ENDKEY UNDO, LEAVE

ON STOP UNDO, LEAVE

ON QUIT UNDO, LEAVE:

rUnifyHOST = NEW MainMenu( ) .

WAIT-FOR Application:Run(rUnifyHOST).

END.

Posted by mstassen on 24-Sep-2008 10:11

i have started or old application in 10.2 beta. It works.

I took an old screen which is started from the application-menu and added a button to it:

ON CHOOSE OF butOE102 IN FRAME Brws-Frame /* RUN OE10.2 prog */

DO:

MESSAGE "1".

DEFINE VARIABLE rChildForm AS ImportDef NO-UNDO.

MESSAGE "2".

PROPATH = PROPATH + ",d:\DLC102\PrijslijstImport".

MESSAGE "3".

rChildForm = NEW ImportDef().

MESSAGE "4".

rChildForm:WindowState = System.Windows.Forms.FormWindowState:Maximized.

MESSAGE "5".

rChildForm:Show().

MESSAGE "6".

It stops after message 3.

What am i missing here?

Posted by Admin on 24-Sep-2008 11:50

Hi Maurice,

Ignore my response ... I see you have identified it as a PROPATH issue!!

Regards,

M

Posted by mstassen on 25-Sep-2008 01:49

thank you for your help so far.

Did you see my last (new) problem, too?

Posted by jankeir on 25-Sep-2008 02:16

Does the form work when you start it straight from the visual designer? It sounds like there's a problem in the constructor.

Posted by mstassen on 25-Sep-2008 03:01

yes, the forms works when running form the designer !

Posted by Admin on 25-Sep-2008 03:41

Have you tried creating and running a blank form?

If this works then I would take a backup of the form you are having a problem with and start stripping/commenting out the code. It can take a while, but I'm sure you'll identify the problem.

Posted by mstassen on 25-Sep-2008 03:50

it hangs on:

rChildForm = NEW ImportDef().

Posted by Admin on 25-Sep-2008 04:04

I was wondering if you created a new form with nothing on it and then created and showed that instead, whether that worked.

In addition to this have you tried putting messages in the Form constructor to see if this gets called?

Posted by mstassen on 25-Sep-2008 10:02

nope two times:

- the empty form does not load also

- the contructor does not get pass teh super() (which has to be the first statement)

Take youre time. I won't be back on this untill next week...

Posted by rbf on 25-Sep-2008 14:42

The second form is ImportDef.cls which is in the

project PrijslijstImport

As first form I have a procedure now (to test it):

DEFINE VARIABLE rChildForm AS ImportDef NO-UNDO.

rChildForm = NEW ImportDef().

rChildForm:WindowState =

System.Windows.Forms.FormWindowState:Maximized.

rChildForm:Show().

Maurice,

Have you tried (instead of fixing the PROPATH):

DEFINE VARIABLE rChildForm AS PrijslijstImport.ImportDef NO-UNDO.

rChildForm = NEW PrijslijstImport.ImportDef().

rChildForm:WindowState = System.Windows.Forms.FormWindowState:Maximized.

rChildForm:Show().

-peter

Posted by mstassen on 01-Oct-2008 07:28

On

DEFINE VARIABLE rChildForm AS PrijslijstImport.ImportDef NO-UNDO.

i get the compile error:

Invalid datatype specified: PrijslijstImport.ImportDef. Specify a datatype such as 'character' or the name of a class. (5638)

??

Posted by jmls on 01-Oct-2008 07:34

I think this means that the PrijslijstImport directory is not in the PROPATH

Posted by mstassen on 01-Oct-2008 07:42

it is in the propath of the project. But i still get the compilation error....

Posted by Matt Baker on 01-Oct-2008 08:17

You would not want PrijslijstImport in the PROPATH if PrijslijstImport is a package name You would want its parent directory in the PROPATH.

Posted by jmls on 01-Oct-2008 08:21

yeah, that's what I meant !!

 * jmls blushes

Posted by mstassen on 01-Oct-2008 08:42

The problem seems to be in finding the project/class/package or something.

From one form within the project to another form within the project it works.

But calling a form (from the project) form a cmplete other window wich has no reference to the project (our old application) it doe not work...

Message was edited by:

Maurice Stassen

Posted by Admin on 03-Oct-2008 05:57

Perhaps you have a conflict with database name or table.

I recall i had an issue like that becuase i gave my package the same name as the database. When i renamed my package structure the problems were gone.

Message was edited by:

John Kattestaart

Posted by mstassen on 03-Oct-2008 09:52

In the new beta drop it works a bit better.

The screen is actually build en shown !

But then i get:

rsion 6 database. (1033) error

?? Any idea ??

Posted by mstassen on 03-Oct-2008 09:54

and after that i get:

Run-time error in WAIT-FOR at line 3717 (relative to expanded source) of mainProcedure (3269)

This thread is closed