c#之上下滚动播放
来源:互联网 发布:最新营销软件 编辑:程序博客网 时间:2024/05/10 15:30
一、功能需求
添加曾经对于XXX系统作出贡献的人和合作伙伴,要求动态播放。
二、实现步骤
1,新增textBox并修改属性
主要修改点如下:
multiline 修改为true --可以跨行
scrollBars 修改为 Both--显示滚动条
2,新增timer
3,添加代码和方法
在初始化窗体处添加如下代码:
this.timer1.Interval = 1000;//播放速度
this.timer1.Enabled = true;
this.timer1.Start();
双击timer1控件新增timer1_Tick方法,代码如下
// 发送消息
[DllImport("user32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);
// 获取滚动条位置
[DllImport("user32.dll")]
public static extern int GetScrollPos(IntPtr hWnd, int nBar);
// 设置滚动条位置
[DllImport("user32.dll")]
static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw);
public const int EM_LINESCROLL = 0xb6;
private void timer1_Tick(object sender, EventArgs e)
{
//this.txtInfo.Top -= 5;
//txtInfo.SelectionStart = txtInfo.Text.Length;
//txtInfo.ScrollToCaret();
int i = GetScrollPos(this.txtInfo.Handle, 1);
// 向下滚动一行
SendMessage(this.txtInfo.Handle, EM_LINESCROLL, 0, 1); // 0,1代表垂直滚动条向下滚动
// 判断是否有位置变化,如果没有则说明到了底部,返回开始处
if (i == GetScrollPos(this.txtInfo.Handle, 1))
{
// 回到顶部,这里用SetScrollPos似乎有问题,滚动条和文字不是同步更新
this.txtInfo.SelectionStart = 0;
this.txtInfo.SelectionLength = 1;
this.txtInfo.ScrollToCaret();
this.txtInfo.SelectionLength = 0;
}
Console.WriteLine(i);
}
阅读全文
1 0
- c#之上下滚动播放
- css3动画之上下抖动
- .Net下C#播放WAV,WAVE文件
- android实现滚动播放
- iOS 图片滚动播放
- TextView实现滚动播放
- 列表自动滚动播放
- 横向图片滚动播放
- ListView 滚动播放
- 图片滚动播放
- 图片无缝滚动播放
- 纯CSS3动画之上下翻转
- c# textBox滚动条一直在最下
- C#中WPF下自定义滚动条ScrollViewer样式
- OpenCv播放视频并滚动条滚动
- C#自动播放下一首歌曲(windowsmediaPlayer)
- Ajax实现新闻滚动播放
- android_背景大图滚动播放
- 二叉树的基本操作(总结)
- 【2】在Ubuntu上为Android系统内置C可执行程序测试Linux内核驱动程序
- noip2017(AFO)游记
- leetcode 233. Number of Digit One
- Samba服务器搭建(Linux)
- c#之上下滚动播放
- 【我的Java笔记】异常类
- 【Unity学习笔记】关于在Unity中build apk error
- ubuntu17.10笔记本待机后无法唤醒的解决方案
- Dubbo服务降级
- C++继承知识点滴
- SQLServer输出字段说明注释
- java加解密之RSA使用
- cocos2dx 获取手机屏幕分辨率 objective-c android 和 Lua 交互 向lua 传参