TCHAR buffer = null; if ((style & SWT.H_SCROLL) != 0) { int length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0); if (length == OS.CB_ERR) { int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED); error (SWT.ERROR_INVALID_RANGE); } buffer = new TCHAR (getCodePage (), length + 1); int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer); if (result == OS.CB_ERR) { int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED); error (SWT.ERROR_INVALID_RANGE); } } int length = OS.GetWindowTextLength (handle); int code = OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0); if (code == OS.CB_ERR) { int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED); error (SWT.ERROR_INVALID_RANGE); } if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true); if (length != OS.GetWindowTextLength (handle)) { sendEvent (SWT.Modify); if (isDisposed ()) return; }  if ((style & SWT.READ_ONLY) != 0) { int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); if (count == 0) OS.InvalidateRect (handle, null, true); }
remove (index, true);
public void remove (int index) {	checkWidget ();	TCHAR buffer = null;	if ((style & SWT.H_SCROLL) != 0) {		int length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);		if (length == OS.CB_ERR) {			int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);			if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);			error (SWT.ERROR_INVALID_RANGE);		}		buffer = new TCHAR (getCodePage (), length + 1);		int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer);		if (result == OS.CB_ERR) {			int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);			if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);			error (SWT.ERROR_INVALID_RANGE);		}	}	int length = OS.GetWindowTextLength (handle);	int code = OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0);	if (code == OS.CB_ERR) {		int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);		if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);		error (SWT.ERROR_INVALID_RANGE);	}	if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);	if (length != OS.GetWindowTextLength (handle)) {		sendEvent (SWT.Modify);		if (isDisposed ()) return;	}	/*	* Bug in Windows.  When the combo box is read only	* with exactly one item that is currently selected	* and that item is removed, the combo box does not	* redraw to clear the text area.  The fix is to	* force a redraw.	*/	if ((style & SWT.READ_ONLY) != 0) {				int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);		if (count == 0) OS.InvalidateRect (handle, null, true);	}}