Original Post
Hey everyone, I'm creating a windows shell wrapper class in c++ using the Win32 API. I'm trying to make it so that creating a toolbar button takes a single line of code. Actually, the toolbar buttons are queued in a TBBUTTON array and then created all at once later with a function call. For a visual: The problem is, I want to dynamically allocate a TBBUTTON array instead of having a static one. I've tried using a pointer and the 'new' operator, and I've tried using vectors. Also tried this... And when I go to create the buttons later, nothing appears. Keep in mind, these are just snippets. I can post my current attempt at solving this problem if you want to see more code. I just want to know if there is a better way of doing this. I don't want to create a static TBBUTTON array because I want to just queue each toolbar button and resize the TBBUTTON array dynamically as I go along. As this is a windows shell, different applications will have different numbers of toolbar buttons, and I want to make creating new apps as easy as possible. If you can help me, thanks in advance. - Ryan
// Queue 3 toolbar buttons
Shell->QueueToolbarButton(...);
Shell->QueueToolbarButton(...);
Shell->QueueToolbarButton(...);
// Create them
Shell->CreateToolbarButtons();
TBBUTTON *tbb;
//...
tbb = new TBBUTTON[num_buttons];
// delete[] is called later, of course
vector<TBBUTTON> tbb;
//...
TBBUTTON tbbTemp;
/* tbbTemp is filled here */
tbb.reserve(num_buttons);
tbb.push_back(tbbTemp);