Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

how to pass over events in stacked objects?
I have written a class clsFINDFILE (which collects filenames calling
FindFirstFile and so on), and a second class clsBACKUP which contains some
backup jobs doing something like that:

DIM FF as clsFindFile
SET FF = New clsFindFile
FF.FindFiles path, filemask    'collecting files
SET FF=Nothing

That works well. Now I want to show the increasing number of found files in
the parent form which holds the clsBACKUP object. But how can I do that
without knowing explicitly the parent form's controls in the clsFINDFILE
class?

I inserted a RaiseEvent FileFound(number,filename) in the clsFINDFILE class,
but how can I receive the event in clsBACKUP  to fire there a new event back
to the parent form?

clsBACKUP will not be able to receive events from an object FF declared 'as
New', and declaring FF not as new will not allow me to access FF's
properties and methods.

Chaining the events is not a 'must be', if possible I would prefer receiving
an event directly in the parent form fired by FF. But I have no idea how to
do that.



Report this thread to moderator Post Follow-up to this message
Old Post
Bruno Köller
05-27-05 08:55 PM


Re: how to pass over events in stacked objects?
"Bruno Köller" <mydevicenull@onlinehome.de>'s wild thoughts
were released on Fri, 27 May 2005 16:59:43 +0200 bearing the
following fruit:

>I have written a class clsFINDFILE (which collects filenames calling
>FindFirstFile and so on), and a second class clsBACKUP which contains some
>backup jobs doing something like that:
>
>DIM FF as clsFindFile
>SET FF = New clsFindFile
>FF.FindFiles path, filemask    'collecting files
>SET FF=Nothing
>
>That works well. Now I want to show the increasing number of found files in
>the parent form which holds the clsBACKUP object. But how can I do that
>without knowing explicitly the parent form's controls in the clsFINDFILE
>class?
>
>I inserted a RaiseEvent FileFound(number,filename) in the clsFINDFILE class
,
>but how can I receive the event in clsBACKUP  to fire there a new event bac
k
>to the parent form?
>
>clsBACKUP will not be able to receive events from an object FF declared 'as
>New', and declaring FF not as new will not allow me to access FF's
>properties and methods.
>
>Chaining the events is not a 'must be', if possible I would prefer receivin
g
>an event directly in the parent form fired by FF. But I have no idea how to
>do that.
>

If FF is defined withevents in the form then the form can
recieve the event. Otherwise you will have to chain the
events.

btw you shouldn't be declaring anything 'as new' in any
case.







Jan Hyde (VB MVP)

--
Metallurgist: Someone who is allergic to iron.  (Leo Roston)

[Abolish the TV Licence - http://www.tvlicensing.biz/]


Report this thread to moderator Post Follow-up to this message
Old Post
Jan Hyde
05-27-05 08:55 PM


Re: how to pass over events in stacked objects?
You'll need to bubble the event up from your clsFindFile through your
clsBackup which means you'll need to dimension your clsFindFile
variable (FF) at the module level using the WithEvents syntax.  If you
need a collection of your clsFindFile objects, you might want to have
a look at the Collection WithEvents example at
http://www.mvps.org/vbvision/  for a way in which to accomplish that.

HTH,
Bryan
 ________________________________________
____________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford		              "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson -
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas



On Fri, 27 May 2005 16:59:43 +0200, "Bruno Köller"
<mydevicenull@onlinehome.de> wrote:

>I have written a class clsFINDFILE (which collects filenames calling
>FindFirstFile and so on), and a second class clsBACKUP which contains some
>backup jobs doing something like that:
>
>DIM FF as clsFindFile
>SET FF = New clsFindFile
>FF.FindFiles path, filemask    'collecting files
>SET FF=Nothing
>
>That works well. Now I want to show the increasing number of found files in
>the parent form which holds the clsBACKUP object. But how can I do that
>without knowing explicitly the parent form's controls in the clsFINDFILE
>class?
>
>I inserted a RaiseEvent FileFound(number,filename) in the clsFINDFILE class
,
>but how can I receive the event in clsBACKUP  to fire there a new event bac
k
>to the parent form?
>
>clsBACKUP will not be able to receive events from an object FF declared 'as
>New', and declaring FF not as new will not allow me to access FF's
>properties and methods.
>
>Chaining the events is not a 'must be', if possible I would prefer receivin
g
>an event directly in the parent form fired by FF. But I have no idea how to
>do that.
>


Report this thread to moderator Post Follow-up to this message
Old Post
alpine
05-27-05 08:55 PM


Re: how to pass over events in stacked objects?
On Fri, 27 May 2005 16:59:43 +0200, "Bruno Köller"
<mydevicenull@onlinehome.de> wrote:

>I have written a class clsFINDFILE (which collects filenames calling
>FindFirstFile and so on), and a second class clsBACKUP which contains some
>backup jobs doing something like that:
>
>DIM FF as clsFindFile

Dim WithEvents FF as clsFindFile

Actually: Private WithEvents FF as clsFindFile

Also you will need to Refresh the Label showing the progress

Ah, that will be in clsBACKUP

You'll need to raise another event in clsBACKUP to notify the parent
Form

BTW, good to see that you are tackling it in a nicely structured way

>SET FF = New clsFindFile
>FF.FindFiles path, filemask    'collecting files
>SET FF=Nothing
>
>That works well. Now I want to show the increasing number of found files in
>the parent form which holds the clsBACKUP object. But how can I do that
>without knowing explicitly the parent form's controls in the clsFINDFILE
>class?
>
>I inserted a RaiseEvent FileFound(number,filename) in the clsFINDFILE class
,
>but how can I receive the event in clsBACKUP  to fire there a new event bac
k
>to the parent form?
>
>clsBACKUP will not be able to receive events from an object FF declared 'as
>New', and declaring FF not as new will not allow me to access FF's
>properties and methods.
>
>Chaining the events is not a 'must be', if possible I would prefer receivin
g
>an event directly in the parent form fired by FF. But I have no idea how to
>do that.
>
>


Report this thread to moderator Post Follow-up to this message
Old Post
J French
05-28-05 01:55 PM


Re: how to pass over events in stacked objects?
> If FF is defined withevents in the form then the form can
> recieve the event. Otherwise you will have to chain the
> events.

That's why I asked...

> btw you shouldn't be declaring anything 'as new' in any
> case.

hmm, why not?




Report this thread to moderator Post Follow-up to this message
Old Post
Bruno Köller
05-28-05 01:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:26 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.