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

property showwindow is readonly error 3

Mandy_crw

Programmer
Jul 23, 2020
585
PH
hi everyone... I have these codes... intention is to have showwindow = 2 but it always say property showwindow is read only... Please help... Thanks in advance....

oRepForm = CREATEOBJECT("FORM")

WITH oRepForm
.Caption = "Balances"
.WindowState = 2
.alwaysontop = .f.
.visible = .T.
.SHOWWINDOW = 2
.Show(2)
ENDWITH

REPORT FORM bal&back PREVIEW WINDOW (oRepForm.Name) ;
TO PRINTER PROMPT

oRepForm.Release()
RELEASE RepForm
 
help:

ShowWindow Property
Specifies whether a form or toolbar is a top-level form or a child form. Available at design time; read-only at run time.

It is readonly at runtime, you can only set ShowWindow at design time, that means you can't first create a form with CREATEOBJECT("form") which by default has 0 (in screen) and then want it to be a top level form. It is already created in the screen in line 1 of the code. The moment the form is created it's running, doesn't matter that it's not yet shown. At runtime you can't set this property.

So design a class of a form and create that with CREATEOBJECT() or design an scx form and run that with DO FORM

I see a lot of code like this, not only with forms, but especially with the cursoradapter baseclass, creating a baseclass and then setting properties. Design a class with the desired property values, not only when they are readonly at runtime, it's just completely broken to do that, you want a form with certain settings, think of how you can make this a class that's reusable in multiple places. If you want some properties set dynamically with values you only know at runtime and close before you create your class, that's not a problem, you have multiple ways to let this be dynamic, by using an expression in the property that get's evaluated when a class is created or by adding parameters to init which sets them. Of course that's not possible with such properties as ShowWindow. But you spare a lot of code by doing this and not repeatedly create the native base class and set its properties.

What you want is a report preview form. For a good example of how to do this, you could look into the source code of FoxyPreviewer:
1735477856126.png
They made a general frxpreviewform that is based on an frxbaseform. The major point is: To have control about ShowWindow they derived three subclasses ...astopform ..indesktop and ..inscreen from the class frxpreviewform. They mainly differ from their parent class in the ShowWindow property. So that way you can have one central class design that you manage and change and adapt when necessary and derive three subclasses with all possible ShowWindow settings and can still decide at runtime, which ShowWindow mode you want, by choosing one of the three subclasses.
 
Last edited:
It is readonly at runtime, you can only set ShowWindow at design time, that means you can't first create a form with CREATEOBJECT("form") which by default has 0 (in screen) and then want it to be a top level form. It is already created in the screen in line 1 of the code. The moment the form is created it's running, doesn't matter that it's not yet shown. At runtime you can't set this property.

So design a class of a form and create that with CREATEOBJECT() or design an scx form and run that with DO FORM

I see a lot of code like this, not only with forms, but especially with the cursoradapter baseclass, creating a baseclass and then setting properties. Design a class with the desired property values, not only when they are readonly at runtime, it's just completely broken to do that, you want a form with certain settings, think of how you can make this a class that's reusable in multiple places. If you want some properties set dynamically with values you only know at runtime and close before you create your class, that's not a problem, you have multiple ways to let this be dynamic, by using an expression in the property that get's evaluated when a class is created or by adding parameters to init which sets them. Of course that's not possible with such properties as ShowWindow. But you spare a lot of code by doing this and not repeatedly create the native base class and set its properties.

What you want is a report preview form. For a good example of how to do this, you could look into the source code of FoxyPreviewer:
View attachment 1395
They made a general frxpreviewform that is based on an frxbaseform. The major point is: To have control about ShowWindow they derived three subclasses ...astopform ..indesktop and ..inscreen from the class frxpreviewform. They mainly differ from their parent class in the ShowWindow property. So that way you can have one central class design that you manage and change and adapt when necessary and derive three subclasses with all possible ShowWindow settings and can still decide at runtime, which ShowWindow mode you want, by choosing one of the three subclasses.

I see... thanks Chriss... i have been looking for answers in the internet but i cannot fine one... so i ask here in the forum... I''l try what you have suggested the DO form.. Thanks again...
 
DO FORM is not the important part, but if you want to use that, create a form, an SCX form. What you have is closer to a class definition than an SCX form, but whatever. When you design a form or form class you can set the ShowWindow property in the designing of the form, that's what matters.

Edit: What you actually want may not be a top level form, but just a form in which you set the AlwaysOnTop property to .T.
 
Last edited:
DO FORM is not the important part, but if you want to use that, create a form, an SCX form. What you have is closer to a class definition than an SCX form, but whatever. When you design a form or form class you can set the ShowWindow property in the designing of the form, that's what matters.

Edit: What you actually want may not be a top level form, but just a form in which you set the AlwaysOnTop property to .T.
Ok Chriss… thanks and Godbless…
 
That can be done with form.Desktop=.T., which is another property that's readonly at runtime, so you need your SCX or form class in a VCX that has Desktop=.t. and I would prefer that to a top level form, a top level form is meant to be a parent form for child forms. The top level is making it freely movable on the Desktop, just like Desktop=.T. does, but it means more than that and for what you want a desktop form is enough.

Acccording to the help documentation of the Desktop property, there's one situation you might want to use a top level form instead of a desktop form: A desktop form - even though it is freely movable outside the main top level form - gets hidden when you minimize the main form, because it's still a child of that. Only a second top level form remains independently seen. But I think if a user wants to minimize your application to use another application on the desktop, a report preview should not stay visible, so you should use the Desktop property.
 
Last edited:

Part and Inventory Search

Sponsor

Back
Top