Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Closing a modal form
Message
From
27/05/2023 14:09:39
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01686646
Message ID:
01686677
Views:
23
>Thank you, Lutz.
>I am thinking of going back to the modal popup form. The only thing that it would not have - unless I implement event method that you suggested - is ability to close the form when a user clicks outside the form. Other than that everything will work.
>I suspect that to make the MODELESS form pass a value to the calling procedure and then calling procedure being "in control" after the popup form is hidden, will take too many jumps through the hoop.

It's rather simple, two forms, one calling the other and return value on deactivate the second, then the first closes the second.
PUBLIC poMyForm
poMyForm = CREATEOBJECT("myform")
poMyForm.VISIBLE = .T.

DEFINE CLASS myform2 AS FORM
 AUTOCENTER = .T.
 ALLOWOUTPUT = .F.
 goParent = .NULL.

 PROCEDURE ACTIVATE
  ?this.Caption+' activated'
 ENDPROC

 PROCEDURE DEACTIVATE
  ?this.Caption+' deactivated'
  THIS.goParent.GET_RESULT('Value sent')
 ENDPROC

 PROCEDURE INIT
  LPARAMETERS;
   toParent

  THIS.goParent = toParent
 ENDPROC
ENDDEFINE

DEFINE CLASS myform AS FORM


 DOCREATE = .T.
 CAPTION = "Form"
 NAME = "myform"
 LEFT = 100
 oform = .NULL.
 ALLOWOUTPUT = .F.


 ADD OBJECT command1 AS COMMANDBUTTON WITH ;
  TOP = 18, ;
  LEFT = 29, ;
  HEIGHT = 34, ;
  WIDTH = 87, ;
  CAPTION = "Start Form", ;
  NAME = "Command1"


 ADD OBJECT label1 AS LABEL WITH ;
  CAPTION = "Start form", ;
  HEIGHT = 27, ;
  LEFT = 40, ;
  TOP = 104, ;
  WIDTH = 90, ;
  NAME = "Label1"


 PROCEDURE GET_RESULT
  LPARAMETERS;
   tcResult

  THIS.label1.CAPTION = tcResult
   THISFORM.oform = .NULL.

 ENDPROC


 PROCEDURE command1.CLICK
  IF ISNULL(THISFORM.oform) THEN
   THISFORM.oform = CREATEOBJECT("myform2",THISFORM)
   THISFORM.oform.VISIBLE = .T.
   THISFORM.label1.CAPTION = "wait for result"

  ENDIF &&ISNULL(THISFORM.oform)
 ENDPROC

 PROCEDURE ACTIVATE
  ?this.Caption+' activated'
 ENDPROC

 PROCEDURE DEACTIVATE
  ?this.Caption+' deactivated'
 ENDPROC

 PROCEDURE QUERYUNLOAD
  THIS.oform = .NULL.
 ENDPROC

ENDDEFINE
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform