VC2008: "MFC class from ActiveX control" wizard doesn't expose any properties
-
I was recently forced to switch from VC6 to VC2008. 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?
-- Vladimir Svrkota, CardWare Novi Sad, Serbia.
-
I was recently forced to switch from VC6 to VC2008. 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?
-- Vladimir Svrkota, CardWare Novi Sad, Serbia.
Hi Vladimir I run exactly in the same problem with VS2005. In case you find a solution, please inform me THANK YOU VERY MUCH!!!. I need the import over ActiveX because this generates a CWND derivated class. However, i get all properties and also events (which are missing too for ActiveX class) when i generate a class by TypeLib (actualle this generates 2 Files, the events are separated). Maybe it´s possible to take from typelib generated files the missing parts and hack them in the file from the ActiveX import. A nuisance, however! Best regards Stefan
-
Hi Vladimir I run exactly in the same problem with VS2005. In case you find a solution, please inform me THANK YOU VERY MUCH!!!. I need the import over ActiveX because this generates a CWND derivated class. However, i get all properties and also events (which are missing too for ActiveX class) when i generate a class by TypeLib (actualle this generates 2 Files, the events are separated). Maybe it´s possible to take from typelib generated files the missing parts and hack them in the file from the ActiveX import. A nuisance, however! Best regards Stefan
Rehi ok, i have a weird solution, but it seems to work: Starting from a scratch container: 1.1) Insert ActiveX in resource editor 1.2) Assign a control variable. This generates a CWND derivated class with all props, events can be assigned by adding event handler and so on. Update is difficult however, except one deletes always the control and redo it (maybe even the way with less effort). Anyway: Updating ActiveX ( added method, event, whatever ) 2.1 Remove every file for control declaration from the project (.h, .cpp) by destroying it! 2.2 leave project, delete the .ncb file, restart project but do not compile anything that would remake the ncb file 2.3 Add the control by the MFC ActiveX class. Name will be different by default then for 1) 2.4 Add the control by the MFC TypeLib, choose there the methods AND events. this will generate 2 more header file types of similar name 2.5 copy the missing parts form the typelib header files into the activex class (event block, property) 2.5 Destroy the generated typlib files, delete the includes 2.6 Remove added includes (in case they were already defined) of afxdisp.h in stdafx.h and the control header file in your main application - else you get after some new class inserts a long list of same include definitions. and only once after you did 1) 3.1 Destroy the control files from 1) 3.2 Replace the object class from 1) by the new activeX class Seems to work, at least in a very simple test Regards Stefan
modified on Wednesday, June 25, 2008 4:51 AM
-
Rehi ok, i have a weird solution, but it seems to work: Starting from a scratch container: 1.1) Insert ActiveX in resource editor 1.2) Assign a control variable. This generates a CWND derivated class with all props, events can be assigned by adding event handler and so on. Update is difficult however, except one deletes always the control and redo it (maybe even the way with less effort). Anyway: Updating ActiveX ( added method, event, whatever ) 2.1 Remove every file for control declaration from the project (.h, .cpp) by destroying it! 2.2 leave project, delete the .ncb file, restart project but do not compile anything that would remake the ncb file 2.3 Add the control by the MFC ActiveX class. Name will be different by default then for 1) 2.4 Add the control by the MFC TypeLib, choose there the methods AND events. this will generate 2 more header file types of similar name 2.5 copy the missing parts form the typelib header files into the activex class (event block, property) 2.5 Destroy the generated typlib files, delete the includes 2.6 Remove added includes (in case they were already defined) of afxdisp.h in stdafx.h and the control header file in your main application - else you get after some new class inserts a long list of same include definitions. and only once after you did 1) 3.1 Destroy the control files from 1) 3.2 Replace the object class from 1) by the new activeX class Seems to work, at least in a very simple test Regards Stefan
modified on Wednesday, June 25, 2008 4:51 AM
Stefan_L_01 wrote:
1.1) Insert ActiveX in resource editor 1.2) Assign a control variable. This generates a CWND derivated class with all props, events can be assigned by adding event handler and so on. Update is difficult however, except one deletes always the control and redo it (maybe even the way with less effort).
Yes, this is the same solution I accidentaly discovered, take a look at this thread[^] in microsoft.public.vc.mfc newsgroup. This "trick" gave me Visual C++ 6 compatible :) h/cpp files and that was all I needed at the time. Fortunately, my OCX control won't be needing any changes in the near future, but it's nice to have your solution when it comes to that. Thank you. By the way, while googling around I found out this problem appeared in the first release of Visual Studio .NET (version 7.0, a.k.a. 2002), it remained in VS2003, VS2005 and it's quite strange it's still present in the most recent VS2008, so many years later.
-- Vladimir Svrkota, CardWare Novi Sad, Serbia.
-
Stefan_L_01 wrote:
1.1) Insert ActiveX in resource editor 1.2) Assign a control variable. This generates a CWND derivated class with all props, events can be assigned by adding event handler and so on. Update is difficult however, except one deletes always the control and redo it (maybe even the way with less effort).
Yes, this is the same solution I accidentaly discovered, take a look at this thread[^] in microsoft.public.vc.mfc newsgroup. This "trick" gave me Visual C++ 6 compatible :) h/cpp files and that was all I needed at the time. Fortunately, my OCX control won't be needing any changes in the near future, but it's nice to have your solution when it comes to that. Thank you. By the way, while googling around I found out this problem appeared in the first release of Visual Studio .NET (version 7.0, a.k.a. 2002), it remained in VS2003, VS2005 and it's quite strange it's still present in the most recent VS2008, so many years later.
-- Vladimir Svrkota, CardWare Novi Sad, Serbia.
btw: do you know how to delete a method, property or event from an aciveX Projekt in VS200x ?? I can´t find a way to do it. At the moment it looks to me that i have to remove it manually with the problem that i have to renumber the odl indizes by hand argh (interrupted number order seems to cause problems) Best regards Stefan
-
btw: do you know how to delete a method, property or event from an aciveX Projekt in VS200x ?? I can´t find a way to do it. At the moment it looks to me that i have to remove it manually with the problem that i have to renumber the odl indizes by hand argh (interrupted number order seems to cause problems) Best regards Stefan
Stefan_L_01 wrote:
btw: do you know how to delete a method, property or event from an aciveX Projekt in VS200x ?? I can´t find a way to do it.
No, sorry.
-- Vladimir Svrkota, CardWare Novi Sad, Serbia.