Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 ActiveX refactoring
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jlbooth318
Junior Member

17 Posts

Posted - Feb 14 2008 :  12:37:15 PM  Show Profile  Reply with Quote
Visual Assist really takes out a lot of the grunt work involved with refactoring code and fills in a lot of missing features in the Visual Studio IDE. We develop several MFC based ActiveX controls for our software products. One thing that is so cumbersome that VAX might be able to help us with, is refactoring ActiveX control events, methods, and properties.

Like say you have an method in an ActiveX control and want to add another parameter, you have to change the function signature in the .idl file, then change the function declaration in the control's class .h file, then modify the control's method map in the .cpp file(there are some pretty arcane macros involved in this part). This whole process can be quite error prone and can be hard to track down if things aren't done exactly right.

Sure, we could delete the existing function, the re-add the function using the IDE wizard, but all the previously mentioned items that need editing, would have to be deleted first.

Visual Studio does a pretty good job when it comes to adding new methods, properties, and events to ActiveX projects, but does not make it easy when things need to be changed.

So what I'm suggesting is the ability to hover over a function description/declaration in the project .idl file, then using VAX to change the signature there, and VAX can handle the rest of the changes from there.

-J. Booth, Software Engineer
Origin Technologies Corporation
http://www.origintech.com

feline
Whole Tomato Software

United Kingdom
19166 Posts

Posted - Feb 15 2008 :  09:58:50 AM  Show Profile  Reply with Quote
If you run Find References on the function, is VA able to find all of the references?

I am wondering how much of this VA already understands.

zen is the art of being at one with the two'ness
Go to Top of Page

jlbooth318
Junior Member

17 Posts

Posted - Feb 19 2008 :  1:45:54 PM  Show Profile  Reply with Quote
Find References, when run from the idl file, only finds the references in just that one file. If I do a find references from the .h file, it will find the references in the .h and .cpp, but not the idl file.

The real cumbersome part is the tweaks that have to be made in the component .cpp file dispatch map and/or the event map. This involves specifying a list of type modifiers representing the types for each parameter for a method (aka in cpp speak "function"). Like:

BSTR GetGaugeConfig(SHORT index);

the method map entry would be:
DISP_FUNCTION_ID(CLGGaugesCtrl, "GetGaugeConfig", dispidGetGaugeConfig, GetGaugeConfig, VT_BSTR, VTS_I2)


Now if I want to change that method signature to take 2 shorts:
BSTR GetGaugeConfig(SHORT index,SHORT parameter);

The dispatch map would have to be tweaked to:
DISP_FUNCTION_ID(CLGGaugesCtrl, "GetGaugeConfig", dispidGetGaugeConfig, GetGaugeConfig, VT_BSTR, VTS_I2 VTS_I2)

Also, the idl file would have to be updated, the .h file would have to be updated with the new function declaration and the function body itself in the .cpp would have to be changed to the new signature.

I'm not sure if all this could be done via VAX, it almost seems like a whole new VS add-in with functionality similar to the add method/add property/add event wizards provided in the IDE.

Incidentally, I use VS2003. I wonder if these wizards are any better in VS2005/2008?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19166 Posts

Posted - Feb 20 2008 :  08:47:48 AM  Show Profile  Reply with Quote
This does look rather complex.

If you use the IDE's find in files, does it correctly search through the IDL files?

I am wondering if using the IDE is a reasonable way forward here. In this case use the IDE wizard to add a new function:

BSTR GetGaugeConfig2(SHORT index, SHORT parameter);

Use VA Outline to make sure the cpp and header files are ordered how you want, so GetGaugeConfig2 is positioned next to GetGaugeConfig

Now just move the body from GetGaugeConfig into GetGaugeConfig2, which can be done in a couple of different ways.

As a final step use Find and Replaces in files to replace all instances of GetGaugeConfig2 with GetGaugeConfig

I am aware this is somewhat labour intensive, but it should be a lot quicker, more accurate and easier than making the change by hand. At this point VA's Find References should help you find the other code references that you need to update with the new parameter.

zen is the art of being at one with the two'ness
Go to Top of Page

jlbooth318
Junior Member

17 Posts

Posted - Feb 20 2008 :  09:21:06 AM  Show Profile  Reply with Quote
Yeah, that does sound like a better/easier way to get the job done. VAX Find references works quite well within the source .cpp and .h files. It's not that often we have to change function prototypes. But your suggestion might be a bit easier than doing the tweaks by hand. The changes are always in our internal development code that hasn't been released to any of our customers.

Come to think of it, we really can't change function prototypes on methods inside controls that are in production software. There's always that big what if a new control with changed parameters winds up alongside an old version of the software which expects the old function prototypes. That's just asking/begging for trouble.

Thanks for your suggestion. Sometimes it's all in how you use the tools you already have.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000