Home Dashboard Directory Help

CMFCTabCtrl bug by Gary Harper


 as Fixed Help for as Fixed

Sign in
to vote
Type: Bug
ID: 768378
Opened: 10/23/2012 4:22:01 AM
Access Restriction: Public
User(s) can reproduce this bug


I derived a class from CMFCTabCtrl and attempted to use it to receive the command message from a context menu. The command messages were not received. I went into the CMFCTabCtrl source code and noticed in the OnCommand method that it checks to see if the incoming command is from one of it's built in scroll buttons. It does this by comparing lParam to GetSafeHandle() of the buttons. However, this does not work because my tab control is not showing any scroll buttons so GetSafeHandle returns 0. Also, the WM_COMMAND message from my context menu has an lParam of 0. Since 0 equals 0, the CMFCTabCtrl logic incorrectly goes into the scroll button handler and returns without ever passing on the OnCommand message to the base class which does the correct routing.

Note: This occurred in VS 2010 but I don't see a way to report the bug for that version and I imagine the same bug still exists in VS 2012.
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:31 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Gary Harper on 7/1/2013 at 10:53 AM
I see that this fix made it into VS2013 Preview. Thank you. Can I get a free t-shirt or something? :)
Posted by Microsoft on 11/26/2012 at 2:47 PM
I apologize for the messy formatting of the previous message. I will follow up with our Connect to see why the formatting is being lost.
Posted by Microsoft on 11/26/2012 at 2:46 PM
Hello Gary,

Thanks for the report. We have investigated and found that this is a bug in MFC, which will be fixed for the next major release of Visual Studio.

Meanwhile, you can work around this issue with the following:

BOOL CMyTabCtrl::OnCommand(WPARAM wParam, LPARAM lParam)
                if (lParam == 0)
                                return CWnd::OnCommand(wParam, lParam);

                return CMFCTabCtrl::OnCommand(wParam, lParam);

Pat Brenner
Visual C++ Libraries Development
Posted by Gary Harper on 10/29/2012 at 3:27 AM
I don't think I need to provide any additional information or provide a sample project. All you have to do is look at the code in the OnCommand handler of the CMFCTabCtrl to see that it does not properly handle messages from menus in the cases I described.
Posted by Microsoft on 10/29/2012 at 3:16 AM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Microsoft on 10/24/2012 at 12:21 AM
Thanks for your feedback.

In order to fix the issue, we must first reproduce the issue in our labs. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project so that we can conduct further research?

Please submit this information to us within 3 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 10/23/2012 at 4:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by Gary Harper on 10/25/2012 at 4:30 AM
I figured out this workaround. A class can be derived from CMFCTabCtrl and the WM_COMMAND message can be handled. The following code in the OnCommand handler method will help:

if (lParam == 0)
return CMFCBaseTabCtrl::OnCommand(wParam, lParam);
return CMFCTabCtrl::OnCommand(wParam, lParam);