Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 [MFC]Refactor->Implement Virtual Methods

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
alextooter Posted - Sep 11 2013 : 12:25:39 AM
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.
5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 09 2013 : 2:03:30 PM
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.
alextooter Posted - Oct 09 2013 : 01:13:48 AM
It sounds good for me.
feline Posted - Oct 07 2013 : 10:53:20 PM
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.
alextooter Posted - Oct 07 2013 : 12:30:39 AM
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.
feline Posted - Sep 14 2013 : 11:06:53 AM
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.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000