Getting Active CDocument's File Icon

Viewed 132

I have an MFC MDI application in which I need to use the active CDocument's file icon. I know that the icon ID is set when specifying the document template (it is the first parameter in the CMultiDocTemplate constructor), but having searched the documentation (and header files) for CDocument, CMultiDocTemplate and CDocTemplate I can find no way to retrieve the icon's ID. Unfortunately all are defined in afxwin.h, so the source code isn't accessible. CDocTemplate does have a protected member variable, m_nIDResource which I'm guessing is set to the resource ID passed to the constructor, but there is no accessor for this variable.

I could write a thin wrapper class for CMultiDocTemplate and provide an accessor for the icon ID, but I thought I'd ask first if anyone has found a way to get the file icon?

1 Answers

Creating a wrapper class for CMultiDocTemplate and adding an accessor for m_nIDResource worked well.

As CMDIChildWnd uses the active document's file icon for its frames, there must be some in-built way of getting the icon, but oh well, this is a pretty simple work-around.

Related