The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: feicong on July 30, 2009, 09:07:39 AM

Title: how to use activex controls in the win32asm project ?
Post by: feicong on July 30, 2009, 09:07:39 AM
  i just got an activex control niceform ,how to use it to asm?
Title: Re: how to use activex controls in the win32asm project ?
Post by: ecube on July 30, 2009, 09:12:23 AM
MASM use to contain nice com examples that showed how to interface/create/etc ocx components, unfortunately it was removed, I have source somewhere if you need it. But basically COM with asm is abit tricky, atleast to me, and i've been trying to get the hang of it for years, for some reason it's all hasn't sunk in yet.
Title: Re: how to use activex controls in the win32asm project ?
Post by: Biterider on July 30, 2009, 09:26:08 AM
Hi
Basically you need to write a COM container for your ActiveX control. Another way is to use the ATL library that acts as a general purpose container.
Here (http://www.asmcommunity.net/board/index.php?topic=29472.0), you can find some sources for a MASM container implementation and here (http://www.masm32.com/board/index.php?topic=11558.0) are some sources using the ATL lib.

Regards,

Biterider
Title: Re: how to use activex controls in the win32asm project ?
Post by: feicong on July 30, 2009, 12:03:03 PM
 thanks E^cube  and Biterider!!
Title: Re: how to use activex controls in the win32asm project ?
Post by: BATSoftware on August 01, 2009, 01:27:54 PM
I have to look at this container. I too wrote an OCX container that merges OLE controls and standard window's controls. What interfaces does your container implement other than the bare bones to run a control)? My container stubbes IStorage and forgoes inplace editing and drag/drop.

A note on calling OLE controls: you need DISPIDs and/or a VTBL structure not to mention the method prototypes. I have a free solution! OLEHDR. A little MASM32 program that generates all necessary typedefs/stuctures/constants to interface to an OLE control. It can be downloaded for free at:
http://home.comcast.net/~batsoftware/OLEHDR/htm/OLEHDR.HTM

Once I complete my last project - Visual Basic FRM to RC/OLE converter, I will package up the OLE container and write up some docs for it. The container will be a simple DLL with a few entry points to initialize, uninitalize, and set/get properties/variables using either a VTBL or IDispatch.

I was going to write a Visual Basic to ASM source code generator, but since VB6 is no longer actively supported, I cant see any benefit for the 3-4 months of work it would entail. I would be fun though. Too bad the towel heads at M$ have destroyed the software ENGINEERING field.
Title: Re: how to use activex controls in the win32asm project ?
Post by: Biterider on August 01, 2009, 03:59:27 PM
Hi
This container implements the following interfaces described as the minimum set by MS here (http://msdn.microsoft.com/en-us/library/ms691268(VS.85).aspx). The difference to this container is that can commect to many servers (controls) simultaniously and if follows the "In-Place" window model.

This is the containr layout:

;                    OCX Container                                        OCX Control
;                                                                             1..n
;                                  ———                                                ———
;                                 |   |                                              |   |
;                                  ———                                                ———
;                                   |                                                  |
;      ————————————————————————————————————                        ———————————————————————————
;     |                             |      |                      |                 IUnknown  |
;     |       OCX Client Site 1..n  |      |                      |                           |
;     |       ———————————————————————————  |              ———     |                           |
;     |     —|                  IUnknown | |             |   |————| IOleObject                |
;     |   —| |                    Site   | |              ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IOleClientSite            |—|——|   |      |   |————| IOleInPlaceObject         |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IAdviseSink               |—|——|   |      |   |————| IOleInPlaceActiveObject   |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IOleInPlaceSite           |—|——|   |      |   |————| IOleControl               |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IOleControlSite           |—|——|   |      |   |————| IDataObject               |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IOleContainer             |—|——|   |      |   |————| IViewObject2              |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IDispatch                 |—|——|   |      |   |————| IDispatch                 |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | ISimpleFrameSite          |—|——|   |      |   |————| IConnectionPointContainer |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IPropertyNotifySink       |—|——|   |      |   |————| IProvideClassInfo(2)      |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | | IErrorInfo                |—|——|   |      |   |————| ISpecifyPropertyPages     |
;     |  | | |                           | |   ———        ———     |                           |
;     |  | | |                           | |              ———     |                           |
;     |  | | |                           | |             |   |————| IPersist...  (*)          |
;     |  | | |                           | |              ———     |                           |
;     |  | | '———————————————————————————' |              ———     |                           |
;     |  | '————————————————————————————'  |             |   |————| IOleCache(2)              |
;     |  '————————————————————————————'    |              ———     |                           |
;     |                                    |              ———     |                           |
;     |                                    |             |   |————| IExternalConnection       |
;     '————————————————————————————————————'              ———     |                           |
;                                                         ———     |                           |
;                                                        |   |————| IRunnableObject           |
;                                                         ———     |                           |
;                                                         ———     |                           |
;                                                        |   |————| IClassFactory2            |
;                                                         ———     |                           |
;                                                                 |                           |
;                                                                 '———————————————————————————'


Regards,

Biterider
Title: Re: how to use activex controls in the win32asm project ?
Post by: ecube on August 01, 2009, 04:27:03 PM
On a side note, many of you know of Visual Basic, which is a language whos functionality is mostly COM based, so naturally using any com compenent in it is a cake walk, nothing like doin it in ASM :P anyway what i'm gettin at is I found a nice way to make VB create *real dll's, so you can do all your COM stuff in vb, and backend stuff in ASM, supports everything vb usually supports. Here's info

http://www.masm32.com/board/index.php?topic=11103.0