ActiveX - writing a client.

Windows specific forum
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

ActiveX - writing a client.

Post by Dare2 »

I am interested in learning about using ActiveX within PB. The stuff I have seen here is very clever and way too complex for me at this stage.

I am hoping that by discussion, Q&A - with participation by those who want to know and those who do know - we can come up with a simplified and understandable approach to this.

I am willing to show my ignorance and (mis)understanding of the subject to kick things off. :) As far as I can tell, in order to use an ActiveX control, the following broad categories apply:

  1: Know the available ActiveX functions/methods/properties (Interface).
This would come from docs, etc, by the supplier of the control. Leo's code can also help here.

  2: Make the activeX control accessible via PB.
From looking at stuff by Danilo, Freak and Leo it appears we need to:
coInitialize and perhaps create an instance of the object.
Perhaps openLibrary is needed.

  3: Have a mechanism to interact with the interface.
Have an interface (listing available functionality)
Somehow connect or link or associate the PB interface with the object.
If the object needs a place to do it's thing, provide one, eg a window or a gadget.

  4: Use it
This may involve receiving information via callbacks as well as simply sending information or requesting information.

  5: Clean up and go.
CoUnitialize, unload object if loaded, etc, so the thing doesn't hang around until the next reboot.

All of which sounds fine and dandy, but the actual doing appears very complex and the approaches shown here appear to differ quite a bit.

So, hopefully there is more than one way, and hopefully we can come up with a simple and generic-ish approach to this, and also demystify the process as well.

Maybe we could end up with some code that becomes a library or an include file or something and leads to:

Code: Select all

Interface
..
EndInterface

Structure
..
EndStructure

..

registerObject(rName$, rGUID$, @myJumpTable)
..

myJumpTable.doSomething(args)

..

unRegisterObject(@myJumpTable)
Whatever. And maybe not, maybe just get to a point where we could write our own.

If you have the smallest interest, if you have the knowledge or want it, please participate (Questions, Answers, Speculation, Etc)
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

One alternative is, sometimes, to use VBS from PureBasic (fllohimself has a very good lib to do that).

This code can control MSWord:

Code: Select all

Set objWrd = CreateObject ("Word.Application")

objWrd.WindowState = vbNormal ' Normal
objWrd.Height = 300 ' height
objWrd.Width = 400 ' width
objWrd.Left = 40 ' X-Position
objWrd.Top = 20 ' Y-Position
objWrd.Visible = true ' show window

' try to write something into the title- and statusbar
objWrd.Caption = Title
objWrd.Statusbar = "Date: " & Date
objwrd.Quit

The you could write some vbs functions (with parameters if you want) and call it from PurBasic to control an external Activex.

There are 2 problems sometimes:

a) When the Activex send back some results to the functions.

Using Flohimself lib dont allow to cathc the result, thats why i develope my activex dll.

b) When the Activex needs a container.

Sometimes you can use a webgadget to contain the visible part of the Activez, but maybe its not possible to do it with all the Activex.


However, using vbs is a possibilitie to interact with some activex from PB in an easy way.
ARGENTINA WORLD CHAMPION
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

As you know, I'm working on this one myself.

I'm finding there is a lot more that is needed before ActiveX use is in the reach of a moderate user.

For example, COM has its own, rather complex, datatypes. The 3 main ones are VARIANT, BSTR and SAFEARRAY.

A simple method for using this types is necessary from purebasic.

My current thinking is to create native PB objects to wrap them.
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Re: ActiveX - writing a client.

Post by Blade »

Dare2 wrote:I am interested in learning about using ActiveX within PB. The stuff I have seen here is very clever and way too complex for me at this stage.
(...)
Maybe we could end up with some code that becomes a library or an include file or something and leads to:

Code: Select all

Interface
[/quote]

Yes, excellent idea, Basic has to be basic, and (as you said) all the COM examples were too complex to use/learn. Why we have to program as if PB was C++ ???
If the same thing can be done with some easy procedure call, that would be great!
User avatar
SimpleMind
Enthusiast
Enthusiast
Posts: 112
Joined: Sun May 18, 2003 12:40 pm
Location: Netherlands

ActiveX OCX

Post by SimpleMind »

Hi,

Has this topic already a follow up? I'm also looking at a simple :wink: way to use or create ActiveX components.
Post Reply