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

DEFINE WINDOW and Standalone Application 2

Status
Not open for further replies.

cpmasesa

Programmer
Oct 24, 2002
78
0
0
AE
Hi,

I am creating a report that I want to run in a custom window. Below is the relevant code snippet:
...
DEFINE WINDOW wReport FROM 20,3 TO 90,130 IN DESKTOP TITLE 'MITU DMSS Reports' SYSTEM CLOSE FLOAT NOMINIMIZE
REPORT FORM S:\CodeVFP\Reports\Corrections PREVIEW WINDOW wReport NOWAIT
RELEASE WINDOWS wReport
...

When I test the form (from within VFP) it works as I want it to. When I build the application, run the executable, open this form and select the button to print the report nothing happens (something just flickers past very quickly)

What could be the problem? I spent most of today trying to solve this with no success.

The application runs fine and loads all the forms as expected. The issue is only when I attempt to preview a report.
TIA

cpmasesa
 
I am not sure READ EVENTS is the problem, or is it the fact that you have no data in the source of your report, because if you form opens and stays opened, that would indicate either your form is modal (no need for READ EVENTS) or that your form is modeless and you do have a READ EVENTS.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Mike and Mike,

I have the READ EVENTS on the prg that loads the main form of the application. This is the code in the applications main form:

SET PROCEDURE TO S:\CodeVFP\Programs\_ProcFunc
DO SetEnvironment
DO FORM gsPath2Forms + '\MITU' &&The main UI
READ EVENTS
DO ResetEnvironment


I tried putting in a READ EVENTS just before the call to REPORT FORM but this also did not work.

I took out the NOWAIT clause and it did not help.

The dataset HAS data as when I run the form itself from within VFP it brings the report that I expect. Its only when I build the application, load the form and click the button for the report that I do not get any report.

Any ideas as to why I am having this problem?

TIA

cpmasesa
 
Try this. In your compiled executable, just before you issue your report, select the alias that is related to your report, browse the table, then run your report. If all is ok, remove the browse.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Mike,

I tried what you suggested. The BROWSE worked as I could see the data in the cursor. Still the report did not show! Just a quick flicker as the printing toolbar showed and dissappeared. I tried this with and without the NOWAIT clause

What I did was:

DEFINE WINDOW wReport FROM 20,3 TO 90,130 IN DESKTOP TITLE 'MITU DMSS Reports' SYSTEM CLOSE FLOAT NOMINIMIZE
SELECT _Corrections
BROWSE
REPORT FORM S:\CodeVFP\Reports\Corrections PREVIEW WINDOW wReport NOWAIT
RELEASE WINDOWS wReport

cpmasesa
 
Is there anything (like a table) left in the Dataenvironment of the report perhaps? If so remove it.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Or, to be even more safe, instead of SELECT _Corrections, do this:

CLOSE DATA ALL
CLOSE TABLES ALL
USE _Corrections

The aim is to be completely sure that no other table is selected for the report.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I think the problem is that the window you're DEFINEing isn't in your top-level form, but in the VFP main window. Is there some reason you need to put the preview in a DEFINEd window?

Tamar
 
Hi cpmasesa:

you need to add

Code:
activate window nReport

try it

Nasib Kalsi
 
I use this code to generate a report preview.

Local whatCaption
whatCaption = "Race Report Program - Click Close Window Icon to Return"


oRepForm = Createobject("Form")
With oRepForm
.Caption = whatCaption
.WindowState = 2
.Show()
Endwith

Repo Form "reports\" + (upickrep) &forclause To Printer Prompt Preview Window (oRepForm.Name)

oRepForm.Release()
 
Hi guys,

Thank you all for your input to my problem.

Mike G - There is nothing in the data environment

Mike L - I cannot use CLOSE DATA ALL because _Corrections is a cursor. Moreover I am sure that the correct table is selected because I see the data when I include SELECT _Corrections; BROWSE just before the call to REPORT FORM.....

Tamar - The form which has the button that calls the report IS a top level form. I want the report to show in a defined window because I want it to show in full screen and the calling form is not in full screen.

Nasib - I added ACTIVATE WINDOW but it did not give me the results I wanted. I put it before the call to REPORT FORM and then after the call to REPORT FORM but it did not work in either case,

Matousek - Thanks for your code. It works fine except that the preview is confined within the boundaries of the calling form. I could not set the DeskTop and ShowWindows properties to overcome this as these are only available at design time. (How do you set them in code!!)

So I did the following to get the effect that I wanted:
...
THISFORM.WindowState = 2
KEYBOARD "{CTRL+F10}"
REPORT FORM S:\CodeVFP\Reports\Corrections PREVIEW
THISFORM.WindowState = 0
...

This maximises the calling window, shows the report in full screen and finally resizes the calling window back to it original size. It is a compromise that I will have to live with until I can somehow crack the problem of having the preview window appear as a maximised top level form.

I guess someone will post the way to do this once they figure it out.

cpmasesa
 
When I test the form (from within VFP) it works as I want it to. When I build the application, run the executable, open this form and select the button to print the report nothing happens (something just flickers past very quickly)

You mean it still 'just flickes past very quickly' ?
Did you try Mike's suggestion to remove NOWAIT ?

I test this on my PC with vfp 9.0 sp1 compiled and ran executable, and it worked as expected. May be a problem with the report or something. Any one else tried it (Activate Window) ?
 
Nasib,

Yes I did try Mike's suggestion of removing NOWAIT. I also tried the ACTIVATE WINDOW wReport. But all these did not work.

My app is a very simple 3 form application and I could send it to someone who could have a look at it and see if they can fix it.

cpmasesa
 
Hi cpmasesa:

I tried the following code in development mode, then build and executed. It worked same way in both environments.

I suggest, you create a NEW PROJECT and copy paste the code. Also create a new report in the project and map the FNAME and LNAME fields.

I hope this may help you.

Code:
* 
* Program name : test.prg
* Calls : none
* Date	: 2008-02-20
*

close tables all
set safety off 
create table nk_test (FName C(15), LNAME C(15))
insert into nk_test (FNAME, LNAME) values ("Line11", "Coloumn12")
insert into nk_test (FNAME, LNAME) values ("Line21", "Coloumn22")
insert into nk_test (FNAME, LNAME) values ("Line31", "Coloumn32")
insert into nk_test (FNAME, LNAME) values ("Line41", "Coloum42")
go top

* Run report without the window
* ------------------------------
REPORT FORM nk_test noconsole PREVIEW

go top

* Run report with the wReport window. adjust co-ordinates as necessary. 
* -------------------------------------------------------
DEFINE WINDOW wReport FROM 20,3 TO 90,130 IN DESKTOP TITLE 'MITU DMSS Reports' SYSTEM CLOSE FLOAT NOMINIMIZE 
activate window wReport
REPORT FORM nk_test PREVIEW WINDOW wReport

RELEASE WINDOWS wReport
 
Nasib,

Thanks for this. I did what you suggested and it worked fine. Except that the print bar did not show in the second call to report form.

And I also did exactly this in my 3 form application but it does not work!

My app has a form (switchboard?) that is loaded via a prg which is the main form (right click and select set main in the project manager)

The switchboard has buttons which call other forms. These secondary forms have a button that calls the report which does not behave as I would like to.

Could it be that there is some other settings that I have to make when the report is called thru a secondary form in the application?

cpmasesa

 
Hi cpmasesa:

We are one step ahead. What version of Foxpro ?

1. Print Bar Does not Show ?
Try moving Window manually by holding the left mouse button. It may be hidden underneath the Preview Window. Try making your preview window smaller(for testing purposes)

2. Still does not work in 3 form application ...
Also read more about Mike/Mike suggestions re Read events and Modal. I do not know of any hinderance when calling serial call to forms as you are doing. May be other forum members can shed some light. Do you mean it still flashes as you have mentioned in the original post ?
You may have saved the "Report/Printer Environment" in the report. I do not know if that may/may not cause problem. Read "SET REPORTBEHAVIOR 80 | 90" and insert it before you call 'REPORT FORM' statement. For testing purposes, may be reset all the envirinments to defaults, set talk off, set echo off, and so forth, before calling the report.


Nasib Kalsi

 
Hello again Nasib,

I am using VFP 9 SP2

1. I tried moving the window and the print bar was nowhere to be seen!

2. Still does not work in 3 form application despite your suggestions.

If you can, could you try a simplistic three form application and see whether you can get it to work as desired. ('Switchboard' with a button that calls the secondary form and a button on secondary form that calls the report) Remember that the main file of the project is a prg that calls the 'switchboard' form

Kind regards,

cpmasesa
 
Hell, can't remember.

Use a regular form and use code in the dataenvironment to maximize the form and dock the print toobar. Otherwise use crtl-f10 but be sure to turn off resource or it will be max versus normal everey other use.

Regards,

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top