Files
mRemoteNG/mRemoteV1/UI/Controls/TextBoxExtensions.cs
2017-01-24 09:34:38 -07:00

24 lines
969 B
C#

using System;
using System.Text;
using System.Windows.Forms;
using mRemoteNG.App;
namespace mRemoteNG.UI.Controls
{
public static class TextBoxExtensions
{
public static bool SetCueBannerText(this TextBox textBox, string cueText, bool showCueWhenFocused = false)
{
if (!textBox.IsHandleCreated || cueText == null) return false;
var result = NativeMethods.SendMessage(textBox.Handle, NativeMethods.EM_SETCUEBANNER, (IntPtr) Convert.ToInt32(showCueWhenFocused), cueText);
return result.ToInt64() == NativeMethods.TRUE;
}
public static string GetCueBannerText(this TextBox textBox)
{
var cueBannerText = new StringBuilder(256);
var result = NativeMethods.SendMessage(textBox.Handle, NativeMethods.EM_GETCUEBANNER, cueBannerText, new IntPtr(cueBannerText.Capacity));
return result.ToInt64() != 0 ? cueBannerText.ToString() : null;
}
}
}