C#的textbox的自动滚屏
来源:互联网 发布:辐射4艾达王捏脸数据 编辑:程序博客网 时间:2024/05/17 07:53
在一个窗口中实现:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace AutomaticText
{
public partial class Form1 : Form
{
private int min, max;
private int pos = 0;
private int endPos = 0;
private const int SB_HORZ = 0x0;
private const int SB_VERT = 0x1;
private const int WM_HSCROLL = 0x114;
private const int WM_VSCROLL = 0x115;
private const int SB_THUMBPOSITION = 4;
[DllImport("user32.dll")]
private static extern int SetScrollPos(IntPtr hwnd, int nBar, int nPos, bool bRedraw);
[DllImport("user32.dll")]
private static extern int GetScrollPos(IntPtr hwnd, int nBar);
[DllImport("user32.dll")]
private static extern bool PostMessage(IntPtr hWnd, int nBar, int wParam, int lParam);
[DllImport("user32", CharSet = CharSet.Auto)]
private static extern bool GetScrollRange(IntPtr hWnd, int nBar, out int lpMinPos, out int lpMaxPos);
public Form1()
{
InitializeComponent();
}
private void rt_DoubleClick(object sender, EventArgs e)
{
timeAutoScroll.Interval = 100;
//得到滚动条的最大最小值
GetScrollRange(rt.Handle, SB_VERT, out min, out max);
//得到滚动条到最底下的实际位置
endPos = max - rt.ClientRectangle.Height;
this.timeAutoScroll.Enabled = true;
}
private void timeAutoScroll_Tick(object sender, EventArgs e)
{
pos = GetScrollPos(rt.Handle, SB_VERT);//加上这句是为了如果用户手动拖拽滚动条,可以保证滚动条继续从拖拽的位置走
pos++;
//如果已经到底,那么从头开始
if (pos > endPos)
{
pos = 0;
}
SetScrollPos(rt.Handle, SB_VERT, pos, true);
PostMessage(rt.Handle, WM_VSCROLL, SB_THUMBPOSITION + 0x10000 * pos, 0);
}
private void btn_okcancel_Click(object sender, EventArgs e)
{
if(txt_span .Text .Length !=0)
timeAutoScroll.Interval = Convert .ToInt32 (txt_span .Text .Trim ());
//得到滚动条的最大最小值
GetScrollRange(rt.Handle, SB_VERT, out min, out max);
//得到滚动条到最底下的实际位置
endPos = max - rt.ClientRectangle.Height;
this.timeAutoScroll.Enabled = true;
}
[DllImport("Dll.dll")]
private static extern void m();
//private static extern void Me();
private void btn_shezhi_Click(object sender, EventArgs e)
{
timeAutoScroll.Enabled = false;
}
}
}
//textbox左右滚动字幕
private void timer1_Tick(object sender, EventArgs e)
{
int i = strNum;
//不存在的话
if (message == null)
{
lab_scroll.Text = "";
return;
}
string messageStr = " " + message;
int leng = messageStr.Length;
if (leng >= 25 + i)
{
lab_scroll.Text = messageStr.Substring(i, 25);
}
else
{
if (leng > i)
{
lab_scroll.Text = messageStr.Substring(i, leng - i);
}
}
strNum++;
if (strNum > leng)
{
strNum = 0;
}
}
- C#的textbox的自动滚屏
- C#中文本阅读的自动滚屏的写法
- 自动高度的TextBox
- 自动滚屏的上下实现
- c#中WinForm的TextBox循环自动滚动示例
- c#中WinForm的TextBox循环自动滚动示例
- (转)c#中WinForm的TextBox循环自动滚动
- c#中WinForm的TextBox循环自动滚动示例
- TextBox编辑框间的自动跳转C#实现
- C# Textbox字符输入的时候自动转换成为大写
- 自动回滚的listview
- JavaScript实现网页的自动滚屏显示
- 一个流畅的拖动排序DragSortGridView,自动滚屏
- VC编辑框(EDIT)的自动换行、自动滚屏 、自动清空
- VC编辑框(EDIT)实现的自动换行、自动滚屏 、自动清空
- VC编辑框(EDIT)实现的自动换行、自动滚屏 、自动清空
- Spring自动回滚的事务管理配置
- 自动滚动轮播循环的ViewPager
- 开始玩iPad开发了(2)
- 影响研发效率的十大典型问题
- 我应时刻低调
- 在c语言中NULL的值为0
- Java读取xml类
- C#的textbox的自动滚屏
- 创建项目统一的连续增长ID
- code::blocks的基本配置
- C# 应用程序根目录
- C#里partial关键字的作用 (分布类)
- HDFS如何使用多个磁盘
- 使用VC开发软件框架
- SOJ 3427 Dark roads
- 10个你需要了解的项目管理工具