I am just starting with Visual Foxpro. I have been a long time CLIPPER developer and trying to switch to VFP to convert my applications from DOS environment to Windows plateform. I started off with a very simple application with one single form containing 4 variables, 4 labels, 4 text boxes and 2 buttons. I set ShowWindow property of the Form to "2 - AS TOP LEVEL FORM". I put the following code in Init and Activate methods of the form

Init
thisform.addproperty('ReadEventsFlg',.F.
cInfile='KKKKKKKK
cOutfile='LLLLLLLL
dStart=ctod('01/01/2000'
dEnd=date(

Activate
IF !THISFORM.READEVENTSFL
READ EVENT
THISFORM.READEVENTSFLG=.T
ENDI

In CONFIG.FPW, I put only one line SCREEN=OFF. The button named GO displays a messagebox showing values of the variables as entered by the user and CANCEL button has following code in CLICK_EVENT

clear event
thisform.releas

When I run the form in Design environment, everything works fine i.e. the initial values of the variables are displayed as initialized in the Init method. However, when I compile an EXE and run it under runtime, it shows all blank values. I tried moving the initialization code of the variables from Init to Activate method. Then it shows the correct value for the first text box and as I click on other boxes, those values also show up correctly. I want the form to show all four values correctly as the form is first displayed. I have playing with it for 3 days now but with no success

I would really appreciate help from the experts and make my entry into FOXPRO world a little easier

Thanks in advance.....

RE: EXE file behaves different than in Design Evnironment by anonymous

anonymous
Wed Feb 04 09:06:09 CST 2004

Create Main.prg and insert the following line

*- Please create your main menu, generate it and save it as mainmenu.mp
*- DO MainMenu.mp
_SCREEN.Visible = .T
DO FORM YourFormNam
DO WHILE .T
READ EVENT
IF glExi
EXI
ENDI
ENDD



RE: EXE file behaves different than in Design Evnironment by anonymous

anonymous
Wed Feb 04 09:51:06 CST 2004

Thanks Tom for your reply. I am going to try that and see if it worked

Just wondering if I can achieve the same without creating a prg file. Can't I just have an application consisting of only one form

Thanks again

RE: EXE file behaves different than in Design Evnironment by anonymous

anonymous
Wed Feb 04 10:26:08 CST 2004

Tom, I just tried that and it didn't work. It opened the form in VFP window. When I close the form, then I could not close the VFP window. I had to go Alt-Ctl-Del and close the process manually

Any olther ideas ???

RE: EXE file behaves different than in Design Evnironment by anonymous

anonymous
Wed Feb 04 11:01:11 CST 2004

Subhas

Based on what you said you had, have a main calling program with this

DO FORM YourFormNam

That's all. Then, in the Init of your form add Thisform.Refres

Ga

p.s. As you have it now, the first time you run it in test after a clear all the fields are blank. The 2nd time and after they are populated. If you don't want a main calling program, set that form as the main form.

RE: EXE file behaves different than in Design Evnironment by anonymous

anonymous
Wed Feb 04 12:51:06 CST 2004

Gar, I did set the form as Main Form. As I said it works fine in the design environment. While in design, it first displays all the values as set in the Init method e.g. cInfile is displayed KKKKKKKK, cOutfile as LLLLLLL and so on. Now after the form is displayed, if I change the value of cInfile to say DATAFILE and then press GO, the messagebox displayes cInfile as DATAFILE and I return to the form after I press OK in the Messagebox. I can continue this until I press Cancel button and then I return to operating system

I believe that it should be possible without having to add another program to DO yourfomname. I am away from my Development computer at this time. When I get back to it, I will try adding thisform.refresh in the Init method and see if that works

Thanks for your input........

RE: EXE file behaves different than in Design Evnironment by anonymous

anonymous
Wed Feb 04 13:06:06 CST 2004

Subhash, correct... you do not need the prg in this case, only if you were using it to do other logic before doing the form. Putting the thisform.refresh at the end of the Init should work to display the original values
Good luc
Gar

Re: EXE file behaves different than in Design Evnironment by David

David
Wed Feb 04 19:55:42 CST 2004

Subhash,

You should use a main prg. The problem with your code below, the READ EVENTS
inside the method of the form is preventing the Activate() method from
completing its execution.

There always ends up being some environmental things setup and shutdown that
belong outside your form, so use a main.prg:

* setup here

on shutdown ShutdownApp()

do form yourform
read events

* clean up here

return

function ShutdownApp()
on shutdown
clear events
return


In your form close down, use a CLEAR EVENTS command to drop you out of the
read event loop.

Another reason for using a main is if your program has parameters passed to
it. If your form is the project "main" the parameters won't be sent to the
form.Init() because in the absence of a main.prg VFP is doing a DO FORM
behind the scenes to get the form up and running.

Welcome to VFP!

--
df - Microsoft MVP FoxPro http://www.geocities.com/df_foxpro

"Subhash Chopra" <fox.vfp.forms> wrote in message
news:1B2A61C6-0BDA-4B17-8D21-7F3551A7370A@microsoft.com...
> I am just starting with Visual Foxpro. I have been a long time CLIPPER
developer and trying to switch to VFP to convert my applications from DOS
environment to Windows plateform. I started off with a very simple
application with one single form containing 4 variables, 4 labels, 4 text
boxes and 2 buttons. I set ShowWindow property of the Form to "2 - AS TOP
LEVEL FORM". I put the following code in Init and Activate methods of the
form:
>
> Init:
> thisform.addproperty('ReadEventsFlg',.F.)
> cInfile='KKKKKKKK'
> cOutfile='LLLLLLLL'
> dStart=ctod('01/01/2000')
> dEnd=date()
>
> Activate:
> IF !THISFORM.READEVENTSFLG
> READ EVENTS
> THISFORM.READEVENTSFLG=.T.
> ENDIF
>
> In CONFIG.FPW, I put only one line SCREEN=OFF. The button named GO
displays a messagebox showing values of the variables as entered by the user
and CANCEL button has following code in CLICK_EVENT:
>
> clear events
> thisform.release
>
> When I run the form in Design environment, everything works fine i.e. the
initial values of the variables are displayed as initialized in the Init
method. However, when I compile an EXE and run it under runtime, it shows
all blank values. I tried moving the initialization code of the variables
from Init to Activate method. Then it shows the correct value for the first
text box and as I click on other boxes, those values also show up correctly.
I want the form to show all four values correctly as the form is first
displayed. I have playing with it for 3 days now but with no success.
>
> I would really appreciate help from the experts and make my entry into
FOXPRO world a little easier.
>
> Thanks in advance.....