i've this code in c++:


#ifndef _HEXVIEW_INCLUDED
#define _HEXVIEW_INCLUDED

#include <windows.h>
#include <tchar.h>

#include "hexbaset.h"
#include "sequence.hpp"

#pragma warning( disable : 4530 )

class MyDataObject;
class MyDropTarget;

#define HV_MAX_COLS 13

class HexViewCtrl
{
public:

HWND hwnd;

//
// Basic constructor / destructor
//
HexViewCtrl(HWND hwnd);
~HexViewCtrl();

//
// -----------------------------------------------------
// Message Handler member functions
// -----------------------------------------------------
//
LRESULT OnNCCreate (WPARAM wParam, LPARAM lParam);
LRESULT OnCreate (WPARAM wParam, LPARAM lParam);
LRESULT OnDestroy (WPARAM wParam, LPARAM lParam);
(...)
private:
(...)


and i'm trying to use this class object with assembly, thus i guess i've to build the structure like this:



; IPersistFile Interface
IPersistFile STRUCT DWORD
IPersistFile_QueryInterface comethod3 ?
IPersistFile_AddRef comethod1 ?
IPersistFile_Release comethod1 ?
IPersistFile_GetClassID comethod2 ?
IPersistFile_IsDirty comethod1 ?
IPersistFile_Load comethod3 ?
IPersistFile_Save comethod3 ?
IPersistFile_SaveCompleted comethod2 ?
IPersistFile_GetCurFile comethod2 ?
IPersistFile ENDS

of Ernest Murphy shelllink sample.
I've to keep QueryInterface, AddRef and Release, and
add the rest of the methods right?
like,


HexViewCtrl STRUCT DWORD
IPersistFile_QueryInterface comethod3 ?
IPersistFile_AddRef comethod1 ?
IPersistFile_Release comethod1 ?

hwnd DWORD ?
HexViewCtrl commethod1 ?
OnNCCreate commethod2 ?
(...)

i guess i just have to put in the same order..
I don't know much about C++, Interfaces and Objects... tnkx in advance.

Jean
Posted on 2002-06-11 09:04:01 by coder
Gee... somewhere in my fuzzy brain I should remember this... wish my Inside COM book was handy to review.

I'm not so good at C++ (I can read C OK, C++ not so OK, but passably). It seems the class you are creating there is a "straight" C++ class, not a COM object. The main difference being you don't include the IUnknown as the base of your exported interface.

To get asm to use this code, you must supply some method to return a HexViewCtrl object pointer. Then I believe (and I'm sure many people will jump on me if I'm wrong here) you can access the C++ object with the following interface and a CoInvoke call:



IHexViewCtrl STRUCT

IHexViewCtrl_OnNCCreate comethod3 ?
IHexViewCtrl_OnCreate comethod3 ?
IHexViewCtrl_OnDestroy comethod3 ?

IHexViewCtrl ENDS
Posted on 2002-06-11 22:06:47 by Ernie
coder7345,

to use C++ classes in ASM its not nessessary to create a vtable (like the COM interfaces). Lookt this thread .

To avoid problems with C++ name decorations see f0dders remarks about writing small C wrappers.

But if you really want to use "COM interface"-like vtables you have to declare your methods as "virtual". If a class has some virtual functions (or inherits any) C++ will generate a vtable and store a pointer to this vtable in the object (VC and others store that pointer at offset 0 like COM).

japheth
Posted on 2002-06-12 06:56:38 by japheth