protected virtual void LaunchDialog(int customIndex) { base.Invalidate(); this.colorUI.EditorService.CloseDropDown(); ColorEditor.CustomColorDialog dialog = new ColorEditor.CustomColorDialog(); IntPtr focus = System.Drawing.Design.UnsafeNativeMethods.GetFocus(); try { if (dialog.ShowDialog() != DialogResult.Cancel) { Color color = dialog.Color; this.customColors[customIndex] = dialog.Color; this.SelectedColor = this.customColors[customIndex]; this.OnPicked(EventArgs.Empty); } dialog.Dispose(); } finally { if (focus != IntPtr.Zero) { System.Drawing.Design.UnsafeNativeMethods.SetFocus(new HandleRef(null, focus)); } } }