8,834
社区成员
发帖
与我相关
我的任务
分享
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++)
{
sb.Append(string.Format("Index={0}\"!@#D!@E!@#@!X#!@#S!@S!@#!@#!@#S!@#!@#\"\r\n", i));
}
this.textBox1.Text = sb.ToString();
}
private void textBox1_MouseMove(object sender, MouseEventArgs e)
{
IntPtr lPResult = UnsafeNativeMethods.SendMessage(this.textBox1.Handle, NativeMethod.EM_GETFIRSTVISIBLELINE, IntPtr.Zero, IntPtr.Zero);
int lineNumber = lPResult.ToInt32();
this.Text = string.Format("FistVisibleLine:{0}", lineNumber);
}
}
[SuppressUnmanagedCodeSecurity]
internal static class UnsafeNativeMethods
{
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
}
internal static class NativeMethod
{
public const int EM_GETFIRSTVISIBLELINE = 0x00CE;
}