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

Setting WindowType property to 1 for Modal - receive error 1

Status
Not open for further replies.

Foxprosoldier

Programmer
Nov 5, 2004
7
CA
I want to set a form to Modal or Modeless depending on the value of a parameter passed. Am trying to set the WindowType property in the init of the form.
On some forms it works fine on others I am receiving a "Property is read only" error. I am using VFP 9.0.

Anyone else run into this problem?
 

Didn't try to change WindowType at run time, but Init event seems to be a little too late for that. Try Load event.
 
Thankyou TamarGranor . I used this code and it worked perfectly. A bit puzzling though as I swear there are forms where I don't have to set the form to Visible=.F.
befor I change the windowtype and works fine with no error
but not on others. Anyway the code below solved it.



THIS.Visible=.F.
THIS.windowtype= 1
THIS.Visible=.T.

 
Foxprosoldier,

A bit puzzling though as I swear there are forms where I don't have to set the form to Visible=.F.

It could be that you are doing it from the Init or Load event. Remember, the form is normally invisible during those events.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
In ALL cases I was changing the windowtype property in the init. In the cases of the forms where I receieved the error "Property is read only" I also tried changing the windowttype property in the first line in the init and the first line in the load. I receved the same error. When I tried to use the show(1) I received an error "Cannot change modality on a visible form". When I used

this.hide
this.windowtype= 1
this.show

It did work except the form seemed to be loaded twice. I had to press the Exit button twice (containing the command thisform.unload()) in order to get out of the form.

Using the code:

THIS.Visible=.F.
THIS.windowtype= 1
THIS.Visible=.T.

no such problem occurred as the form became modal and unloaded properly when the exit button was pressed.




 
You don't have to change WindowType separately with Show method. It has an argument already to determine whether a form is modal or modeless:

[FormSet.]Object.Show([nStyle])

where nStyle could be 1 for Modal or 2 for Modeless.

Besides,
The Show method sets a form or form set's Visible property to true (.T.) and makes the form the active object. If a form's Visible property is already set to true (.T.), the Show method makes it the active object.
...
Forms contained within a form set retain their Visible property setting. If a form's Visible property is set to false (.F.), the Show method for the form set does not show the form.

I got to add that the syntax (and the quote) is from VFP6 Help, but I would guess that the argument didn't go away in later versions.

 
it may be a li'l late, but you might consider the NOSHOW param of DO FORM.. something like:

Code:
LOCAL lnval

STORE 1 to lnval && to open modal
*!* STORE 2 to lnval && to open modaless

DO FORM frmForm NAME "frmForm" NOSHOW

IF TYPE('frmForm') == 'O'
  frmForm.Show(lnval)
ENDIF

just set lnval based on whether you want to open the form modal or not..

HTH
-- frank~
 
My guess is that in the forms with the problem, you have some code that's causing the form to become visible prematurely. Probably something you're doing with a control is triggering the Show or Activate before it would normally run. You could check this with the Event Tracker.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top