🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.basic.visual.misc
3 messages
3 total messages Started by Bill Mastbrook Thu, 15 Feb 1996 23:03
Multiple instances of a VBX
#166
Author: Bill Mastbrook
Date: Thu, 15 Feb 1996 23:03
17 lines
1133 bytes
How do you differentiate between different instances of a VBX?

When multiple instances of a control are created, the same HCTL value
is always passed to the main control procedure for all messages.  The
HCTL value is used to generate events with the VBFireEvent function.
So, without a unique HCTL value, how do I generate the events in the
correct instance of the control?  

I have created a winsock VBX (with VC++ 1.5) and if multiple
applications using the VBX are opened, all events generated within the
VBX are passed to the last created instance.  

Also, are there any good references for creating VBX's, OCX's, or
converting VBX's to OCX's?

Thanks
Re: Multiple instances of a VBX
#171
Author: Jon Machtynger
Date: Tue, 27 Feb 1996 13:33
31 lines
1848 bytes
mastbrook@duff.com (Bill Mastbrook) wrote:


>How do you differentiate between different instances of a VBX?

>When multiple instances of a control are created, the same HCTL value
>is always passed to the main control procedure for all messages.  The
>HCTL value is used to generate events with the VBFireEvent function.
>So, without a unique HCTL value, how do I generate the events in the
>correct instance of the control?  

This doesn't sound right.  You should be able to use a combination
of the htcl and the hwnd to determine exactly which control and window
you are using.  In other words, the htcl is a unique identifier.

>I have created a winsock VBX (with VC++ 1.5) and if multiple
>applications using the VBX are opened, all events generated within the
>VBX are passed to the last created instance.  

Don't forget that the VBX is shared by all controls using it.  In other words,
if you have any variables declared globally, then all instances are going
to use the info.  How are you referencing your hctl?

>Also, are there any good references for creating VBX's, OCX's, or
>converting VBX's to OCX's?

See OLE Inside out by Mark Denning (I think).  I found it *very* confusing.
I'm no expert at OLE and to be honest, it initially confused the hell out of me.
I'll go back to it in a month or so when I gather enough guts...

Jon
Re: Multiple instances of a VBX
#188
Author: Bill Mastbrook
Date: Mon, 04 Mar 1996 18:42
42 lines
2548 bytes
jonm@ingres.com (Jon Machtynger) wrote:

>>When multiple instances of a control are created, the same HCTL value
>>is always passed to the main control procedure for all messages.  The
>>HCTL value is used to generate events with the VBFireEvent function.
>>So, without a unique HCTL value, how do I generate the events in the
>>correct instance of the control?  

>This doesn't sound right.  You should be able to use a combination
>of the htcl and the hwnd to determine exactly which control and window
>you are using.  In other words, the htcl is a unique identifier.

Inside the main control proc, I put a print statement that printed the
hctl and hwnd values to a file, each time into the proc.  I then
started up multiple instances of a program that uses the VBX.  The
hctl values printed to the file never change, no matter which instance
of the control is currently active.  However, the hwnd values do
change.  So, even though I have a unique hwnd, because the hctl is the
same, all events fired with VBFireEvent go to the same instance of the
control.  Right?

What am I doing wrong?  

The above problem may not even be important if what I describe below
is not possible.  Here's what I'm trying to do ...

I use the VBX to call an api (3rd party) that requests info from a
remote server.  The api calls take a pointer to a function that is
called when the info is returned from the server.  When this function
is called by the api, I need to generate an event telling the calling
VB program that the info was returned and pass the info to the VB
program.  Because the function called by the api doesn't contain the
hctl or hwnd value of the control, how can I generate events in the
correct instance of the VBX from this function?  Is it possible
without changing the api to accomodate the handle in both the function
called to request the information and the function called by the api
to return the information?

Any suggestions will be greatly appreciated.

Thanks,
Bill
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads