On 2011-04-17 11:46, Stefan Küng wrote:
On 17.04.2011 09:30, Oto BREZINA wrote:
On 2011-04-05 20:03, Stefan Küng wrote:

2. Is there plan to support icons there? let say, same like in main
menu? not worth much but nice :)
Good idea.
I look at code it seems be possible without owner draw to keep string.
(ref: http://www.codeguru.com/forum/archive/index.php/t-101074.html)
However I don't know how to extract one bitmap from toolbar ...
Do we need set new resource?
To get the icon for a specific command from the toolbar, something like 
this might work:

HICON GetIconForCommand() {
CToolbar bar;
if (bar.LoadToolBar(IDR_MAINFRAME))
   int offset = bar.CommandToIndex(cmdId);
   CImageList imgList;
   imgList.Attach(SendMessage(bar.GetSafeHwnd(), TB_GETIMAGELIST, 0, 0));
   HICON h=imgList.ExtractIcon(offset);
   return h;
return 0;
If a handle is returned, use that for the AppendMenuIcon() method. 
Otherwise (if 0 is returned) you can use a custom icon.
I tried this and some other aproach as well. In best case I was able to get some handle, but it wont display icon on popup menu. However when I use some bitmap/icon from resource it works.

Oto BREZINA, Printflow s.r.o., EU
+421 903 653470 skype: ot_ik_