Call-backs - AAARGGHHH! HELP please please please! 
Author Message
 Call-backs - AAARGGHHH! HELP please please please!

Hi all,

Can someone help me PLEASE! I AM GOING INSANE trying to work out how to do
this

I am at my wit's end trying to work out how to implement call-backs and the
sample programs supplied with VB and associated documentation are only
confusing the issue.

Here's my situation:

I have an EXE that runs as a controller for a range of DLLs. It creates the
DLL object and passes data down to it and then is supposed to continue on
while keeping an ear out for the DLL to complete or whatever.

The DLL does its business which includes user-interaction, and when its
done, needs to raise the call-back so the EXE knows what its doing. To
simplify (or complicate, depending on your point of view), all of these DLLs
(of which there are 1103 to be precise), implement a Global_Routines class
in a single DLL, thus providing common code in the one place.

Can someone confirm for me how to do this? I think I need to do it like so:

CONTROLLER
Contain a NotifyController class

Has an object of type NotifyController class
Has an object of type GlobalRoutines class

Calls GlobalRoutines.ShowDLL(DLLName, NotifyControllerObject, OtherParms)

NotifyController class has a
Sub DLLStatusChanged(Status as string)
    Msgbox "DLL status changed to " & Status
End Sub

GLOBAL_ROUTINES
public MyNotifyObject as MyNotify

Sub ShowDLL(sDLLName, NotifyControllerObject as MyNotify, OtherParms)
    MyNotifyObject = NotifyControllerObject
    invoke sDLLName processing
End Sub

When sDLLName has finished processing, it invokes the following sub in
GLOBAL_ROUTINES
Sub DLLStatusChangeNow(StatusChange as string)
    MyNotifyObject.DLLStatusChanged(StatusChange)
End Sub

GLOBAL_ROUTINES also needs to have a class calls MyNotify which Implements
NotifyController from the CONTROLLER EXE. Do I have to put stuff in the
interfaces within this MyNotify class, and if so doesn't that override
what's in my CONTROLLER class?

The actual coding is a WHOLE lot more complex than what's here... CONTROLLER
needs to do stuff with what comes back, the DLLs may return status codes
before they're finished processing and the CONTROLLER does stuff in the
background, CONTROLLER needs to invoke other methods within GLOBAL_ROUTINES
upon return BEFORE the the current instance of the DLL being processed is
destroyed, ETC.

HELP ME PLEASE! I AM GOING MAD

Thanks
Andrew Parsons




Sat, 01 Jun 2002 03:00:00 GMT  
 Call-backs - AAARGGHHH! HELP please please please!

Andrew,

Quote:
> Can someone help me PLEASE! I AM GOING INSANE trying to work out how to do
> this

> I am at my wit's end trying to work out how to implement call-backs and
the
> sample programs supplied with VB and associated documentation are only
> confusing the issue.

Forgive me if I'm off here, but nobody has responded so I will take a shot.

It sounds like you are using VB-created activeX dlls???
If so, then you want to use the term "Events" rather than "Callbacks",
otherwise you will see a lot of confused looks.

You really have 1103(!) dlls???   And all of these are referenced from the
main exe project?  I can't imagine a scenario where you would need that many
dlls.  Just for curiosity's sake - *what* are you doing? ;-)

A couple of things it sounds like you might not be clear on are as follows:
1. To raise events back to a container (exe) you Dim the object using the
"WithEvents" keyword.
e.g.,
[in form's General Declarations section]
Private WithEvents oObj as IMyInterface

As soon as you do this you will see the oOBj object appear in the form's
left property drop-down listbox and any events which are specified in the
Interface will appear in the right.  You can directly handle raised events
in the form's code.

[later]
Set oObj = whatever

2.Interfaces generally do not contain code, they are normally just "empty
classes" the code must be implemented in the class which Implements the
interface and/or the container.

Again, if I'm off please forgive me , but maybe this will help you at least
rephrase your question.  Also, if you are *not* using activeX dlls, but
really need to catch callback messages, you might want to take a look at the
Callback Routing tutorial on my website.  The final sample shows how to
Implement an interface to route messages (although not for quite so many
dlls ;-))

Hope this helps,

--
Ray Mercer
MS-MVP Visual Basic
www.shrinkwrapvb.com



Sat, 01 Jun 2002 03:00:00 GMT  
 Call-backs - AAARGGHHH! HELP please please please!
Thanks for the tips Ray,

For your information, this is what we're doing.

We are converting a mainframe application to a client/server multi-tier
system. This new system is Unix, Microfocus COBOL on the back end, with an
Oracle 8 database. There are some C programs that serve as driver programs
interacting between the host and the front end and the front end is the
system we're talking about, written in VB.

The 1103 DLLs I'm referring to are ActiveX VB DLLs and are automatically
generated by a program I wrote. What we do is extract the information from
the mainframe screen definitions and stick it in an Access database. This
includes the X & Y location, field names, attributes and a few others. The
generator grabs all this information and creates VB code - a CLS, FRM, BAS
and VBP file, as well as copying a default FRX file for icons. All of this
information is dynamically generated. I love it when you do something like
this - Write a VB generator in VB.

The main EXE doesn't have any inbuilt references to these DLLs in it. It
defines an object as type Object and then uses
CreateObject(Screenname.screennameclass) to get the thing and populate the
data.

This is much faster than making the screens individually (it takes about 30
minutes to create all 1103 screens including default attributes, positioning
and class functions). Then we have a batch file that builds all 1103 DLLs
from their VBP files and registers them.

This is all going to run on a Hydra server, so the individual clients
shouldn't need the DLLs registered on their own Workstations, since they
will be running the application on Hydra.

I didn't think I wanted to use the WithEvents option, but that's probably a
sign that I misunderstood the documentation that came with VB. Is there a
good book on all this stuff?

Cheers
Andrew

Quote:

> Andrew,

> > Can someone help me PLEASE! I AM GOING INSANE trying to work out how to
do
> > this

> > I am at my wit's end trying to work out how to implement call-backs and
> the
> > sample programs supplied with VB and associated documentation are only
> > confusing the issue.

> Forgive me if I'm off here, but nobody has responded so I will take a
shot.

> It sounds like you are using VB-created activeX dlls???
> If so, then you want to use the term "Events" rather than "Callbacks",
> otherwise you will see a lot of confused looks.

> You really have 1103(!) dlls???   And all of these are referenced from the
> main exe project?  I can't imagine a scenario where you would need that
many
> dlls.  Just for curiosity's sake - *what* are you doing? ;-)

> A couple of things it sounds like you might not be clear on are as
follows:
> 1. To raise events back to a container (exe) you Dim the object using the
> "WithEvents" keyword.
> e.g.,
> [in form's General Declarations section]
> Private WithEvents oObj as IMyInterface

> As soon as you do this you will see the oOBj object appear in the form's
> left property drop-down listbox and any events which are specified in the
> Interface will appear in the right.  You can directly handle raised events
> in the form's code.

> [later]
> Set oObj = whatever

> 2.Interfaces generally do not contain code, they are normally just "empty
> classes" the code must be implemented in the class which Implements the
> interface and/or the container.

> Again, if I'm off please forgive me , but maybe this will help you at
least
> rephrase your question.  Also, if you are *not* using activeX dlls, but
> really need to catch callback messages, you might want to take a look at
the
> Callback Routing tutorial on my website.  The final sample shows how to
> Implement an interface to route messages (although not for quite so many
> dlls ;-))

> Hope this helps,

> --
> Ray Mercer
> MS-MVP Visual Basic
> www.shrinkwrapvb.com



Sat, 01 Jun 2002 03:00:00 GMT  
 Call-backs - AAARGGHHH! HELP please please please!

Quote:

>Hi Andrew,
>This is a little out of my league.  I'm just a lowly Win32 multimedia
>specialist ;-)
>I bet you'll get some advice from the real enterprise gurus there.

Now stop this modesty crap.

You're vbshrinktapiwrapperclass or whatever provided a perfect way
for me to learn tapi.

I broke down the vblineclass you wrote to a line, call, callinfo, and
separate linecallback
class. Your idea of a wrapper inspired me.

So stop saying you're just a blah blah, or i will spread the buggiest code
with your name on it ;-)

Bye.



Sun, 02 Jun 2002 03:00:00 GMT  
 Call-backs - AAARGGHHH! HELP please please please!
Azeus,

Quote:
> Now stop this modesty crap.

Aw gee!  =^_^=  <blush>

Quote:
> So stop saying you're just a blah blah, or i will spread the buggiest code
> with your name on it ;-)

LOL!

Thanks for the encouragement.  It helps.

--
Ray Mercer
MS-MVP Visual Basic
www.shrinkwrapvb.com



Mon, 03 Jun 2002 03:00:00 GMT  
 Call-backs - AAARGGHHH! HELP please please please!

Andrew,

Quote:
> Your initial response actually triggered something in the back of my head
> and yesterday I had a brain explosion...

You have a very graphic style of writing.  ;-)

Quote:
> tested it all and it works!

Glad to hear it.

Quote:
> Of course, now my brain has finally woken up, YOU DON'T NEED TIMER OBJECTS
> TO USE WITHEVENTS, DO YOU?
> Damn, I don't know how long I've been going round in circles with the
basic
> misunderstanding.

Don't you just love it when this happens?  I think Bruce McKinney called it
"the next level of VB enlightenment".  I'm glad to hear that WithEvents
finally clicked for you.  FWIW, the reason most sample code teaching
WithEvents uses timers is simply because it's an easy way to have a class
wait a while before raising the Event, but you are right.  WithEvents has
nothing to do with timers.

Now if I could just get that Enterprise D-Com stuff to click for me...

--
Ray Mercer
MS-MVP Visual Basic
www.shrinkwrapvb.com



Mon, 03 Jun 2002 03:00:00 GMT  
 Call-backs - AAARGGHHH! HELP please please please!
Actually my next task is how to get VB to talk with Oracle Pipes via ADO...
Don't know if it's even possible to do this or not.

In terms of my writing... heh... I actually write for a couple of games mags
and you need your imagination to run wild when you write some of those
reviews... I mean some games are SOOOOOO BAD.

Cheerio


Quote:

> Andrew,

> > Your initial response actually triggered something in the back of my
head
> > and yesterday I had a brain explosion...

> You have a very graphic style of writing.  ;-)

> > tested it all and it works!

> Glad to hear it.

> > Of course, now my brain has finally woken up, YOU DON'T NEED TIMER
OBJECTS
> > TO USE WITHEVENTS, DO YOU?

> > Damn, I don't know how long I've been going round in circles with the
> basic
> > misunderstanding.

> Don't you just love it when this happens?  I think Bruce McKinney called
it
> "the next level of VB enlightenment".  I'm glad to hear that WithEvents
> finally clicked for you.  FWIW, the reason most sample code teaching
> WithEvents uses timers is simply because it's an easy way to have a class
> wait a while before raising the Event, but you are right.  WithEvents has
> nothing to do with timers.

> Now if I could just get that Enterprise D-Com stuff to click for me...

> --
> Ray Mercer
> MS-MVP Visual Basic
> www.shrinkwrapvb.com



Mon, 03 Jun 2002 03:00:00 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

3. PLEASE HELP PLEASE HELP PLEASE HELP

4. API callbacks - need help / example code - PLEASE PLEASE!!!

5. Calling DLL function troubles - please, please help!!!

6. Design Help PLEASE PLEASE PLEASE!

7. Please Please PLEASE HELP!!!!!

8. URGENT HELP PLEASE PLEASE PLEASE???

9. Please please please, help me :-)

10. Please, Please, Please I need help working with dates

11. Please, please, please help!!

12. Cloning problem -- please please please help

 

 
Powered by phpBB® Forum Software