subject_x
subject_x

Reputation: 421

How do you make your MDI MFC app show one instance in the TaskBar?

I have an MDI app and when I click new document, it opens up a separate tab. This creates another instance of the icon in the taskbar within Windows. Is there any way I can change this behavior so that only one icon instance is shown the taskbar?

I know one way is to use SDI and use tabs for my views, but I want to keep it an MDI. Is this even possible.

I'm trying to mimic the view of this particular application called 'Dameware NT Utilities': http://www.dameware.com/v3-dameware/media/DameWare/DW%20NTU/Carousel/DRS-Primary-medium.png?width=490&height=276&ext=.png

Upvotes: 4

Views: 3016

Answers (2)

sergiol
sergiol

Reputation: 4335

I have an easier solution. On the app class InitInstance() method, just call

EnableTaskbarInteraction(FALSE);

before the main frame has been created. Then you will get one view per application instance when mouse does fly hover on its Taskbar icon, instead of one per sub-winodow.

Upvotes: 0

subject_x
subject_x

Reputation: 421

I found the solution after a day of digging around. Gosh, that feels good to finally figure this out. Anyway here is the solution.

I just had to override the childframe's CanShowOnTaskBarTabs() method to return FALSE. Here's the class method:

first, in the childframe.h file, put the following code in the class declaration

public:
     virtual BOOL CanShowOnTaskBarTabs() override;

Then in your childframe.cpp file, put the following code at the very bottom:

BOOL CChildFrame::CanShowOnTaskBarTabs()
{
    return FALSE;
}

Here's more information on the subject: http://msdn.microsoft.com/en-us/library/ee256255(v=vs.100).aspx

Upvotes: 6

Related Questions