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
 [MFC]Refactor->Implement Virtual Methods
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

alextooter
Ketchup Master

55 Posts

Posted - Sep 11 2013 :  12:25:39 AM  Show Profile  Reply with Quote
Hi,

When use VAX's refactor->implement virtual methods to add a virtual function in MFC, it forget to call the default Constructor,

like this:

BOOL myDialog::OnInitDialog()
{
CDialogEx::OnInitDialog();//VAX doesn't add this line.

// TODO: Add you code here

return TRUE; // return TRUE unless you set the focus to a control

}

Can VAX aware this is a MFC project,and add this line to generated function, provide the same feature as Class Wizard.

Edited by - alextooter on Sep 11 2013 12:26:44 AM

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Sep 14 2013 :  11:06:53 AM  Show Profile  Reply with Quote
Currently Implement Virtual Methods does not call the base method in any of the generated functions. There are going to be quite a few places where calling the base method is important, like here, but I am not sure how VA can know when it should call the base method.

I don't want to start hard coding special cases if we can avoid it. Do you have any thoughts on a general, easy to use, solution here?

I am wondering about marking the functions that should call the base class in the Implement Methods dialog, but we would need to do this in a simple and easy to use manor... two check boxes per line is not really what we want to be doing.

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

alextooter
Ketchup Master

55 Posts

Posted - Oct 07 2013 :  12:30:39 AM  Show Profile  Reply with Quote
I don't have any good solution here.

Two not perfect ideas:
1, provide option in setting, user can select call base method in generated functions. This is not good, may impact user's code.
2, call base method, but comment it with //, if user want to use, just remove //. Let user decide what to use.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Oct 07 2013 :  10:53:20 PM  Show Profile  Reply with Quote
Calling the case method is a sensible request, but we only want to do it some of the time. So method 1, doing this directly, is probably going to cause more problems than it solves.

Method 2, if a VA Snippet was added to control the body of the generated methods then this would allow the comment to be created, but this would add a comment to every single method generated, which might be excessive, certainly distracting if this is not actually wanted.

How about a new refactoring command to call the base method? You would need to trigger this on the generated OnInitDialog() function, after it was created, but this would be a lot quicker and simpler than typing the function call manually.

This is not as fast or simple as having VA add this call directly, but it avoids all of the problems of unwanted calls being inserted.

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

alextooter
Ketchup Master

55 Posts

Posted - Oct 09 2013 :  01:13:48 AM  Show Profile  Reply with Quote
It sounds good for me.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Oct 09 2013 :  2:03:30 PM  Show Profile  Reply with Quote
Interesting and good news, we can do this already in VA 2001 with VA Snippets. If you create a new snippet with the code:

$BaseClassName$::$MethodName$( $MethodArgs$ );

and then trigger it inside the derived function body, the correct call is inserted. I created this with the shortcut "call", which seemed appropriate.

zen is the art of being at one with the two'ness
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