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

Creating form for report preview

Status
Not open for further replies.

sdocker

IS-IT--Management
Aug 12, 2010
218
GB
I use the following to create a form to hold a report...

loForm = CREATEOBJECT('Form')
loForm.NAME = 'ReportPreview'
loForm.CAPTION = 'Preview'

I would like to make the form wider than the Top Level form. Is this possible?

Thanks
Sam
 
The only way to do this is to make the preview form itself a top-level form, like so:

[tt]loForm.ShowWindow = 2[/tt]

You can then set its width to whatever you want.

But that might have implications for your preview. Top-level form are always modeless, which might be an issue in this case. But try it and see.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 


Hi Mike,

Tried it. Got error number 1743. Property SHOWWINDOW IS READ-ONLY.

I'll try creating the form with the form designer and calling it.

I'll get back with the results.

Sam

 
Sam,

That's right. You'll have to create a form class in the Class Designer. Then set the property in the designer. And then create your form based on the class.

Alternatively, just create the form in the Form Designer, and launch it with DO FORM ... NAME ...

Sorry I didn't point that out before.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike,

Worked fine.

But along the way I found a different solution.

I changed the size and position of the Top-Level form and changed it back when I was done.

Thanks,

Sam


 
Coming in late. Readonly properties mainly are readonly at runtime, eg you can't tell windows to start a top level form, after it already is running. That's a thing Windows needs to know in advance, as a form can't switch it's status from child to top level form.

So a simple way in general to set runtime readonly proeprties is obviously to set them at design time. That still can be in code, instead of using a visual class, at the end of your PRG you can put a definition of a top level form as

Code:
DEFINE CLASS TopLevelForm as Form
   ShowWindow = 2
ENDDEFINE

This short class definitions inherits all from a normal base Form class despite of having ShowWindow defined as 2 from the outset, it's not set at runtime, it's predefined in the definition. You can't put that DEFINE CLASS section into a method or event of a form or control, but into a PRG, eg at the end of main.prg. Then instead of CREATEOBJECT("Form") do CREATEOBJECT("TopLevelForm").

I tend to not want to convolute main.prg with such things, but it's an easy way to make some function or class definition available globally in all your app.

Bye, Olaf.
 
Olaf said:
I tend to not want to convolute main.prg with such things, but it's an easy way to make some function or class definition available globally in all your app.

I agree with that. I tend to put all those general-purpose class definitions in a single PRG, and call that near the start of the main program. Another option would be to use NEWOBJECT() instead of CREATEOBJECT(), and to specify the PRG name in the third parameter.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks all.

I always learn something, even from the simplest questions.

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top