diff --git a/Documents/Help/Changelog.md b/Documents/Help/Changelog.md
index 3c7e192e1..8b236bd93 100644
--- a/Documents/Help/Changelog.md
+++ b/Documents/Help/Changelog.md
@@ -6,6 +6,8 @@
## 2022-11-xx - Build 2211 - November 2022
* Made enumeration `SchemeOfficeColors` public, so they can be used to make external themes
+* Resolved [#578](https://github.com/Krypton-Suite/Standard-Toolkit/issues/578), ComboBox Center no longer draws text centered
+* Resolved [#20](https://github.com/Krypton-Suite/Standard-Toolkit/issues/20), Selected text in ComboBox is drawn in a different font
* Resolved [#308](https://github.com/Krypton-Suite/Standard-Toolkit/issues/308), Panel AntiAlias Border Problem
* Resolved [#734](https://github.com/Krypton-Suite/Standard-Toolkit/issues/734), Disabled Text in NumericUpDown Not visible
* Resolved [#715](https://github.com/Krypton-Suite/Standard-Toolkit/issues/715), v65.22.4.94 - PaletteSparkleBlueBase.GetContentPadding: Specified argument was out of the range of valid values. Parameter name: style
diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs
index dc43312f9..071666744 100644
--- a/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs
+++ b/Source/Krypton Components/Krypton.Toolkit/Controls Toolkit/KryptonComboBox.cs
@@ -130,8 +130,9 @@ public InternalComboBox(KryptonComboBox kryptonComboBox)
// Remove from view until size for the first time by the Krypton control
ItemHeight = 15;
DropDownHeight = 200;
- DrawMode = DrawMode.OwnerDrawFixed; // DrawMode = DrawMode.OwnerDrawVariable;
- SetStyle(/*ControlStyles.UserPaint| */ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true);
+ //DrawMode = DrawMode.OwnerDrawFixed; // #20 fix, but this causes other problems; see #578
+ DrawMode = DrawMode.OwnerDrawVariable;
+ SetStyle(/*ControlStyles.UserPaint | */ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true);
}
#endregion
@@ -171,10 +172,7 @@ public bool MouseOver
///
/// Reset the app themed setting so it is retested when next required.
///
- public void ClearAppThemed()
- {
- _appThemed = null;
- }
+ public void ClearAppThemed() => _appThemed = null;
///
/// Gets the content short text.
@@ -388,56 +386,53 @@ protected override void WndProc(ref Message m)
_kryptonComboBox.CueHint.PerformPaint(_kryptonComboBox, g, rect, backBrush);
}
else
- //////////////////////////////////////////////////////
- // Following commented out, to allow the Draw to always happen even tho the edit box will draw over afterwards
- // Draw Over is tracked here
- // https://github.com/Krypton-Suite/Standard-Toolkit/issues/179
- // If not enabled or not the dropDown Style then we can draw over the text area
- //if (!_kryptonComboBox.Enabled || _kryptonComboBox.DropDownStyle != ComboBoxStyle.DropDown)
+ ////////////////////////////////////////////////////////
+ //// Following commented out, to allow the Draw to always happen even tho the edit box will draw over afterwards
+ //// Draw Over is tracked here
+ //// https://github.com/Krypton-Suite/Standard-Toolkit/issues/179
+ //// If not enabled or not the dropDown Style then we can draw over the text area
+ ////if (!_kryptonComboBox.Enabled || _kryptonComboBox.DropDownStyle != ComboBoxStyle.DropDown)
{
- // Set the correct text rendering hint for the text drawing. We only draw if the edit text is disabled so we
- // just always grab the disable state value. Without this line the wrong hint can occur because it inherits
- // it from the device context. Resulting in blurred text.
g.TextRenderingHint = CommonHelper.PaletteTextHintToRenderingHint(states.Content.GetContentShortTextHint(state));
- // Define the string formatting requirements
- StringFormat stringFormat = new()
- {
- LineAlignment = StringAlignment.Near,
- FormatFlags = StringFormatFlags.NoWrap,
- Trimming = StringTrimming.None,
- // Use the correct prefix setting
- HotkeyPrefix = HotkeyPrefix.None
- };
-
- stringFormat.Alignment = states.Content.GetContentShortTextH(state) switch
- {
- PaletteRelativeAlign.Near => RightToLeft == RightToLeft.Yes
- ? StringAlignment.Far
- : StringAlignment.Near,
- PaletteRelativeAlign.Far => RightToLeft == RightToLeft.Yes
- ? StringAlignment.Near
- : StringAlignment.Far,
- PaletteRelativeAlign.Center => StringAlignment.Center,
- _ => stringFormat.Alignment
- };
-
- // Draw using a solid brush
- Rectangle rectangle = new(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
- rectangle = CommonHelper.ApplyPadding(VisualOrientation.Top, rectangle,
- states.Content.GetContentPadding(state));
+ TextFormatFlags flags = TextFormatFlags.TextBoxControl | TextFormatFlags.NoPadding | TextFormatFlags.VerticalCenter;
+
+ // Use the correct prefix setting
+ flags |= TextFormatFlags.NoPrefix;
- try
+ // Do we need to switch drawing direction?
+ if (RightToLeft == RightToLeft.Yes)
{
- //string label = this.Items[e.Index].ToString();
- using SolidBrush foreBrush = new(states.Content.GetContentShortTextColor1(state));
- g.DrawString(displayText, states.Content.GetContentShortTextFont(state), foreBrush, rectangle, stringFormat);
+ flags |= TextFormatFlags.RightToLeft;
}
- catch (ArgumentException)
+
+ switch (states.Content.GetContentShortTextH(state))
{
- using SolidBrush foreBrush = new(ForeColor);
- g.DrawString(displayText, Font, foreBrush, rectangle, stringFormat);
+ case PaletteRelativeAlign.Near:
+ flags |= TextFormatFlags.Left;
+ break;
+ case PaletteRelativeAlign.Center:
+ flags |= TextFormatFlags.HorizontalCenter;
+ break;
+ case PaletteRelativeAlign.Far:
+ flags |= TextFormatFlags.Right;
+ break;
}
+
+ // Draw text using font defined by the control
+ Rectangle rectangle = new(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+ rectangle = CommonHelper.ApplyPadding(VisualOrientation.Top, rectangle, states.Content.GetContentPadding(state));
+ // Find correct text color
+ Color textColor = states.Content.GetContentShortTextColor1(state);
+ Font contentShortTextFont = states.Content.GetContentShortTextFont(state);
+ // Find correct background color
+ Color backColor = states.PaletteBack.GetBackColor1(state);
+
+ TextRenderer.DrawText(g,
+ Text, contentShortTextFont,
+ rectangle,
+ textColor, backColor,
+ flags);
}
// Remove clipping settings
@@ -672,8 +667,8 @@ public bool Visible
IntPtr.Zero,
0, 0, 0, 0,
PI.SWP_.NOMOVE | PI.SWP_.NOSIZE |
- (value ? PI.SWP_.SHOWWINDOW : PI.SWP_.HIDEWINDOW)
- );
+ (value ? PI.SWP_.SHOWWINDOW : PI.SWP_.HIDEWINDOW)
+ );
}
#endregion
@@ -1277,6 +1272,8 @@ public bool IsInitializing
/// Gets or sets the draw mode of the combobox.
/// The draw mode of the combobox.
[Description(@"Gets or sets the draw mode of the combobox.")]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public DrawMode DrawMode
{
get => _comboBox.DrawMode;
@@ -2666,7 +2663,15 @@ private void AttachEditControl()
// If we found a child then it is the edit class
if (childPtr != IntPtr.Zero)
{
+ if (this.DropDownStyle == ComboBoxStyle.Simple)
+ {
+ //this.childListBox = new ComboBox.ComboBoxChildNativeWindow(this, ComboBox.ChildWindowType.ListBox);
+ //this.childListBox.AssignHandle(window);
+ childPtr = PI.GetWindow(childPtr, PI.GetWindowType.GW_HWNDNEXT);
+ }
_subclassEdit = new SubclassEdit(childPtr, this);
+ // Following will have been done by Framework
+ //PI.SendMessage(childPtr, PI.WM_.EM_SETMARGINS, new IntPtr(3), IntPtr.Zero);
_subclassEdit.TrackMouseEnter += OnComboBoxMouseChange;
_subclassEdit.TrackMouseLeave += OnComboBoxMouseChange;
}
@@ -2723,6 +2728,7 @@ private void OnComboBoxDrawItem(object sender, DrawItemEventArgs e)
// Do we need to draw the edit area
if ((e.State & DrawItemState.ComboBoxEdit) == DrawItemState.ComboBoxEdit)
{
+ // TODO: Check if this is covered by the WM_PAINT in the internal Combo
// Always get base implementation to draw the background
e.DrawBackground();
@@ -2926,7 +2932,13 @@ private void OnComboBoxGotFocus(object sender, EventArgs e)
{
if (DropDownStyle == ComboBoxStyle.DropDown)
{
- //_subclassEdit.Visible = true;
+ _subclassEdit.Visible = true;
+ PaletteState state = Enabled
+ ? IsActive
+ ? PaletteState.Tracking
+ : PaletteState.Normal
+ : PaletteState.Disabled;
+ _comboBox.Font = GetComboBoxTripleState().Content.GetContentShortTextFont(state);
}
base.OnGotFocus(e);
@@ -2938,7 +2950,8 @@ private void OnComboBoxLostFocus(object sender, EventArgs e)
{
if (DropDownStyle == ComboBoxStyle.DropDown)
{
- //_subclassEdit.Visible = false;
+ _subclassEdit.Visible = false;
+ _comboBox.Font = GetComboBoxTripleState().Content.GetContentShortTextFont(PaletteState.Normal);
}
// ReSharper disable RedundantBaseQualifier
diff --git a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs
index 5d6ec7cce..510554c73 100644
--- a/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs
+++ b/Source/Krypton Components/Krypton.Toolkit/Controls Visuals/VisualControlBase.cs
@@ -525,6 +525,8 @@ public void UnattachGlobalEvents()
///
/// Gets and sets the ViewManager instance.
///
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public ViewManager ViewManager
{
[DebuggerStepThrough]
diff --git a/Source/Krypton Components/TestForm/Form1.Designer.cs b/Source/Krypton Components/TestForm/Form1.Designer.cs
index c4290e91b..f7a079590 100644
--- a/Source/Krypton Components/TestForm/Form1.Designer.cs
+++ b/Source/Krypton Components/TestForm/Form1.Designer.cs
@@ -29,21 +29,98 @@ protected override void Dispose(bool disposing)
private void InitializeComponent()
{
this.kryptonPanel1 = new Krypton.Toolkit.KryptonPanel();
+ this.label1 = new System.Windows.Forms.Label();
+ this.comboBox1 = new System.Windows.Forms.ComboBox();
+ this.kryptonComboBox3 = new Krypton.Toolkit.KryptonComboBox();
+ this.kryptonComboBox2 = new Krypton.Toolkit.KryptonComboBox();
+ this.kryptonButton1 = new Krypton.Toolkit.KryptonButton();
+ this.kryptonComboBox1 = new Krypton.Toolkit.KryptonComboBox();
((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).BeginInit();
+ this.kryptonPanel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox3)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox2)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox1)).BeginInit();
this.SuspendLayout();
//
// kryptonPanel1
//
+ this.kryptonPanel1.Controls.Add(this.label1);
+ this.kryptonPanel1.Controls.Add(this.comboBox1);
+ this.kryptonPanel1.Controls.Add(this.kryptonComboBox3);
+ this.kryptonPanel1.Controls.Add(this.kryptonComboBox2);
+ this.kryptonPanel1.Controls.Add(this.kryptonButton1);
+ this.kryptonPanel1.Controls.Add(this.kryptonComboBox1);
this.kryptonPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.kryptonPanel1.Location = new System.Drawing.Point(0, 0);
this.kryptonPanel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.kryptonPanel1.Name = "kryptonPanel1";
this.kryptonPanel1.Size = new System.Drawing.Size(800, 450);
- this.kryptonPanel1.StateCommon.Color1 = System.Drawing.Color.Black;
- this.kryptonPanel1.StateCommon.Color2 = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
- this.kryptonPanel1.StateCommon.ColorStyle = Krypton.Toolkit.PaletteColorStyle.Rounded;
this.kryptonPanel1.TabIndex = 0;
//
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(361, 37);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(161, 20);
+ this.label1.TabIndex = 5;
+ this.label1.Text = "Winform ComboBox \\/";
+ //
+ // comboBox1
+ //
+ this.comboBox1.Font = new System.Drawing.Font("Segoe Script", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.comboBox1.FormattingEnabled = true;
+ this.comboBox1.Location = new System.Drawing.Point(358, 66);
+ this.comboBox1.Name = "comboBox1";
+ this.comboBox1.Size = new System.Drawing.Size(215, 31);
+ this.comboBox1.TabIndex = 4;
+ this.comboBox1.Text = "33333333333333";
+ //
+ // kryptonComboBox3
+ //
+ this.kryptonComboBox3.CornerRoundingRadius = -1F;
+ this.kryptonComboBox3.DropDownWidth = 215;
+ this.kryptonComboBox3.IntegralHeight = false;
+ this.kryptonComboBox3.Location = new System.Drawing.Point(76, 66);
+ this.kryptonComboBox3.Name = "kryptonComboBox3";
+ this.kryptonComboBox3.Size = new System.Drawing.Size(215, 25);
+ this.kryptonComboBox3.TabIndex = 3;
+ this.kryptonComboBox3.Text = "33333333333333333";
+ //
+ // kryptonComboBox2
+ //
+ this.kryptonComboBox2.CornerRoundingRadius = -1F;
+ this.kryptonComboBox2.DropDownWidth = 215;
+ this.kryptonComboBox2.IntegralHeight = false;
+ this.kryptonComboBox2.Location = new System.Drawing.Point(76, 27);
+ this.kryptonComboBox2.Name = "kryptonComboBox2";
+ this.kryptonComboBox2.Size = new System.Drawing.Size(215, 29);
+ this.kryptonComboBox2.StateCommon.ComboBox.Content.Font = new System.Drawing.Font("Segoe Script", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.kryptonComboBox2.TabIndex = 2;
+ this.kryptonComboBox2.Text = "33333333333333";
+ //
+ // kryptonButton1
+ //
+ this.kryptonButton1.CornerRoundingRadius = -1F;
+ this.kryptonButton1.Location = new System.Drawing.Point(86, 204);
+ this.kryptonButton1.Name = "kryptonButton1";
+ this.kryptonButton1.Size = new System.Drawing.Size(90, 25);
+ this.kryptonButton1.TabIndex = 1;
+ this.kryptonButton1.Values.Text = "kryptonButton1";
+ //
+ // kryptonComboBox1
+ //
+ this.kryptonComboBox1.CornerRoundingRadius = -1F;
+ this.kryptonComboBox1.DropDownWidth = 215;
+ this.kryptonComboBox1.IntegralHeight = false;
+ this.kryptonComboBox1.Location = new System.Drawing.Point(76, 104);
+ this.kryptonComboBox1.Name = "kryptonComboBox1";
+ this.kryptonComboBox1.Size = new System.Drawing.Size(215, 25);
+ this.kryptonComboBox1.StateCommon.ComboBox.Content.TextH = Krypton.Toolkit.PaletteRelativeAlign.Center;
+ this.kryptonComboBox1.TabIndex = 0;
+ this.kryptonComboBox1.Text = "Center";
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@@ -55,6 +132,11 @@ private void InitializeComponent()
this.PaletteMode = Krypton.Toolkit.PaletteMode.Office2007BlackDarkMode;
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.kryptonPanel1)).EndInit();
+ this.kryptonPanel1.ResumeLayout(false);
+ this.kryptonPanel1.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox3)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox2)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.kryptonComboBox1)).EndInit();
this.ResumeLayout(false);
}
@@ -62,5 +144,11 @@ private void InitializeComponent()
#endregion
private Krypton.Toolkit.KryptonPanel kryptonPanel1;
+ private Krypton.Toolkit.KryptonComboBox kryptonComboBox1;
+ private Krypton.Toolkit.KryptonButton kryptonButton1;
+ private Krypton.Toolkit.KryptonComboBox kryptonComboBox3;
+ private Krypton.Toolkit.KryptonComboBox kryptonComboBox2;
+ private System.Windows.Forms.ComboBox comboBox1;
+ private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file