I have played around with COM in ASM and tried out the source code example "AsmCtrl" in masm32\com\examples.

This code works with VB6, but the ActiveX Control Test Container of VC50 refuses to load it. By examining the reasons I have created an "improved" version of ASMCTRL.ASM working with VC, with the following changes:

1. Included Interface "IPersistStorage", which is needed for embeddable objects. Without this interface, VC50 does not load controls.

2. Eliminated some major bugs in ASMCTRL.ASM

3. in AsmCtrl_vtable.inc, include IPersist_Storage:



IPersist DWORD QueryInterface
DWORD AddRef
DWORD Release
DWORD IPersist_GetClassID
IPersistStorage DWORD QueryInterface
DWORD AddRef
DWORD Release
DWORD IPersist_GetClassID
DWORD IPersistStorage_IsDirty
DWORD IPersistStorage_InitNew
DWORD IPersistStorage_Load
DWORD IPersistStorage_Save
DWORD IPersistStorage_SaveCompleted
DWORD IPersistStorage_HandsOffStorage
IPersistStreamInit DWORD QueryInterface
DWORD AddRef


4. in DllMain.asm in directory cofiles you should change returncode in eax to TRUE in the .ELSE branch:



.IF dwReason == DLL_PROCESS_ATTACH
mov eax, hModule
mov g_hModule, eax
; get handle for global heap
invoke GetProcessHeap
mov g_hHeap, eax
mov eax, TRUE
.ELSEIF dwReason == DLL_PROCESS_DETACH
mov eax, TRUE
.ELSE
mov eax, TRUE
; xor eax, eax ; mov eax, FALSE
.ENDIF
ret
DllMain Endp


japheth
Posted on 2001-08-06 04:49:36 by japheth
the above AsmCtrl version is still a "passive" control. That is if it is included as a OCX/ActiveX control in VC5, for example, it will be shown in design mode (resource editor) but not in the running program. The reason is normally a container app does "activate" an activex control when it is generated. For the control this means:

- it must implement interface IOleInPlaceObject
- when activated, the control must create a window (if it is not a windowless control, which requires certain other Interfaces to be implemented).

I have extended the AsmCtrl example in this manner and it is displayed now in a "standard" OCX container.
Posted on 2001-08-14 07:44:57 by japheth
Hello,

Playing again with the AsmCtrl example from Ernie, I have implemented event handling (connection points) to the control so it is now "full featured".

The source now really needs some restructuring and is really bad "for educational purposes", but if anyone is interested in it it is supplied for download here. Please read the readme included.

japheth
Posted on 2001-08-31 06:09:59 by japheth