Home > Archive > FoxPro Help and Support > January 2006 > works in click event but not form load...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author works in click event but not form load...
cj

2006-01-23, 1:24 pm

I'm using a 3rd party control package by Catalyst called socket tools.
Specifically their time tool. Right now I have a problem any time I try
to set any property in that tool from the form load event. Here's what
I mean. I created a new project with one form. I put the time control
on the form and in the form load event, I typed
thisform.olecontrol1.autoresolve = .F. and saved and built the project.
When I run the program from within VFP 9 I get unknown member of
olecontrol1. That makes no sense to me as intelisense showed the valid
entries as I typed the line and it showed olecontrol1 and autoresolve
after it.

Next I find out that if I cut this code from form load and put a button
on the form and paste the code into the button's click event I don't an
error.

Any ideas?

One thing I have tried was thisform.olecontrol1.object.autoresolve =
..F. but it didn't work either. People have told me sometimes in FP
you need to use object but nobody knows why.
Cindy Winegarden

2006-01-23, 8:25 pm

Hi CJ,

Forms instantiate in this order: Load, Init, Show, Activate, GotFocus. All
of the form controls instantiate in the Init event of the form itself. Since
your code is in the Load event, your control doesn't exist yet. Try issuing
your property setting in the Init event.

--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn
.com www.cindywinegarden.com


"cj" <cj@nospam.nospam> wrote in message
news:ehiLPCFIGHA.3144@TK2MSFTNGP11.phx.gbl...
> ....I have a problem any time I try to set any property in that tool from
> the form load event. .... I get unknown member of olecontrol1.



Josh Assing

2006-01-23, 8:25 pm


at form.load() -- the objects ON the form don't exist yet.
move the code to form.init()


On Mon, 23 Jan 2006 14:06:31 -0500, cj <cj@nospam.nospam> wrote:

>I'm using a 3rd party control package by Catalyst called socket tools.
>Specifically their time tool. Right now I have a problem any time I try
>to set any property in that tool from the form load event. Here's what
>I mean. I created a new project with one form. I put the time control
>on the form and in the form load event, I typed
>thisform.olecontrol1.autoresolve = .F. and saved and built the project.
>When I run the program from within VFP 9 I get unknown member of
>olecontrol1. That makes no sense to me as intelisense showed the valid
>entries as I typed the line and it showed olecontrol1 and autoresolve
>after it.
>
>Next I find out that if I cut this code from form load and put a button
>on the form and paste the code into the button's click event I don't an
>error.
>
>Any ideas?
>
>One thing I have tried was thisform.olecontrol1.object.autoresolve =
>.F. but it didn't work either. People have told me sometimes in FP
>you need to use object but nobody knows why.



--- AntiSpam/harvest ---
Remove X's to send email to me.
cj

2006-01-23, 8:25 pm

That did it. Thanks! You got time for another? I noticed executed the
exe from outside VFP and it ran and set the time as it was supposed to
then exited. It's what I wanted but not what I expected as I didn't
have a quit command in it. Shouldn't it stay running with the blank
form being shown?

Cindy Winegarden wrote:
> Hi CJ,
>
> Forms instantiate in this order: Load, Init, Show, Activate, GotFocus. All
> of the form controls instantiate in the Init event of the form itself. Since
> your code is in the Load event, your control doesn't exist yet. Try issuing
> your property setting in the Init event.
>

cj

2006-01-23, 8:25 pm

That did it. Thanks!


Josh Assing wrote:
> at form.load() -- the objects ON the form don't exist yet.
> move the code to form.init()
>
>
> On Mon, 23 Jan 2006 14:06:31 -0500, cj <cj@nospam.nospam> wrote:
>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.

cj

2006-01-23, 8:25 pm

That did it, thanks!

Cindy Winegarden wrote:
> Hi CJ,
>
> Forms instantiate in this order: Load, Init, Show, Activate, GotFocus. All
> of the form controls instantiate in the Init event of the form itself. Since
> your code is in the Load event, your control doesn't exist yet. Try issuing
> your property setting in the Init event.
>

Josh Assing

2006-01-23, 8:25 pm



do form MyForm
read events

in your form -- you'll need a "clear events" before you issue "thisform.close()"

You should also look at form.queryunload()



On Mon, 23 Jan 2006 14:46:00 -0500, cj <cj@nospam.nospam> wrote:
[color=darkred]
>That did it. Thanks! You got time for another? I noticed executed the
>exe from outside VFP and it ran and set the time as it was supposed to
>then exited. It's what I wanted but not what I expected as I didn't
>have a quit command in it. Shouldn't it stay running with the blank
>form being shown?
>
>Cindy Winegarden wrote:


--- AntiSpam/harvest ---
Remove X's to send email to me.
cj

2006-01-23, 8:25 pm

you don't use quit any more to end the program?

Sorry for all the questions.



Josh Assing wrote:
>
> do form MyForm
> read events
>
> in your form -- you'll need a "clear events" before you issue "thisform.close()"
>
> You should also look at form.queryunload()
>
>
>
> On Mon, 23 Jan 2006 14:46:00 -0500, cj <cj@nospam.nospam> wrote:
>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.

Josh Assing

2006-01-23, 8:25 pm

You never had to.....

I do not like "quit" -- Prefer to end the program by following the code to it's
end vs "quit here"

I do have a quit in my on error() routine for some programs tho.


On Mon, 23 Jan 2006 15:47:51 -0500, cj <cj@nospam.nospam> wrote:
[color=darkred]
>you don't use quit any more to end the program?
>
>Sorry for all the questions.
>
>
>
>Josh Assing wrote:


--- AntiSpam/harvest ---
Remove X's to send email to me.
cj

2006-01-23, 8:25 pm

ok, but what do you put behind the file/exit button? I just posted a
new question asking for a lead on a simple hello world program to
demonstrate this kind of thing. If you know of one please respond to
that. I'm pretty frustrated right now. I appreciate your help.

Josh Assing wrote:
> You never had to.....
>
> I do not like "quit" -- Prefer to end the program by following the code to it's
> end vs "quit here"
>
> I do have a quit in my on error() routine for some programs tho.
>
>
> On Mon, 23 Jan 2006 15:47:51 -0500, cj <cj@nospam.nospam> wrote:
>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.

Josh Assing

2006-01-23, 8:25 pm

http://www.jassing.com/temp/cjworld.zip


This is pretty basic stuff here.

Are you new to Fox? new to VFP? new to coding in general?

On Mon, 23 Jan 2006 16:25:39 -0500, cj <cj@nospam.nospam> wrote:
[color=darkred]
>ok, but what do you put behind the file/exit button? I just posted a
>new question asking for a lead on a simple hello world program to
>demonstrate this kind of thing. If you know of one please respond to
>that. I'm pretty frustrated right now. I appreciate your help.
>
>Josh Assing wrote:


--- AntiSpam/harvest ---
Remove X's to send email to me.
cj

2006-01-24, 9:24 am

Your right, it is and it should be the first thing in any book. A good
old fashioned "Hello World" program, but the first thing in books these
days is usually an intro to classes. And I don't need the first thing
to me making a Hello World class either. These groups are ok with a lot
of knowledgeable people but they also all seem to think I'm just as
knowledgeable and invariably the first thing they tell me is to
instigate a overloaded class of something.

I'm new to visual foxpro. I've got almost 10 years in DOS based dBase
and Clipper. I've also worked with Visual basic from version 2 I
believe to version 4 which I used up until 2003. Had a spell with a bit
of several things from HTML and C++ to RPG then this year I've been
working with VB .net mostly. Now I've been asked to use VFP.


Josh Assing wrote:
> http://www.jassing.com/temp/cjworld.zip
>
>
> This is pretty basic stuff here.
>
> Are you new to Fox? new to VFP? new to coding in general?
>
> On Mon, 23 Jan 2006 16:25:39 -0500, cj <cj@nospam.nospam> wrote:
>
>
>
> --- AntiSpam/harvest ---
> Remove X's to send email to me.

Josh Assing

2006-01-24, 9:24 am

Well; welcome -- hope the cjworld helps.
It's good to point out your level when asking a question so folks know how to
tailor the answer to you.

Here's a simple of a "hello world" class example, then "do cjclass"

cjclass.prg:

loHi = CREATEOBJECT("cjworld")
?loHi.ctext && Errors, becuase it's protected
?loHi.saywhat()


DEFINE CLASS cjworld AS CUSTOM
PROTECTED ctext && Non accessable property

PROCEDURE INIT
THIS.ctext = "Hello World"
ENDPROC

PROCEDURE saywhat
RETURN THIS.ctext
ENDPROC
ENDDEFINE



On Tue, 24 Jan 2006 08:54:10 -0500, cj <cj@nospam.nospam> wrote:
[color=darkred]
>Your right, it is and it should be the first thing in any book. A good
>old fashioned "Hello World" program, but the first thing in books these
>days is usually an intro to classes. And I don't need the first thing
>to me making a Hello World class either. These groups are ok with a lot
>of knowledgeable people but they also all seem to think I'm just as
>knowledgeable and invariably the first thing they tell me is to
>instigate a overloaded class of something.
>
>I'm new to visual foxpro. I've got almost 10 years in DOS based dBase
>and Clipper. I've also worked with Visual basic from version 2 I
>believe to version 4 which I used up until 2003. Had a spell with a bit
>of several things from HTML and C++ to RPG then this year I've been
>working with VB .net mostly. Now I've been asked to use VFP.
>
>
>Josh Assing wrote:


--- AntiSpam/harvest ---
Remove X's to send email to me.
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com