Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActX DLL or ActX Control ... Which will get the job done? 1

Status
Not open for further replies.

x508

Programmer
Jun 26, 2003
396
ZA
Hi.

Last night I created a licensing system in the form of an activeX dll, it works kewl...evrything relies on the dll and I only have to write one line of code in my app to make it have a licensing system....coolstuff....

Now.

I whish to do the same for my "login" and "manage user accounts" forms. i.e, I want to create them once and then just use them from the dll or OCX, in all my different apps.

Whith which will I be able to do this....I guesse I will have to pass to the OCX or DLL an array of users, that my app gets and creates from the database, or give it a "record source", to get the data from the recordset itself. The OCX or DLL will also have to be able to save/edit/create new users, so it will have to pass arguments back to the original program...

Am i making any sense at all???


Thanks in advance :)

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
You are indeed.

Read about "Raise" and "WithEvents" in the docs.

Raise is used to have your dll fire an event of your own making, so you can catch it in the main application.

When you dim your dll object in the main application, write it like this :

Dim WithEvents objWhatever as ClassName

Now in the DLL class declarations section, write a line like this:

Public Event MyEvent(intA as integer, strB as string)

Again, in the DLL class, when ever you want to fire the event, you call the Raise method - like this:

Raise MyEvent(14,"Wibble")

Now, back to the main application - where we included the WithEvents... If you look, you should see your DLL object listed as something which has events (just like you'd expect to see a Textbox, Listbox etc...).

You are now, as they say, cooking...

BTW, I would suggest your scenario is an ActiveX DLL.

mmilan

 
Good stuff mmilan

I understand what you are saying...and I will apply it.

Now, this takes care of my dll talking to my app, but how would I pass an array of users, with their Rights, to the dll, to load them into the Users form.

I suppose I can create a multi-dimensional array, for the username, passw and rights.

I will then fill this array in my code, and pass it to the dll HOW, and the dll will use it HOW?

Maybe I'm just stooped today, but I cannot seem to get around the logic of it all (Probably a bit *dumb" due to the fact that I only went to bed at 1:00AM this morning, working onm y licensing system..lol)

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
I would create a class in your DLL to hold the user information (UserName, Password, Rights etc), and make this PUBLIC. You should then be able to create an array of such objects in the main application, and then pass the array into the DLL as a function argument / property.

If you pass it by reference, your DLL could operate on the objects and any results would be visible to the main application.

You MAY be able to do this using a Type instead of a Class, which would be simpler in theory. Having said that, I've had problems in the past using Types in this manner, and the object approach is more powerful.

mmilan
 
Thanks mmilan



*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Thanks, I got it right passing a an array to the dll (just like passing a normal variable).....really easy actually

Now I will have a look at the with and raise events as soon as I get home tonight

Thanks

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
About the with and raise events....

I created an event in my class module....and then dimmed the module "withevents", but the moment I dim it with "withEvents", i cannot access the functions of the module (is not available/does not pop up)

Another thing...where do I get the event from...do I have to write it myself or am i supposed to see it somewhere?

Thanks in advance

*****************************************
May the Code Be With You...[lightsaber]
----------
x50-8 (X Fifty Eigt)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top