0

In my MFC MDI application I have 10 CMFCToolBar and each has separate imagelist(bitmap images).

I implemented task pane using CMFCTaskPane in which I am grouping same tasks or activities what the CMFCToolbar is doing.

Can I use/assign each CMFCToolbar image list to the tasks coming under each group?

In CMFCTaskPane class I only have these methods:

  • BOOL SetIconList(HIMAGELIST hIcons)
  • BOOL SetIconsList(UINT uiImageListResID, int cx, COLORREF clrTransparent = RGB(255, 0, 255))

In CMFCTaskPane class we have an option to assign only one image list to the entire taskpane. There is no option to assign separate imagelist to each group and its tasks.

But I have 10 CMFCToolbar and 10 CImageList. How to use my toolbar images to achieve my requirement?

In this link https://www.codeproject.com/Articles/16529/Simple-Menus-That-Display-Icons-Minimalistic-Appro?msg=1895336

the toolbar images are used in the menu by overriding DrawItem() function similarly can we draw icon for a task by overriding the function

virtual void OnDrawTasks(CDC* pDC, CRect rectWorkArea); in the CMFCTaskPane.

I dont have any idea on how to do it?

1 Answers1

1

When you call LoadToolbar, you create local instance of imagelist for this toolbar. By default, all toolbars in application shares same imagelist. So, just make something like this:

CMFCToolbar m_toolbar;
...
m_toolbar.Create(this, AFX_DEFAULT_TOOLBAR_STYLE;);
int newIconID = CMFCToolBar::GetImages()->AddIcon(hIcon, TRUE);
m_toolbar.InsertButton(cmd, newIconID, name);
Shmap
  • 11
  • 1