C#中用Form实现浮动工具栏(转)_
来源:互联网 发布:ubuntu开机运行脚本 编辑:程序博客网 时间:2024/05/07 09:48
今天才发觉微软XX的在.net 2003里边没给提供浮动工具栏控件,没办法google了一下只找到几个第三方的控件,要付费不过功能倒是挺强悍。考虑一下偶只是需要一个简单的浮动条,不至于用到那些太多的牛x功能,自己动手丰衣足食吧!
基本思路,用一个无text,ControlBox=false的窗体,设置其top属性为true作为该工具条的载体
在窗体MouseDown,MouseMove,MouseUp事件中处理工具条的移动
代码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace SmartBoard
{
/// <summary>
/// Form1
{
/// <summary>
/// Form1
/// </summary>
public class NPButton : System.Windows.Forms.Form
{
protected SmartBoard ParentFrom = null;
private int mouseX,mouseY,currX,currY;
public System.Windows.Forms.Button button3;
public System.Windows.Forms.Button button2;
/// <summary>
///
public class NPButton : System.Windows.Forms.Form
{
protected SmartBoard ParentFrom = null;
private int mouseX,mouseY,currX,currY;
public System.Windows.Forms.Button button3;
public System.Windows.Forms.Button button2;
/// <summary>
///
/// </summary>
private System.ComponentModel.Container components = null;
private System.ComponentModel.Container components = null;
public NPButton(SmartBoard parent)
{
//
// Windows
{
//
// Windows
//
InitializeComponent();
this.ParentFrom = parent;
//
// TODO: InitializeComponent
InitializeComponent();
this.ParentFrom = parent;
//
// TODO: InitializeComponent
//
}
}
/// <summary>
///
///
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows
/// <summary>
///
///
///
/// </summary>
private void InitializeComponent()
{
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button3
//
this.button3.BackColor = System.Drawing.Color.LightGray;
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button3.ForeColor = System.Drawing.Color.Black;
this.button3.Location = new System.Drawing.Point(55, 5);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(50, 18);
this.button3.TabIndex = 1;
this.button3.Text = ">";
//
// button2
//
this.button2.BackColor = System.Drawing.Color.LightGray;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.ForeColor = System.Drawing.Color.Black;
this.button2.Location = new System.Drawing.Point(5, 5);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(50, 18);
this.button2.TabIndex = 0;
this.button2.Text = "<";
//
// NPButton
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(110, 30);
this.ControlBox = false;
this.Controls.Add(this.button2);
this.Controls.Add(this.button3);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "NPButton";
this.ShowInTaskbar = false;
this.TopMost = true;
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NPButton_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.NPButton_MouseUp);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.NPButton_MouseMove);
this.ResumeLayout(false);
/// </summary>
private void InitializeComponent()
{
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button3
//
this.button3.BackColor = System.Drawing.Color.LightGray;
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button3.ForeColor = System.Drawing.Color.Black;
this.button3.Location = new System.Drawing.Point(55, 5);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(50, 18);
this.button3.TabIndex = 1;
this.button3.Text = ">";
//
// button2
//
this.button2.BackColor = System.Drawing.Color.LightGray;
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button2.ForeColor = System.Drawing.Color.Black;
this.button2.Location = new System.Drawing.Point(5, 5);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(50, 18);
this.button2.TabIndex = 0;
this.button2.Text = "<";
//
// NPButton
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(110, 30);
this.ControlBox = false;
this.Controls.Add(this.button2);
this.Controls.Add(this.button3);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Name = "NPButton";
this.ShowInTaskbar = false;
this.TopMost = true;
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NPButton_MouseDown);
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.NPButton_MouseUp);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.NPButton_MouseMove);
this.ResumeLayout(false);
}
#endregion
#endregion
private void NPButton_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseX=e.X;
mouseY=e.Y;
}
{
mouseX=e.X;
mouseY=e.Y;
}
private void NPButton_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button==MouseButtons.Left)
{
currX = this.Left - mouseX + e.X;
currY = this.Top - mouseY + e.Y;
{
if (e.Button==MouseButtons.Left)
{
currX = this.Left - mouseX + e.X;
currY = this.Top - mouseY + e.Y;
this.SetDesktopLocation(currX,currY);
}
}
}
}
private void NPButton_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Capture=true;
}
{
this.Capture=true;
}
}
- C#中用Form实现浮动工具栏(转)_
- Visual C# .Net 环境中编程实现浮动工具栏
- Visual C# .Net环境中编程实现浮动工具栏
- Visual C# .Net环境中编程实现浮动工具栏
- Visual C# .Net 环境中编程实现浮动工具栏
- Visual C# .Net 环境中编程实现浮动工具栏
- 如何创建C#版浮动工具栏?
- 如何创建C#版浮动工具栏?
- 如何创建C#版浮动工具栏?
- 如何创建C#版浮动工具栏?
- 用VB实现Photoshop浮动工具栏
- 一个浮动、分行工具栏的实现
- 浮动工具栏
- 浮动工具栏
- C# ToolStrip浮动工具栏及上/下/左/右 停靠
- 利用CDialogBar来实现类似工具栏的浮动条
- 利用CDialogBar来实现类似工具栏的浮动条
- Android 实现可用于文本选择的浮动工具栏
- 如何用最低的成本成就最高流量系列 各种线上推广手段的投入产出比数字公布(IreSearch.cn/龚文祥)(推荐帖)
- svn提交数据失败(提示 svn:MKACTIVITY ... 403 Forbidden )
- [摘]两种特殊的Java容器类List和Set分析
- 《时代》评出07年5个最差劲网站 MySpace入选
- 自定义JButton外观(Java)
- C#中用Form实现浮动工具栏(转)_
- Hibernate process a batch of data
- 传说中最贵的跑车: 布加迪威龙
- 用于datagrid模板针对不同的数据类型的参数归总
- Window.Open详解
- 框加中 退出 按钮的使用
- javascript弹出窗口问题总结
- 建设成功公司网站的最佳方案
- 使用Jakarta POI EXCEL API自动生成ORACLE数据字典的源代码