int lastIndex = getLastIndexOfRow (index); if (lastIndex != -1 && index == lastIndex + 1) { REBARBANDINFO rbBand2 = new REBARBANDINFO (); rbBand2.cbSize = REBARBANDINFO.sizeof; rbBand2.fMask = OS.RBBIM_IDEALSIZE; OS.SendMessage (handle, OS.RB_GETBANDINFO, lastIndex, rbBand2); rbBand2.fMask = OS.RBBIM_SIZE; RECT rect = new RECT (); OS.SendMessage (handle, OS.RB_GETBANDBORDERS, lastIndex, rect); rbBand2.cx = rbBand2.cxIdeal + rect.left + rect.right; OS.SendMessage (handle, OS.RB_SETBANDINFO, lastIndex, rbBand2);
int lastIndex = getLastIndexOfRow (index - 1); if (index == lastIndex + 1) { resizeToPreferredWidth (lastIndex);
void createItem (CoolItem item, int index) {	int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);	if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);	int id = 0;	while (id < items.length && items [id] != null) id++;	if (id == items.length) {		CoolItem [] newItems = new CoolItem [items.length + 4];		System.arraycopy (items, 0, newItems, 0, items.length);		items = newItems;	}	int hHeap = OS.GetProcessHeap ();	int lpText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);	REBARBANDINFO rbBand = new REBARBANDINFO ();	rbBand.cbSize = REBARBANDINFO.sizeof;	rbBand.fMask = OS.RBBIM_TEXT | OS.RBBIM_STYLE | OS.RBBIM_ID;	rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS;	if ((item.style & SWT.DROP_DOWN) != 0) {		rbBand.fStyle |= OS.RBBS_USECHEVRON;	}	rbBand.lpText = lpText;	rbBand.wID = id;	/*	* Feature in Windows.  When inserting an item at end of a row,	* eventually, Windows will begin to place the item on the right	* side of the cool bar.  The fix is to resize the next to last	* item to the ideal size and resize the new items to the maximum	* size.	*/	int lastIndex = getLastIndexOfRow (index);	if (lastIndex != -1 && index == lastIndex + 1) {  			REBARBANDINFO rbBand2 = new REBARBANDINFO ();		rbBand2.cbSize = REBARBANDINFO.sizeof;		rbBand2.fMask = OS.RBBIM_IDEALSIZE;		OS.SendMessage (handle, OS.RB_GETBANDINFO, lastIndex, rbBand2);		rbBand2.fMask = OS.RBBIM_SIZE;		RECT rect = new RECT ();		OS.SendMessage (handle, OS.RB_GETBANDBORDERS, lastIndex, rect);		rbBand2.cx = rbBand2.cxIdeal + rect.left + rect.right;		OS.SendMessage (handle, OS.RB_SETBANDINFO, lastIndex, rbBand2);		rbBand.fMask |= OS.RBBIM_SIZE;		rbBand.cx = MAX_WIDTH; 	}	if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) == 0) {		error (SWT.ERROR_ITEM_NOT_ADDED);	}	OS.HeapFree (hHeap, 0, lpText);	items [item.id = id] = item;	int length = originalItems.length;	CoolItem [] newOriginals = new CoolItem [length + 1];	System.arraycopy (originalItems, 0, newOriginals, 0, index);	System.arraycopy (originalItems, index, newOriginals, index + 1, length - index);	newOriginals [index] = item;	originalItems = newOriginals;}