mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 12:50:52 +00:00
Added missing source file for placeholder tool strip text box
This commit is contained in:
parent
a5df323717
commit
54b99ee710
2 changed files with 80 additions and 0 deletions
|
@ -184,6 +184,9 @@
|
|||
<DependentUpon>ExternalCommandControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FolderSelectDialog.cs" />
|
||||
<Compile Include="Controls\PlaceholderToolStripTextBox.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\Scripting\TextEditorControl.cs" />
|
||||
<Compile Include="Controls\TransparentTrackBar.cs">
|
||||
<SubType>Component</SubType>
|
||||
|
|
77
Source/Core/Controls/PlaceholderToolStripTextBox.cs
Normal file
77
Source/Core/Controls/PlaceholderToolStripTextBox.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Controls
|
||||
{
|
||||
// This is based on https://stackoverflow.com/questions/50918225/how-to-add-placeholder-text-to-toolstriptextbox
|
||||
[ToolboxBitmap(typeof(ToolStripTextBox))]
|
||||
public class PlaceholderToolStripTextBox : ToolStripTextBox
|
||||
{
|
||||
#region ================== DLL Imports
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
private static extern int SendMessage(IntPtr hWnd, int msg, int wParam, string lParam);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constants
|
||||
|
||||
private const int EM_SETCUEBANNER = 0x1501;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
private string placeholder;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public string PlaceholderText
|
||||
{
|
||||
get { return placeholder; }
|
||||
set
|
||||
{
|
||||
placeholder = value;
|
||||
UpdatePlaceholderText();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructors
|
||||
|
||||
public PlaceholderToolStripTextBox()
|
||||
{
|
||||
Control.HandleCreated += Control_HandleCreated;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
private void Control_HandleCreated(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(placeholder))
|
||||
UpdatePlaceholderText();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
private void UpdatePlaceholderText()
|
||||
{
|
||||
SendMessage(Control.Handle, EM_SETCUEBANNER, 0, placeholder);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue