1. RE: my dll troubles

Mike Hurley wrote:
> could someone possibly write a simple demo that will declare a class in 
> the dll and use it in another application?  would i be better off just 
> doing some kind of mylib_init() and have the user pass the instance to 
> that and do it with the application's instance?  wouldn't that clog the 
> system if many apps used the same dll i make?  the way i want to do it 
> should work, i just don't know all the particulars.  please email me the 
> demo via private email.  thanks.
> 
> my email address if you can't see it: mike_hurley_2 at yahoo.com (or 
> mikehurley.1 at worldnet.att.net, whichever)
> 
   Mike:
   Here is a complete example using borland Compiler.
   http://community.borland.com/article/0,1410,15624,00.html
   Let me know if this helps.
Bernie

new topic     » topic index » view message » categorize

2. RE: my dll troubles

-----Original Message-----
From: Mike Hurley [mailto:mikehurley.1 at worldnet.att.net]

>could someone possibly write a simple demo that will declare a class 
>in the dll and use it in another application?  would i be better off 
>just doing some kind of mylib_init() and have the user pass the instance 
>to that and do it with the application's instance?  wouldn't that clog 
>the system if many apps used the same dll i make?  the way i want to do 
>it should work, i just don't know all the particulars.  please email 
>me the demo via private email.  thanks.

OK, since you're talking class, I assume you're using C++.  I think what
you'd want to do is call the constructor (or a function in the dll that
calls the constructor--probably a better idea for Eu) and pass the 'this'
pointer back.  Now, any C++ app will only need your header declaring the
class to figure out how to use objects of that class.

You can also call C++ object's members from Euphoria, but you'll have to be
able to call a routine by pointer (see fptr.e in EuCOM).  Here's an example:

include fptr.e
atom this, vtbl, ok, pfunc
this = c_func( my_class_constructor, {})
vtbl = peek4u( this )
pfunc = peek4u( vtbl + func_offset * 4 )
ok = call_fptr( pfunc, {this[, args...]})

Here's what that does.  The 'this' pointer stores the address of the virtual
function table (vtbl).  That table is an array of pointers to the member
functions of the class.  So you need to get the pointer to the member you're
interested in.  Then you simply call the function by pointer, passing the
'this' pointer as the first argument (C++ does this for you on every call).
The 'this' pointer indicates which instance of the class you're using.

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. RE: my dll troubles

Mike Hurley wrote:
> when i say class i mean something that would be passed to 
> RegisterWindowEx()
> or RegisterWindow.
> 
Mike:

  What I think you trying to do is to defined a WC structure
  When your DLL initializes, use a for loop to go through
  your class definitions and fill in the WC structure and register
  it. Then as along as your user knows the name of your predefined
  defined classes; they can create a instance of that class
  with a createwindow function or etc.
 
  If you wanted to do this with Euphoria then you would have
  a constant sequence listing the parameters of of each WC structure.
  and when DLL initializes, you would poke the them into the WC
  structure and register it and then go on to the next sequence
  discription.
    
  What registering a class does is tells windows to keep a copy of
  each definition and relates that to your CLASS NAME. Don't worry
  about memory managememt for the DLL or how many users are using
  your DLL; windows will worry about that. 

Bernie

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu