-
September 4th, 2012, 01:00 PM
#1
How to generate a class with properties from an ActiveX control?
Greetings!
I am using Visual Studio 2008.
I need to generate a wrapper class for an ActiveX control that has public methods and a public property. The generated class has no methods for dealing with the ConnectionString property. What do I have to do to get it?
The definition of the class, using Visual Studio 6's OLE/COM Object Viewer, is below, along with the generated class files.
Also, if you would be so kind, could you point me to a replacement for the OLE/COM object viewer? It doesn't seem to ship with VS 2008 (or at least, I've never found it.
And what happened to word wrapping in this forum? As I'm typing this, "least" got split into two lines.
RobR
Code:
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: ScheduleDisplay.ocx
[
uuid(08AA35D4-440B-4E9F-9086-EE7B30FBE945),
version(1.0),
helpstring("ScheduleDisplay ActiveX Control module"),
helpfile("ScheduleDisplay.hlp"),
helpcontext(00000000)
]
library ScheduleDisplayLib
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
dispinterface _DScheduleDisplay;
dispinterface _DScheduleDisplayEvents;
[
uuid(E79DA7E1-5FDE-4087-ABE1-AE414576C00B),
helpstring("Dispatch interface for ScheduleDisplay Control")
]
dispinterface _DScheduleDisplay {
properties:
[id(0x00000001), helpstring("property ConnectionString")
]
BSTR ConnectionString;
methods:
[id(0xfffffdd8)]
void AboutBox();
[id(0x00000002), helpstring("method Draw")]
void Draw(
long left,
long top,
long right,
long bottom);
[id(0x00000003), helpstring("method DrawManager")]
void DrawManager(long pManager);
[id(0x00000004), helpstring("method GetManager")]
long GetManager();
};
[
uuid(2AAE5A5B-8091-4E0D-9A39-F55A00D7EC3D),
helpstring("Event interface for ScheduleDisplay Control")
]
dispinterface _DScheduleDisplayEvents {
properties:
methods:
};
[
uuid(86967618-BE35-440A-90F9-2D1306326BBD),
helpstring("ScheduleDisplay Control"),
control
]
coclass ScheduleDisplay {
[default] dispinterface _DScheduleDisplay;
[default, source] dispinterface _DScheduleDisplayEvents;
};
};
Code:
// CDScheduleDisplay0.h : Declaration of ActiveX Control wrapper class(es) created by Microsoft Visual C++
#pragma once
/////////////////////////////////////////////////////////////////////////////
// CDScheduleDisplay0
class CDScheduleDisplay0 : public CWnd
{
protected:
DECLARE_DYNCREATE(CDScheduleDisplay0)
public:
CLSID const& GetClsid()
{
static CLSID const clsid
= { 0x86967618, 0xBE35, 0x440A, { 0x90, 0xF9, 0x2D, 0x13, 0x6, 0x32, 0x6B, 0xBD } };
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
}
BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey);
}
// Attributes
public:
// Operations
public:
void AboutBox()
{
InvokeHelper(DISPID_ABOUTBOX, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
void Draw(long left, long top, long right, long bottom)
{
static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4 ;
InvokeHelper(0x2, DISPATCH_METHOD, VT_EMPTY, NULL, parms, left, top, right, bottom);
}
void DrawManager(long pManager)
{
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x3, DISPATCH_METHOD, VT_EMPTY, NULL, parms, pManager);
}
long GetManager()
{
long result;
InvokeHelper(0x4, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
};
-
September 5th, 2012, 02:29 AM
#2
Re: How to generate a class with properties from an ActiveX control?
When adding class to project, there should be options like "MFC Class from Type Library" or "MFC Class from ActiveX Control."
Best regards,
Igor
-
September 5th, 2012, 08:58 AM
#3
Re: How to generate a class with properties from an ActiveX control?
Which do you recommend I use? I mainly ask out of curiosity, since I already found an answer. I don't know if it's the best answer. I had been using "MFC Class from ActiveX Control". That gave me the public methods of my control, but it did not give me access to public properties. But when I used "MFC Class from Type Library", I got Set and Get methods for the property, and I was able to proceed from there.
Thanks again!
RobR
-
September 6th, 2012, 01:50 AM
#4
Re: How to generate a class with properties from an ActiveX control?
Actually I have no recommendations just because I almost never use MFC wrappers.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|