日期:2013-02-08  浏览次数:20484 次

//////////////////////////////////////////////////////////////////////////

/// 程序:屏幕取色

/// 功能:动态获取当前屏幕中光标所在位置的颜色

/// 作者:黎波

/// 网名:upto(阿球)

/// 邮箱:itfun@163.com

/// 日期:2004年3月31日

//////////////////////////////////////////////////////////////////////////


using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

namespace LiBo.ColorPicker
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
// 桌面工作区的尺寸
Size workingArea;
// Form 的初始位置和在左下角,右下角的位置
Point formLoc, ptLeftBottom, ptRightBottom;

private System.Windows.Forms.Label lblColor;
private System.Windows.Forms.TextBox txtArgb;
private System.Windows.Forms.Timer tmr;
private System.Windows.Forms.ToolTip tip;
private System.ComponentModel.IContainer components;

public Form1()
{
InitializeComponent();

this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
this.StartPosition = FormStartPosition.CenterScreen;

Rectangle rect = SystemInformation.WorkingArea;
workingArea = new Size(rect.Width, rect.Height);
ptLeftBottom = new Point(0, workingArea.Height - this.Height);
ptRightBottom = new Point(workingArea.Width - this.Width,
workingArea.Height - this.Height);

String tipMsg = "在窗体空白处双击鼠标左键开始取色,按ESC键确定颜色";
tip.SetToolTip(this, tipMsg);
tip.SetToolTip(lblColor, tipMsg);
tip.SetToolTip(txtArgb, tipMsg);
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lblColor = new System.Windows.Forms.Label();
this.tmr = new System.Windows.Forms.Timer(this.components);
this.txtArgb = new System.Windows.Forms.TextBox();
this.tip = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// lblColor
//
this.lblColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblColor.Location = new System.Drawing.Point(8, 8);
this.lblColor.Name = "lblColor";
this.lblColor.TabIndex = 0;
//
// tmr
//
this.tmr.Tick += new System.EventHandler(this.tmr_Tick);
//
// txtArgb
//
this.txtArgb.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.txtArgb.Font = new System.Drawing.Font("Arial", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.txtArgb.Location = new System.