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

Free standing Report as VFP.exe in a single window

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
623
GB
I have a Clipper application which needs to view a report created from several .dbf files using the VFP REPORT FORM command.

So my Clipper application fires up the VFP .exe and this works fine. My user sees the report with its various fonts; he scrolls through it and then presses ESC which closes the VFP application.

However I notice that I get the VFP application window and within that the report preview window, complete with buttons and scroll bar -(which I am happy to have).

Is it possible to have the report preview completely fill (and so obliterate) the VFP application window? That presentation would look best for my user.

I also notice that on my own machine the report window is maximized with the VFP window, whereas on my clients site it is smaller. What controls that?

The commands that I use in my VFP program are just

SELECT DETAIL
SET RELATION TO ANM_Docno INTO Head
REPORT FORM &lName PREVIEW

Thank you.
 
Hi Andrew,

[qupte]I have a Clipper application ... [/quote]

You have my sympathy <g>.

But seriously ... The solution is to your problem is to use the WINDOW clause in the REPORT FORM command. Essentially, you create a normal form with whatever characteristics you like. You then reference the form name in the WINDOW cluause"

REPORT FORM &lName PREVIEW WINDOW MyForm

To make the preview form "obliterate" the main VFP window, make it a top-level form (set its ShowWindow to 2). In the form's load, set _SCREEN.Visibible to .F., to hide the main VFP window. During your testing, you also need to set _SCREEN.Visible back to .T. in the form's Unload, otherwise you won't get back to the development environment.

I think that will do what you want. Give it a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike. I now have

SELECT DETAIL
SET RELATION TO ANM_Docno INTO Head
CREATE FORM frmAndrew NOWAIT
frmAndrew.ShowWindow = 2
_Screen.VISIBLE = .F.
REPORT FORM &lName PREVIEW WINDOW frmAndrew
_SCREEN.Visible = .T.

However I find that although the form is displayed, my ".ShowWindow" instruction fails with the message "Object frmAndrew not found". How can I refer to the properties of a form I have created?
 
Mike

As an alternative, I have tried
frmAndrew = CREATEOBJECT(“FORM”)
frmAndrew.ShowWindow = 2
REPORT FORM &lName PREVIEW WINDOWfrmAndrew

However I get :
1. The ShowWindow property is Read only
2. WINDOW frmAndrew has not been defined

Am I being too simplistic? Is it perhaps not possible to create a form within a VFP program - does it instead have to be defined in the VFP development environment and then linked into the program in some way.
 
Andrew,

Your second attempt is better than the first. You can't use CREATE FORM for this. All that does is to open a form in the form designer, which is not what you want. CREATEOBJECT() is closer.

However, as you have found, you can't set ShowWindow programatically, for the simple reason that, once the form has been instantiated, it is too late for VFP to make it top-level.

You need to create a form in the form designer, set its ShowWinder -- and also set its Name property (to frmAndrew in this example). Then, DO the form, like this:

DO FORM frmAndrew NAME frmAndrew

(I'm not sure, but you might need to add NOSHOW to the above; try it without doing that first to see if it works.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Andrew,

Just a quick follow up ....

Here's another way of doing it. This is some code I just found in one of my own apps that you can use as a model:

Code:
loPreview = CREATEOBJECT("frmPreview")
loPreview.Show
REPORT FORM Movies PREVIEW IN WINDOW loPreview 

DEFINE CLASS frmPreview AS Form
 ShowWindow = 2
 Name = "loPreview"
  * set other properties here, such as height or
  * WindowState
ENDDEFINE

Give it a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Andrew,

One more thing ...

The code I just posted still shows the outer VFP window. You can hide that by changing the REPORT FORM command to this:

Code:
REPORT FORM Movies PREVIEW WINDOW loPreview IN SCREEN

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike

I have tried the last suggestion about defining class frmPreview.

The program compiles and the form displays, but it doesn't have anything in it. Are you sure that the name of the object (of class frmPreview) is the same as the name of a window? I also now have to put an INKEY(0) instruction into my program - or run in DEBUG mode, otherwise the (blank) form is gone.

regards. Andrew

loPreview = CREATEOBJECT("frmPreview")
loPreview.Show
SET STEP ON
_Screen.VISIBLE = .F.
REPORT FORM &lName PREVIEW WINDOW loPreview
_SCREEN.Visible = .T.
RETURN .T.

ENDDEFINE

DEFINE CLASS frmPreview AS FORM
ShowWindow = 2
NAME = "loPreview"
* Set other properties here, such as WindowState
ENDDEFINE
 
Andrew,

Sorry about the confusion. I should have told you to exclude the _SCREEN.Visible settings in this case. It was in a previous scenario that I suggested you include them.

As for the problem of the form disappearing as soon as you open it, you might need to put READ EVENTS after the DO FORM. In that case, you would also need CLEAR EVENTS in the form's Destroy.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I'm still struggling to get a window to display by itself, not in a "Microsoft Visual Foxpro" window, which the user is probably not interested in. I have :

loPreview = CREATEOBJECT("frmPreview")
REPORT FORM &lName PREVIEW WINDOW loPreview
. . .

DEFINE CLASS frmPreview AS FORM
ShowWindow = 2
Windowstate = 0
Height = 600
Width = 700
NAME = "loPreview"
ENDDEFINE

The height and width properties work fine. But my lopreview window doggedly refuses to move out of the MVP screen, even though I thought the ShowWindow property was meant to allow it to float freely. And of course if I set _screen.visible = .F., I am back to seeing nothing.

 
Andrew,

Hmm. I seem to remember it worked for me when I was experimenting the other day, but unfortunately I didn't bother to keep the code -- other than what I posted here.

How about a different approach? Instead of doing it as top-level form (ShowWindow = 2), how about making it a normal form, and maximising it within the main VFP window. Then set its MDIForm to .T., which in effect hides its title bar. That way, the form will be fully visible but the main VFP window will be "hidden" behind it.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike, but no success. The MDIform property does not seem to be effective when I run the REPORT FORM command. If anyone has a worked example I would be grateful, otherwise it is not a major problem.
 
I think the problem is now resolved. The code I now include is

loPreview = CREATEOBJECT("frmPreview")
loPreview.Show
REPORT FORM &lName PREVIEW IN WINDOW loPreview

The trick seems to be that you have to create the form, show the form, then generate the report IN WINDOW[\b]. If I just include a WINDOW[\b] clause, then it creates a new window which does not seem to inherit all the attributes of the class as defined.

Thanks very much for your patience, Mike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top