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>
Summary description of the Form1.
</summary>
public class Form1:System.Windows.Forms.Form
{
Size of the desktop workspace
Size Workingarea;
The initial position of the Form and the position in the lower-left corner, the lower-right corner
Point Formloc, Ptleftbottom, Ptrightbottom;
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 = "Double-click the left mouse button in the form blank to start taking the color, press ESC to determine the color";
Tip. SetToolTip (this, tipmsg);
Tip. SetToolTip (Lblcolor, tipmsg);
Tip. SetToolTip (Txtargb, tipmsg);
}
<summary>
Clean up all resources that are in use.
</summary>
protected override void Dispose (bool disposing)
{
if (disposing)
{
if (Components!= null)
{
Components. Dispose ();
}
}
Base. Dispose (disposing);
}
#region Windows Form Designer generated code
<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</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.Drawing.Point (8, 40);
This.txtArgb.Name = "Txtargb";
This.txtArgb.TabIndex = 1;
This.txtArgb.Text = "";
This.txtArgb.KeyPress + = new System.Windows.Forms.KeyPressEventHandler (this.txtargb_keypress);
//
Form1
//
This. AutoScaleBaseSize = new System.Drawing.Size (6, 14);
This. ClientSize = new System.Drawing.Size (115, 70);
This. Controls.Add (THIS.TXTARGB);
This. Controls.Add (This.lblcolor);
This. Name = "Form1";
This. Text = "screen take color (upto)";
This. DoubleClick + = new System.EventHandler (this. Form1_doubleclick);
This. MouseEnter + = new System.EventHandler (this. Form1_mouseenter);
This. ResumeLayout (FALSE);
}
#endregion
<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main ()
{
Application.Run (New Form1 ());
}
[DllImport ("Gdi32.dll")]
private static extern bool BitBlt (
IntPtr hdcdest,//handle of target device
int nxdest,//x coordinate of the upper-left corner of the target object
int nydest,//x coordinate of the upper-left corner of the target object
int nwidth,//The width of the rectangle of the target object
int nheight,//The length of the rectangle of the target object
IntPtr hdcsrc,//source device handle
int NXSRC,//x coordinate of the upper-left corner of the source object
int NYSRC,//x coordinate of the upper-left corner of the source object
int Dwrop//Raster operation value
);
[DllImport ("Gdi32.dll")]
private static extern IntPtr CreateDC (
String lpszdriver,//driver name
String lpszdevice,//device name
String lpszoutput,//useless, can be set to locate "NULL"
INTPTR Lpinitdata//Any printer data
);
private void Txtargb_keypress (object sender, KeyPressEventArgs e)
{
Determines the color ARGB value when the ESC key is pressed
Note: Valid only if the form is active
if (E.keychar = = (char) keys.escape)
{
Tmr. Enabled = false;
This. Location = Formloc;
This. topmost = false;
Txtargb.selectall ();
}
}
private void Form1_mouseenter (object sender, EventArgs e)
{
if (this. Location = = ptleftbottom)//form in the lower left corner
{
This. Location = Ptrightbottom;
}
else if (this. Location = = ptrightbottom)//form in the lower right corner
{
This. Location = Ptleftbottom;
}
}
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.