c++ - Final toolbar item icon not showing -


i wrapping win32 toolbar. works except whenever user of wrapper class adds separator, last toolbar item's icon not show.

consider client code:

    toolbarbtn tbb[] = { toolbarbtn { id_file_new, idi_new },                             toolbarbtn { id_file_open, idi_open },                             sep { },                             toolbarbtn { id_file_saveas, idi_save },                             toolbarbtn { id_file_print, idi_print },                             sep { },                             toolbarbtn { id_edit_undo, idi_undo },                             toolbarbtn { id_edit_redo, idi_redo } };  this->tb = toolbar { *this, tbb, sizeof tbb / sizeof *tbb }; 

the toolbarbtn objects represent toolbar button. sep object separator, , inherits class toolbarbtn. following statement calls constructor of toolbar class, creating it. code, graphics output:

enter image description here

as can see hover, final 2 buttons exist! reason icon not show, , order changed of icons. should "new", "open", [separator], "save", "print", [separator], "undo", , "redo". "save as" , "redo" not show. , know icon not problem, because can put sequence of toolbarbtns, long there sep object, last icon never displays.

here implementing of relevant functions/methods:

toolbarbtn::toolbarbtn(int id, icon ico, byte state, byte style) {     zeromemory(this, sizeof *this);     this->ico = ico;     this->tbb.idcommand = id;     this->tbb.fsstate = state;     this->tbb.fsstyle = style;     this->tbb.ibitmap = 0;  // field changed toolbar c'tor }  // count # of buttons; no separators counted size_t nactualbuttons(const toolbarbtn btns[], size_t n) {     size_t n1 = n;     (size_t = 0; < n; ++i)         if (btns[i].gettbb().fsstyle & tbstyle_sep)             --n1;     return n1; } toolbar::toolbar(overlappedwindow parent, const toolbarbtn btns[], size_t n,                   int id) {     this->hwnd = createwindow(toolbarclassname, null,          ws_child | ws_visible | tbstyle_flat, 0, 0, 0, 0,         parent.gethwnd(), (hmenu) id, getmodulehandle(null), null);     if (this->hwnd == null)         message(l"%s: %s", __functionw__, geterror());      // send tb_buttonstructsize message, required     // backward compatibility.     sendmessage(this->hwnd, tb_buttonstructsize, sizeof(tbbutton), 0);      himagelist imglist = imagelist_create(16, 16, ilc_color32, n, 0);     if (!imglist)         message(l"%s: %s", __functionw__, geterror());      (size_t = 0; < n; ++i) {         if (btns[i].gettbb().fsstyle & tbstyle_sep)             continue;     // dont add separators image list         if (imagelist_addicon(imglist, btns[i].geticon().gethandle()) == -1)             message(l"%s: %s", __functionw__, geterror());     }      sendmessage(this->hwnd, tb_setimagelist, (wparam) 0, (lparam) imglist);      tbbutton *tbb = (tbbutton *) calloc(n, sizeof (tbbutton));     (size_t = 0; < n; ++i) {         tbb[i] = btns[i].gettbb();         tbb[i].ibitmap = (tbb[i].fsstyle & tbstyle_sep) ? 0 : i;         if (tbb[i].fsstyle & tbstyle_sep)             tbb[i].idcommand = 0;     }     sendmessage(this->hwnd, tb_addbuttons, n, (lparam) tbb);     free(tbb); } 

i think problem may this:

sep { }, 

your doing this:

sep {0, 0, 0, 0} 

so separator not have tbstyle_sep set. should initialize separator this:

sep {0, 0, 0, tbstyle_sep} 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -