Skip to content

Instantly share code, notes, and snippets.

@MysteryDash
Created December 11, 2017 01:12
Show Gist options
  • Save MysteryDash/55423bbc434841caa66c0351cb655d21 to your computer and use it in GitHub Desktop.
Save MysteryDash/55423bbc434841caa66c0351cb655d21 to your computer and use it in GitHub Desktop.
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
class CueTextBox : TextBox
{
private string _cue;
[Localizable(true)]
public string Cue
{
get => _cue;
set
{
_cue = value;
UpdateCue();
}
}
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, string lp);
private void UpdateCue()
{
if (IsHandleCreated && _cue != null)
{
SendMessage(Handle, 0x1501, (IntPtr)1, _cue);
}
}
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
UpdateCue();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment