Modal form not working as expected

Trying to develop a form that I can popup just like the messagebox() - that can be used to get info from the user. (ie a programmable messagebox) and as messagebox() it prevents any input outside of that form until it has been closed

Have set up a Formset with window type = 1 Modal - then added 2 forms - FrmTest and Frmpopup (both window type 1)

frmpopup.visible = .f

have a showpopup command box  - thisformset.frmPopup.hide +thisformset.frmpopup.Show(1)

but when activated the controls on the frmtest are still active

What am I doing that is wrong??
Brian WorgerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pcelbaCommented:
Does INPUTBOX() function fit to your needs?

lcAnswer = INPUTBOX("Type Here:", "Input Title", "Nothing at all", 5000, 'Timed Out', 'Canceled')
? lcAnswer
Brian WorgerAuthor Commented:
No - I do need to display data in the popup and then let the user choose what to do
For example user asks for all orders from a particular customer - popup shows them and then within the popup gives the option to either print them locally or email them.
pcelbaCommented:
Look at the following code:
FUNCTION msg
LPARAMETERS lcText

LOCAL lcResult, loDialogFrm, loRetValues
lcResult = ""
loRetValues = CREATEOBJECT("Empty")
ADDPROPERTY(m.loRetValues, 'EnteredText', "")
ADDPROPERTY(m.loRetValues, 'ExitButton', "")

loDialogFrm = CREATEOBJECT('MyModalMessage', m.lcText, m.loRetValues)
loDialogFrm.Show(1)

IF m.loRetValues.ExitButton = "OK"
  lcResult = m.loRetValues.EnteredText
ENDIF

RETURN m.lcResult

DEFINE CLASS MyModalMessage AS Form
  WindowType = 1
  Width = 400
  Height = 100
  AutoCenter = .F.
  RetValueObj = null
  
  PROCEDURE Init
  LPARAMETERS lcText, loRetValues
  
  THISFORM.RetValueObj = m.loRetValues
  
  THISFORM.AddObject('txtMsg', 'Textbox')
  THISFORM.txtMsg.Top = 10
  THISFORM.txtMsg.Left = 10
  THISFORM.txtMsg.Width = THISFORM.Width - 20
  THISFORM.txtMsg.Value = m.lcText
  THISFORM.txtMsg.Visible = .T.
  
  THISFORM.AddObject('btnOK', 'MyOKbutton')
  THISFORM.btnOK.Left = (THISFORM.Width - THISFORM.btnOK.Width)/2
  THISFORM.btnOK.Top  = THISFORM.Height - THISFORM.btnOK.Height - 5
  THISFORM.btnOK.Visible = .T.
  
  ENDPROC
  
ENDDEFINE

DEFINE CLASS MyOKbutton AS CommandButton
  Width = 50
  Height = 20
  Caption = "OK"
  
  PROCEDURE Click
  
  THISFORM.RetValueObj.EnteredText = THISFORM.txtMsg.Value
  THISFORM.RetValueObj.ExitButton = "OK"
  THISFORM.Release
  
  ENDPROC
  
ENDDEFINE

* Calling sample:
? MSG("Some text")

Open in new window

It still works like a MessageBox but you can whatever you need. So Instead of the Textbox object on the form you may display a dropdown combo containing your options. Etc. etc.

Of course, if you need the standard popup menu in the modal window then you have to design the menu and attach it to the modal form.

If the above code looks too complex then you may do all the things in VFP designers. The only thing you don't probably need is the FormSet as almost useless element.
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

pcelbaCommented:
Sample with a combo box:
FUNCTION MyOptions
LPARAMETERS lcText

LOCAL lcResult, loDialogFrm, loRetValues
lcResult = ""
loRetValues = CREATEOBJECT("Empty")
ADDPROPERTY(m.loRetValues, 'EnteredText', "")
ADDPROPERTY(m.loRetValues, 'ExitButton', "")

loDialogFrm = CREATEOBJECT('MyModalDropDown', m.lcText, m.loRetValues)
loDialogFrm.Show(1)

IF m.loRetValues.ExitButton = "OK"
  lcResult = m.loRetValues.EnteredText
ENDIF

RETURN m.lcResult

DEFINE CLASS MyModalDropDown AS Form
  WindowType = 1
  Width = 400
  Height = 100
  AutoCenter = .F.
  RetValueObj = null
  
  PROCEDURE Init
  LPARAMETERS lcText, loRetValues
  
  THISFORM.RetValueObj = m.loRetValues
  
  THISFORM.AddObject('cmb', 'ComboBox')
  THISFORM.cmb.Top = 10
  THISFORM.cmb.Left = 10
  THISFORM.cmb.Width = THISFORM.Width - 20
  THISFORM.cmb.Style = 2
  
  LOCAL lnI
  FOR lnI = 1 TO GETWORDCOUNT(m.lcText, ';')
    THISFORM.cmb.AddItem(GETWORDNUM(m.lcText, m.lnI, ';'))
  NEXT
  
  THISFORM.cmb.ListIndex = 1
  THISFORM.cmb.Visible = .T.
  
  THISFORM.AddObject('btnOK', 'MyOKbutton')
  THISFORM.btnOK.Left = (THISFORM.Width - THISFORM.btnOK.Width)/2
  THISFORM.btnOK.Top  = THISFORM.Height - THISFORM.btnOK.Height - 5
  THISFORM.btnOK.Visible = .T.
  
  ENDPROC
  
ENDDEFINE

DEFINE CLASS MyOKbutton AS CommandButton
  Width = 50
  Height = 20
  Caption = "OK"
  
  PROCEDURE Click
  
  THISFORM.RetValueObj.EnteredText = THISFORM.cmb.Value
  THISFORM.RetValueObj.ExitButton = "OK"
  THISFORM.Release
  
  ENDPROC
  
ENDDEFINE

* Calling sample;
? myoptions("XXX;YYY;some additional text")

Open in new window

Because we are in FoxPro extensions possibilities are rather wide... You may add Cancel button, you may add additional parameters for the initial combo index, add necessary parameters checks and error handling etc.
Brian WorgerAuthor Commented:
This is actually perfect - it does what I want.

Is there any way that I can create and modify this form in the designer?
pcelbaCommented:
No, such way does not exist. You have to modify the PRG file. Some tool to convert PRG to SCX/VCX could exist but the simplest way is to design such a simple form or form class from a scratch.

If you create form then you may write event code directly to methods in this form and then display it by  DO FORM <<name>> WITH <<parameters>>  instead of CREATEOBJECT.
Of course, you may create the form as a class (by CREATE CLASS command) and leave its instantiation almost unchanged.

I've used PRG which is simpler to post here.
Olaf DoschkeSoftware DeveloperCommented:
The simple "secret" is to not use formsets. In a formset modality of all forms only means they are all modal relative to other formsets, not to themselves, that couldn't work out to start with, so it's disregarded.

Pavel forms simply works, as it's a separate form not part of the formset. Forget about formsets overall anyway.

The way modality works is at first Show, or by setting it modal at design time already, not when you switch states with hide&show.

Modality is disregarded in top level forms, too.

Bye, Olaf.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brian WorgerAuthor Commented:
Have resolved my problem by setting the main form "enabled" property to false when my message form is  made visible & then reversing it when the message has been resolved.
But many thanks for this explanation -
Olaf DoschkeSoftware DeveloperCommented:
Pavel earns all credit, as he provided a solution you already said: "This is actually perfect".

I only wanted to add the explanation why your original situation doesn't work out, why Pavel's solution works and reaffirm you to redo such a single form yourself with the visual editors if you want to maintain it with the form or class designers.

Bye, Olaf.
pcelbaCommented:
My February points are over the average already :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FoxPro

From novice to tech pro — start learning today.