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

why is my form disappearing? 2

Status
Not open for further replies.

ajpa

Programmer
Jan 31, 2002
52
GB
I've designated a top level form, and in it I need to open a form to give a message. When I close the message form I want the top-level form top stay on the screen. It all works fine on the machine I'm developing on, but as soon as upload it onto the remote server and operate it as if I were a client, the whole thing closes down when I close the 'message' window.

I've got the 'message' window set to modal and its ShowWindow property set to type 1 and Always on top false. The 'master' window is set to modal, ShowWindow type 2 and Always on top true.

Tony Ayres
 
Hi Tony

Top level forms cannot be modal forms. Even if you set them as modal, they are non modal only.

However, the problem you are facing could be because of lack of EVENT PROCESSING.

That is to say, in your main.prg..
DO FORM myMainForm
READ EVENTS

add the READ EVENTS.

Then in the Main forms, queryunload event add the code..
CLEAR EVENTS.

I also suggest you add a line before the DO FORM myMainForm..
ON SHUTDOWN DO myShutDown.

Add a procedure at the end of your main.prg

PROCEDURE myShutDown
CLEAR EVENTS
QUIT

Hope that fixes your problem. If you make a search on this forum you will get pleanty of threads on identical problems. Probably, one of these should help you. Instead of waiting for answers, you can find that fast.

:)




____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Modal has no effect on a top-level form. You need a READ EVENTS to keep you "in" your application.
 
(I typed this yesterday, but it seems to have got lost, so I'll try again).

Thanks for this: I think it was you who helped me when I was first setting up this kind of project. I've already implemented your suggestions, which is why the system is basically working (I even included a comment that the top level form couldn't be modal, but seem to have overlooked the advice while trying possible solutions!)

The irritating thing is that it all works perfectly on the office machine. Can it be anything to do with the fact that I've got the whole of FoxPro (version 6) on the office machine, but that on the remote server I'v only got the two .dll files needed to run .exe files?

Tony
 
Hi Tony,

The issue is the EVENT processing.

In a development unit, if you start from the desktop as you do in another user computer, the glitch will show. However, if you start it from the VFP command window, the event processing is already on and so you will not face any problem.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
You're quite right that my app doesn't work properly on its home computer if FoxPro isn't running. So is there anything I can do? I'm not allowed to issue READ EVENTS more than once. It doesn't seem to make any difference whether the button used to close the child screen is Terminate Read or not. I thought the whole point of .exe files was that they were standalone and that clients didn't have to buy a license for FoxPro.

I've done a search on events processing, but, interesting though the threads it finds are, they don't seem to address my problem.

(I've always assumed that you were based in the U.S.A. but from the time of day you seem to have made this reply, I must be wrong.)

Tony
 
Hi

I thoght you had solved your problem.

The way to solve it is..

1. Add a line before the DO FORM myMainForm..
ON SHUTDOWN DO myShutDown.

2. You should have only one Read Event.
The place to put is in your Main.PRG from where you start the application.

3. Add a procedure at the end of your main.prg

Example... My Main.Prg
**********************
ON SHUTDOWN DO myShutDown
ON ERROR DO errhand WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO(1)
DO FORM myMainForm
READ EVENTS
CLEAR EVENTS
QUIT
*********************************************************
PROCEDURE myShutDown
CLEAR EVENTS
QUIT
*********************************************************
** My error handler
PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
LOCAL myMessage
myMessage='Error number: ' + LTRIM(STR(merror))+ CHR(13) ;
+ 'Error message: ' + mess + CHR(13) ;
+ 'Line of code with error: ' + mess1 + CHR(13);
+ 'Line number of error: ' + LTRIM(STR(mlineno)) + CHR(13) ;
+ 'Program with error: ' + mprog
=MESSAGEBOX(myMessage,"ERROR !!!",16)
RETURN
*********************************************************
** EOF
*********************************************************

4. In the Main form, queryunload event add the code. This is the final form from where you quit the application as well.

CLEAR EVENTS
QUIT

This is to make sure that you complete the EVENT processing, if the user quits by using your custom exit button or by pressing X at the top of title bar or in any way of shutdown.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Hi ramani,

Thanks for all this detail. I'm afraid that the problem turned out to be that I'd put a CLEAR EVENTS into the Deactivate method of the form at a time when I was trying *anything*, and I failed to remove it. So, of course, when I activated the message window ........

I'm sorry to have wasted your time, but am glad of a full printout of what I need: I hadn't bothered with the error handling before, but clearly should.

Tony
 
HI

Going thru my code above which I wrote with some mix of my code from some Prgs(cut copy paste), and in the process missed some thing. So reposting it so that any future users dont make a mistake..

1. Example... My Main.Prg
**********************
ON SHUTDOWN DO myShutDown
ON ERROR DO errhand WITH ;
ERROR( ), MESSAGE( ), MESSAGE(1), PROGRAM( ), LINENO(1)
DO FORM myMainForm
READ EVENTS
CLEAR EVENTS
ON ShutDown
QUIT
*********************************************************
PROCEDURE myShutDown
CLEAR EVENTS
ON ShutDown
QUIT
*********************************************************
** My error handler
PROCEDURE errhand
PARAMETER merror, mess, mess1, mprog, mlineno
LOCAL myMessage
myMessage='Error number: ' + LTRIM(STR(merror))+ CHR(13) ;
+ 'Error message: ' + mess + CHR(13) ;
+ 'Line of code with error: ' + mess1 + CHR(13);
+ 'Line number of error: ' + LTRIM(STR(mlineno)) + CHR(13) ;
+ 'Program with error: ' + mprog
=MESSAGEBOX(myMessage,"ERROR !!!",16)
RETURN
*********************************************************
** EOF
*********************************************************

2. In the Final quit place, call the myShutDown by code..
DO myShutDown

This is to ensure that ON SHUTDOWN, CLEAR EVENTS are all processed correctly.
********************************************************
The error in my earlier posting is... no ON ShutDown command to clear the earlier code. If you simply type on the command window..
ON ShutDown CLEAR EVENTS
And now press the X at the titlebar. VFP wont close down.
Now type on the command window.. ON ShutDown
and thentry. It will close.

:)

____________________________________________
ramani - (Subramanian.G) :)
When you ask VFP questions, please add VFP version.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top