Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VC++ 2008: "MFC class from ActiveX control" wizard doesn't expose any properties

108 views
Skip to first unread message

Vladimir Svrkota

unread,
Apr 8, 2008, 4:43:49 PM4/8/08
to
Recently I was forced to switch from VC++ 6 to VC++ 2008. Many projects
to convert, many errors to fix, many days to -- well -- spend. One day
I recompiled and registered a MFC ActiveX control. That went fine. I
had a few projects that use that control, so I removed the old H/CPP
wrapper files from one of them and imported the control using Project
-> Add Class -> MFC Class From ActiveX Control. The wizard re-generated
H/CPP files, containing wrapper class for the control. When I
recompiled the project I got many errors saying dozens and dozens of
Get/Set methods are not members of my control (wrapper). I looked into
generated H file of the wrapper class and found out the compiler was
right: there were no Get/Set methods for any of the properties
contained in the control.

After a few tries and failures I decided to start from the scratch. I
created a simple MFC ActiveX control containing only two properties --
Prop1 and Prop2 of type LONG -- and two empty methods -- Method1 and
Method2. All checkboxes and radio buttons in wizards were left on their
default values while doing that. I imported the control the same way as
before into a newly created MFC application and got the same problem:
wrapper class contained only Method1 and Method2, but no Get/Set
methods for the properties Prop1 and Prop2.

What am I doing wrong?

--
Best regards,
Vladimir.

Ajay Kalra

unread,
Apr 8, 2008, 10:07:00 PM4/8/08
to

I dont have the answer to this, except that are you certain that the
control that you are importing does indeed have get/set properties?
How are you certain about it.

Since you have Vc6, try importing the same control and see if you get
the get/set on the resulting .tlh/.tli.

---
Ajay

Vladimir Svrkota

unread,
Apr 9, 2008, 2:39:05 AM4/9/08
to
Ajay Kalra wrote:

> are you certain that the control that you are importing does indeed
> have get/set properties? How are you certain about it.

I am certain because I wrote and used the control in a few projects :).
But I'm not talking about "get/set properties", it's just "properties".
The wizard mentioned in previous message (not #import directive!) should
generate h/cpp files for a wrapper class derived from CWnd containing
get/set methods for those properties (if there's a property named Prop1,
there should be GetProp1() and SetProp1() methods). At least it did in
vc6.

> Since you have Vc6, try importing the same control and see if you get
> the get/set on the resulting .tlh/.tli.

There's no tlh/tli files because I'm not using #import directive. When I
tried it, it generated get/set methods in both vc6 and vc2008, but
that's not what I need. I need CWnd derivate to use the control in
projects, not interfaces.

--
Best regards,
Vladimir.

Ajay Kalra

unread,
Apr 9, 2008, 9:03:37 AM4/9/08
to
On Apr 9, 2:39 am, Vladimir Svrkota <s...@reply.to> wrote:
> Ajay Kalra wrote:
> > are you certain that the control that you are importing does indeed
> > have get/set properties? How are you certain about it.
>
> I am certain because I wrote and used the control in a few projects :).
> But I'm not talking about "get/set properties", it's just "properties".
> The wizard mentioned in previous message (not #import directive!) should
> generate h/cpp files for a wrapper class derived from CWnd containing
> get/set methods for those properties (if there's a property named Prop1,
> there should be GetProp1() and SetProp1() methods). At least it did in
> vc6.
>

I see what you are saying. I dont any answer for this though. There
may be some option that you may need to check in the wizard but I am
not sure.

---
Ajay

Ganyukov@discussions.microsoft.com Alex Ganyukov

unread,
Apr 22, 2008, 10:40:03 AM4/22/08
to

"Ajay Kalra" wrote:

Vladimir,

I do have the same issue with properties names in C++ generated wrapper
classes for the OCX.
VS 6 creates them as Get/SetSomeName and VS 2008 as get_/put_SomeName. So
far I don't know how to force VS 2008 to generate Get/Set names.
Did you find any solution for this problem?

Alex

Vladimir Svrkota

unread,
Apr 23, 2008, 2:08:56 AM4/23/08
to
Alex Ganyukov wrote:

> Vladimir,
>
> I do have the same issue with properties names in C++ generated wrapper
> classes for the OCX.
> VS 6 creates them as Get/SetSomeName and VS 2008 as get_/put_SomeName. So
> far I don't know how to force VS 2008 to generate Get/Set names.
> Did you find any solution for this problem?

Hi, Alex.

Seems like it simply doesn't work in VS 2008. I asked the same question
on CodeProject and MSDN forums and got no answer. I tried Google and
found a guy with the same problem -- in VS 2003! -- meaning this issue
existed long before VS 2008. Scary, don't you think?

I found out a workaround by accident. It's not elegant, but it does the
trick. When I put the OCX control on any dialog and create a member
variable of it, VS 2008 generates h/cpp files and Get/Set methods for
the properties correctly. Then I remove the member variable and OCX
control from the dialog and keep generated h/cpp files.

I hope this helps.

--
Best regards,
Vladimir.

Ajay Kalra

unread,
Apr 23, 2008, 9:32:55 AM4/23/08
to
> I found out a workaround by accident. It's not elegant, but it does the
> trick. When I put the OCX control on any dialog and create a member
> variable of it, VS 2008 generates h/cpp files and Get/Set methods for
> the properties correctly. Then I remove the member variable and OCX
> control from the dialog and keep generated h/cpp files.
>

Wow. Thats a neat trick. I would guess then that this feature exists
but either its a bug in your earlier scenario or simply a new feature.

---
Ajay

Vladimir Svrkota

unread,
Apr 23, 2008, 12:04:02 PM4/23/08
to
Ajay Kalra wrote:

> Wow. Thats a neat trick. I would guess then that this feature exists
> but either its a bug in your earlier scenario or simply a new feature.

It's funny how both scenarios generated the same h/cpp files in good old
VS 6. Seems to me things have changed since. But hey, at least there is
a way for me to keep my old VS 6 projects unmodified -- it would be such
an "amusement" finding all Get/Set occurencies and replacing them with
get/put :[

--
Best regards,
Vladimir.

Alex Ganyukov

unread,
Apr 23, 2008, 11:39:00 AM4/23/08
to

"Vladimir Svrkota" wrote:

This approach works for the properties without any input parameters. Wrapper
class calls them via GetProperty/SetProperty like:
GetProperty(0x59, VT_BOOL, (void*)&result);
SetProperty(0x59, VT_BOOL, propVal);

But it doesn’t work for properties with input parameter(s). Wrapper class
calls them via InvokeHelper like:
InvokeHelper(0x110, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, parms,
nCol);
InvokeHelper(0x110, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, nCol,
newValue);

These properties in VS2008 wrapper still have names like get_/put_:
It seems like I will use VS6 to generate wrapper classes so far.
Otherwise I have to redo a lot of code that use this OCX (well at least this
OCX is for my company internal use only).

Thanks,
Alex

>

riversam

unread,
Jul 9, 2008, 6:34:07 AM7/9/08
to

stevebryndin

unread,
Dec 15, 2008, 9:29:44 AM12/15/08
to
The easiest but does require some hand work.
Open IDL file and in the section properies:

example:

[id(1), helpstring("property ActiveSheet")] LONG ActiveSheet;

change to:

[id(1), propget, helpstring("property ActiveSheet")] LONG ActiveSheet();
[id(1), propput, helpstring("property ActiveSheet")] void ActiveSheet(LONG newVal);

and move these two lines into "methods section".


After that Property generated correctly by the MFC class From ActiveX control wizard

0 new messages