Link to home
Start Free TrialLog in
Avatar of Pegasus100397
Pegasus100397

asked on

Application Exit on report preview! Help!

Here's a good one. I have a simple Delphi 3.0 application with one form with buttons that calls another with a QuickReport object on it. On my development system (NT 4.0) the application runs fine but when I attempt to run this application on my client computers the application simply exits when the report is called to be previewed. All I can think of is that a DLL or something might be missing from the client computer that is QuickReport-related. This is my first deployed application from version 3.0, previous applications running Delphi 2.0 apps work fine. Any help would be appreciated!

Pegasus
Avatar of Epsylon
Epsylon

If you are using a database you have to configure that on the client systems.
Check that any DB components are installed correctly on the clients machine also if the app is built with runtime packages then make sure the client's machine has them.

hope that helps some.
Avatar of Pegasus100397

ASKER

AndyJohn & Epsylon,

I checked the database components and they are all in place and working correctly. I can open, read, write and close tables with no problem.

Just to check, I created a whole new application, just one form with a button on it that calls another form, with a Quickreport on it with one band that has one QRLabel with the word "Test" in it (how simple can it be?). This "new" application does not use any database components at all.

Guess what! Same thing! The application simply exits when the .Preview line is hit on the client machine but not in my development environment. Here is the code behind the button to produce the preview, maybe something is screwy in my calling convention:

Application.CreateForm(TfrmRPT_Snapshot, frmRPT_Snapshot);
frmRPT_Snapshot.qrSnapShot.Preview;
//frmRPT_Snapshot.ShowModal;

(the "//frmRPT_Snapshot.ShowModal;" was commented out as Delphi 2.0 seems to need it but Delphi 3.0 does not.

BTW: I have the latest BDE installed on the users computers

Adjusted points to 355
Avatar of RBertora
Have you checked that your build with runtime packages checkbox is turned off. in other words the check box is empty... you can find this check box under

Project,options,Packages,Runtime packages..
That might make the differece.
Pegasus, I just did what you did: Create a new app with a label on the QuickReport and a button to do a preview. No need to install additional files. 100% proof!

I think you should put your preview code in the OnFormActivate event of you second form:



procedure frmRPT_Snapshot.FormActivate(Sender: TObject);
begin
  qrSnapShot.Preview;
end;


Eps.
Pegasus,

QuickReport doesn't use any DLLs. IT might be that your application is compile without the runtime packages, ut I doubt it. If that was the case, the program wouldn't run at all.

As of the code you sent:

>>Application.CreateForm(TfrmRPT_Snapshot, frmRPT_Snapshot);


Do not create runtime forms like that. Do this instead:

frmRPT_Snapshot := TfrmRPT_Snapshot.create(application);

It's far better programming practive if you do not call CreateForm. Let Delphi do that. You should create forms the way suggested.

There might also be other code in frmRPT_Snapshot that's causing the abortion, but in order for us to analyse that, we need to see more of the application.

Anyway, try the change in the form-creation method and get back to us.


yours,

Alex
Please send the source to epsylon3@hotmail.com and I will check it....
RBertora,

  The option for Build With Runtimes Packages is turned OFF (unchecked). Thanks for the comment though!

Trying the other suggested options now, thanks all!
If the proposed solutions don't work, please feel free to send me the source code (zipped, please), to simonet@bhnet.com.br

YOurs,

Alex
or to epsylon3@hotmail.com as I did propose earlier  :o)
========================================================
Epsylon, what do you see on your rear mirror? See my headlights closing in again?! Hehehe!

Alex
Yeah please dim your lights a little will ya   :o)
This is what I did:

- I created a new project (Delphi 3.02)
- Added a second form (unit2)
- In unit1 I added 'unit2' to the uses clause
- on form2 I put a quickreport component (and labels etc.)
- for form1 create an event for OnActivate (event tab in object inspector) with the following line:

  Form2.QuickRep1.Preview;
- Saved and run the project

That's all!

Regards,

Epsylon.
Ok all,

First off for Epsylon. I tried moving the qrSnapShot.Preview to the OnActivate event of the form containing the QuickReport object. Cool idea but the application still exited. Thanks though (I'll keep this one for my next project ;^)

Simonet. Thanks for the tips on creating runtime forms. I've been using the "old" Delphi 1.0 method forever and really do need to get with the "program" <grin>. Anyways, I changed the creation code around but to no avail. When the form with the quickreport was called the application simply exited. No error messages or anything, just Bye Bye!

*****************************************************
Now, just to make things interesting...
New Project
New Form
Button on new form that creates second form with Quickreport & a label on it.
Form2 does a preview on the quickreport object

It works! But only on my development machine (with Delphi 3.0 on it).

Got me so far? Should be easy stuff

When I go to a client computer the form that has the button on it will happly display BUT as soon as I press the button to create and display the QuickReport the app simply exits.

Ok, I can handle this. Howza bout just Creating the form with the QuickReport on it and don't even bother doing a preview? Tried it! and guess what? The app exits JUST CREATING THE FORM with the quickreport object on it.

Ok I sez, how about removing the quickreport object, recompile and try running it on a clients computer again? Great! Works like a charm! But if I re-add the quickreport object to the form and try it again the app exits.

From my experimenting all I can think of is that the client computer is missing something that QuickReport needs but that the application CAN find on my development computer.

To boil it down, when the client computer attempts to create the quickreport object (or form with quickreport on it) it apparently can't find something it needs (QR library?) and simply exits with no message.

Maybe I should rebuild the Delphi 3.0 library and do a recompile but how do you do it in v 3.0? I know how to in 2.0 but not in 3.0

I'm outta ideas so I upped the points a bit! Thanks again all... HELP! hehehehe

Pegasus
If you add a new form you don't have to write code to create the second form. It will created already but is is invisible  -> visible := true will make it appear.
Epsylon,

   Yeah, I forgot to mention that if the second form is auto-created then the application starts then immediately exits. If I take the Quickreport form out of the AutoCreate box and place it in the Available list and THEN create it (at runtime) then the application will start normally, but exit when the QR form is created. All I can think of is that maybe my library is corrupt or SOMETHING is not being included in the compiled .EXE that is needed for quickreport. Thanks for the comment!

Points increased to 500, my boss is getting antsy that this gee-whiz app works on my development machine but not his hehehehe

Pegasus
Can you try it on a 3rd computer?
Epsylon,

Good idea, trying it on a third computer.

I tried it on computer #3 and #4 and instead of simply exiting when the Quickreport form was created, it came back with an error message:

ACCESS VIOLATION AT ADDRESS 00473459 IN MODULE "TEST.EXE". READ OF ADDRESS 0064005C

Hope this makes sense to someone, sounds pretty cryptic to me! Thanks

Points upped to 550 ;)

Pegasus
Epsylon,

Good idea, trying it on a third computer.

I tried it on computer #3 and #4 and instead of simply exiting when the Quickreport form was created, it came back with an error message:

ACCESS VIOLATION AT ADDRESS 00473459 IN MODULE "TEST.EXE". READ OF ADDRESS 0064005C

Hope this makes sense to someone, sounds pretty cryptic to me! Thanks

Points upped to 550 ;)

Pegasus
Could it be that the Delphi installation is corrupt? I.E. mixed up two versions. Do you have a clean install of Delphi 3? There must be something terribly wrong. Access violations should not popup like this...

By the way:
- What platforms are you using?
- What's the quickreport version?

I am afraid that I have no explanation.... this is weird    :o(

Eps.
Epsylon,

All the computers in question are running Windows NT version 4.0 with Service Pack 2 installed. Near as I can figure the QuickReport version is the one that came with Delphi 3.0 Professional out of the box (version 3.0?)

I appreciate your time helping!

Points upped to 600, getting desperate! 80()
All I can think of right now is install an upgrade for QuickReport. It's free but it's for registered users only.

http://www.qusoft.com/scripts/download.dll
Wait a minute, do the client systems have a default printer installed? This is a must! Found that in the FAQ:

http://www.qusoft.com/faq.htm

Eps.
Eps, I checked all of the computers and the DO have a default printer (including my dev system) although all of them are network printers.

The version of Delphi 3.0 have says

Delphi 3.0 (Build 5.83)

I'll check the qusoft site and see if an update for QuickReport is available.

Thanks again for any assistance you can offer ;)
Pegasus: See if you can get an NT machine that gives the problems upgraded to SP3 or SP4. Delphi 3 requires SP3 anyway, and SP2 is a buggy piece of <bleep>.

Cheers,

Raymond.
RWilson,

   I agree! I checked all of the NT machines and Service Pack 4 is currently installed on all of them. This bug is driving me batty! About to download version 2.0K of quickreport and see if that solves my problem. Thanks!

Pegasus
Pegasus, I have three machine here at home on which I can test your project. I think it's much easier if we do it that way. Please send me the project to simonet@bhnet.com.br

No database tables are required.

Yours,

Alex
Pegasus,

Another possibility just came to mind: Do you have any components on the form that you're trying to create that accesses databases? I mean: are tehre any TTable, TQuery or similar components in that runtime-created form?

The problem might be BDE related. Make just that BDE is correctly installed on the other machines and that all needed aliases are available on the other machines as well.

I actually am pretty convinced that BDE is the problem and the solution here. Please check the BDE configuration on the other machines. If you need help installing BDE, but you don't have a standalone BDE installer, check this link:

http://www.bhnet.com.br/~simonet/tipstricks/bdeinstcab.htm

It will show you how to install BDE on any machine without needing to install Delphi.

Note: QR doesn't require any DLL or any other files if you build your project without runtime packages. That's what makes it a true VCL reporting tool.

Let me know how it went.

Yours,

Alex




Alex  I dont think the BDE is the issue here since his test program had no links to the database as I understood it.

Pegasus-- I had this same problem awhile back in my app. Tried to create a form with auto create-ap shows up for a sec then dissappears. Then I took it out of auto create and when it was created app exited.  I went everywhere searching for answers and actually learned as you did :) that creating forms should be done a bit differently but like you it didnt help my problem!  

I know this isnt the answer you want but you know what truly fixed it?  Reinstalling delphi...

Just a thought...

Gabe
Well, maybe we all have been looking at the wrong cause. Remember than when a form is created, all components owned by that form are also created. If a component fails to be created, causing a nasty exception, it can cause the whole form creation to fail and even cause the app to exit.

Pegasus, are there any OnCreate events assigned to the form created (frmRPT_Snapshot) or to any component owned by that form?

I still suspect BDE can be a cause, but I don't "discharge" any other possible causes.
 
Alex
Sorry Alex....I wasn't discharging your answer. PEgasus just outlined in an earlier comment how he started a fresh test app with what appears to be no database connectivity at all and no components other than the qreport and a qrlabel.  I may very well have misunderstood him though.

Are you there Pegasus?
The answer to this is to get the Update.zip for quick reports.  This problem appears on NT.  The patch will fix it and lots of the numerous leaks in the QR components.
AndyJohn, why do you propose that?
It has already been proposed!

Pegasus, I think you should reject that answer right away...

Regards,

Epsylon.
I suggest the patch because I have had the same problem and it was fixed by the patch.
I already suggested the patches!
Reject the answer.

Alex
GabeinOZ, correct. On my "test" application it's just two forms, one creating the other with the QuickReport stuff on it. Currently installing the QuickReports 2.0(K) patch to see if that fixes it.

AndyJohn, where can I get the UPDATE.ZIP for QuickReports from? If you have it my email address is tnorris@hti.net.

Thanks all & will keep you informed!
Simonet,

re; "Pegasus, are there any OnCreate events assigned to the form created (frmRPT_Snapshot) or to any component owned by that form? "

Nope! The OnCreate event for the form with the quickreport object on it is clean (as well as all other events for the form).

A note to the masses; Applied the Delphi 3.0 Service Pack 3 patch and the QuickReport 2.0K update, no help, same problem. My dev system has something that makes the app happy that the client machines do not. Wish the ^$(&^#$ AV message was a little more specific about what the problem was. Oh well...

AndyJohn, where do I get the UPDATE.ZIP file?

Points upped to 650

I found this somewhere about problems with temporary files, maybe you have already seen it:

-------------------------------------------------
In qrprntr.pas, there is a function named TempFileName and it is probably not allocating enough charactors for the path to the Windows temp directory.  This has been addressed for QR 3.0.5.  For QR2, you can replace the function with the following code:
function TempFilename : string;
var
  AName,
  ADir : array[0..255] of char;
begin
  GetTempPath(255, adir);
  GetTempFilename(aDir, PChar('QRP'), 0, aName);
  result := StrPas(aName);
end;
---------------------------------------------------------

I did not find qrprntr.pas on my system but maybe you have and I just didn't want to keep this for myself. It could explain the access violations you had.



Here is even more:

-----------------------------------------------------
When the report crashes at 25 to 50 pages and the OS is NT, then the problem is usually file permissions based.  QR2 renders the report to a temporary file if it can't do it in RAM.  QuickReport calls the Delphi GetTempPath() and GetTempFileName() functions to build the filename.  These functions check directories specified by the TMP, and TEMP variables, and they fail, the current directory.  If the user does not have sufficient access to create a temporary file, then an error will occur.
-----------------------------------------------------------

Eps.

AndyJohn, I've applied all known patches (except UPDATE.ZIP, I cannot find it) so I'll have to reject the answer for right now until I can locate it. Thanks!
AndyJohn, I've applied all known patches (except UPDATE.ZIP, I cannot find it) so I'll have to reject the answer for right now until I can locate it. Thanks!
Epsylon,

Even though I have Delphi Professional 3.0 I cannot find the qrprntr.pas file. Thanks for the info though! Wonder if my stack size in D3.0 is too small? Anyone have a good suggestion what to set it to? Thanks!

Pegasus
The $M directive specifies an application's stack allocation parameters. minstacksize must be an integer number between 1024 and 2147483647 that specifies the minimum size of an application's stack, and maxstacksize must be an integer number between minstacksize and 2147483647 that specifies the maximum size of an application's stack.
If there is not enough memory available to satisfy an application's minimum stack requirement, Windows will report an error upon attempting to start the application.

An application's stack is never allowed to grow larger than the maximum stack size. Any attempt to grow the stack beyond the maximum stack size causes an EStackOverflow exception to be raised.
The $MINSTACKSIZE and $MAXSTACKSIZE directives allow the minimum and maximum stack sizes to be specified separately.
The memory allocation directives are meaningful only in a program. They should not be used in a library or a unit.

Alex
Pegasus, I think you are fooling us and your app already run fine for hours   :o)
Are you sure it is not a security problem?
Try to run it on a Windows 95 or 98 system.
Installed Delphi 3.0 on a completely different computer running Windows 95, re-compiled my test application and it runs on BOTH development machines but still bombs on the client's computer (NT 4.0)

I'm at wits-end with this one.

Points upped to 1500
Simonet, thanks for the Stacksize info. Nope, not getting any EStackOverflow errors. Epsylon, really! The app is NOT working and my boss is getting pretty miffed. This project is two weeks overdue for the clients. Damned thing runs great on the development computer but not on the clients which makes it kinda useless.

About the security problem, there's an idea and the only thing I can think of. How would I determine if the app was having some kinda problem with security?

I *know* that QuickReport creates temporary files and the inability to do so due to security might very well be the case but I'm at a loss on how to determine if this is indeed the problem.

At this point I'm almost ready to spend another month re-writing the &^$*#$ application in Delphi 2.0 which I KNOW will work.

Thanks for all of your help guys, I'll divy up the points as best I can when (and if) I ever solve this.

Pegasus
Epsylon, I'd love to *try* to run it on a Win95 system but all the computers in the company are running Win NT 4.0 Ouch!

Pegasus
Give this one a go on the failing systems, just to see if it can detect a default printer.


  procedure TForm1.Button1Click(Sender: TObject);
  var
    Device, Driver, Port   : array [0..255] of Char;
    Mode                   : Integer;
  begin
    Printer.GetPrinter(Device,Driver,Port,Mode);
    if Device <> '' then
      ShowMessage(Device)
    else
      ShowMessage('You do not have a default printer defined');
  end;


Maybe is it a font problem....
Epsylon, Thanks for the code. I put it behind a second button on the same form and it came back and reported the Default Network printer. Thanks!

Pegasus
SUCCESS!

You guys aren't going to believe this but...

When I ran Epsylon's code the following line reported an error:

Printer.GetPrinter(Device,Driver,Port,Mode);

It said "Printer" was undefined. Just great, so I went to the uses clause and added the "Printers" unit to the USES clause. Whoopdy-do, the test app compiled, I ran it on the client's computer and it reported the network printer. At this point I'm about as thrilled as I would be going to a funeral.

Just for giggles and since I don't have any hair left (I pulled it all out on this project), I went to the REAL application and tossed the PRINTERS unit into the USES clause and guess what? The *^&$(*#$ thing works! No errors! Report comes up just fine!

Now my questions (mad as hell at this point),

1) WHY did Delphi 3.0 NOT INCLUDE THE PRINTERS UNIT AUTOMATICALLY?

2) Why did it run on my dev computer and not the clients? Did it find a printers.exe or .DCU or something?

3) Who can I slap for this?

4) Who gets the points? All of you all helped although it was Epsylon's code sample that (although not a solution) led to a roundabout way of finding the problem. Might I suggest that you all talk and figure out a way for me to divy up the points in proportion to the amount of help? Just a thought

THANKS ALL!!!
I can now tell my doc that I think my ulcer will go away on it's own. I really appreciate the time & effort you all have put into this very troubling "bug".

Pegasus



THAT'S GREAT!!! ABSOLUTELY GREAT!!!


1) nothing is perfect
2) nothing is perfect except your dev computer  :o)
3) Try me if you can find me   :o{
4) Well, I have been seaching for hours on your problem with out giving up. Is that worth something?
Just to be serious:

1) It did not add printers in my app to but I did not have trouble...
2) Different configuration? Different printer?

Epsylon, it WAS your code that uncovered the true source of the problem so go ahead and respond back with your comment above as the ANSWER and I'll award you the points. Thanks!

Pegasus
Epsylon, forgot to ask, when you created the "test" app with your Delphi 3.0 (two forms, one with a button and the other with a QuickReport object on it) did YOUR Delphi put the PRINTERS unit in the uses clause? Just curious ;)
Epsylon,

  Sounds like a Delphi bug. Even though on your and my systems it did not add the PRINTERS to the uses clause it seems your and my compiled "test.exe" somehow found what it was looking for (the printers.dcu?). Seems like since it wasn't in the USES clause and the printers.dcu didn't exist on the client computers that it decided to freak out. Go figure!

Thanks again to all for your hours on this problem!

Pegasus
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Epsylon! Hope this helps in the points rat-race! hehehehe

Regards,
Pegasus
It sure does  :o)

Thanks again!
O yes, forgot to say:

3) Slap your boss and tell me what happened  :o)