欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# Winform多屏幕多顯示器編程技巧實(shí)例

 更新時(shí)間:2015年06月04日 16:20:53   投稿:junjie  
這篇文章主要介紹了C# Winform多屏幕多顯示器編程技巧實(shí)例,本文直接給出代碼實(shí)例,需要的朋友可以參考下

在窗口的中間有一個(gè)System.Windows.Forms.PictureBox控件(該控件區(qū)域的面積為所在窗口的1/4),當(dāng)該控件的大部分區(qū)域落在其中一臺(tái)顯示器時(shí),在另一臺(tái)顯示器將不顯示該控件,(該P(yáng)ictureBox控件將移動(dòng)到主顯示器所在的窗口區(qū)域)。 

實(shí)現(xiàn)方法:

using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
using System.Data; 
namespace WindowsApplication12 
{ 
/// <summary> 
/// Summary description for Form1. 
/// </summary> 
public class Form1 : System.Windows.Forms.Form 
{ 
private int tmpx = 0; 
private int tmpy = 0; 
private System.Windows.Forms.PictureBox pictureBox1; 
/// <summary> 
/// Required designer variable. 
/// </summary> 
private System.ComponentModel.Container components = null; 
System.Drawing.Rectangle[] ScreensRect; 
public Form1() 
{ 
// 
// Required for Windows Form Designer support 
// 
InitializeComponent(); 
// 
// TODO: Add any constructor code after InitializeComponent call 
// 
} 
/// <summary> 
/// Clean up any resources being used. 
/// </summary> 
protected override void Dispose( bool disposing ) 
{ 
if( disposing ) 
{ 
if (components != null) 
{ 
components.Dispose(); 
} 
} 
base.Dispose( disposing ); 
} 
#region Windows Form Designer generated code 
/// <summary> 
/// Required method for Designer support - do not modify 
/// the contents of this method with the code editor. 
/// </summary> 
private void InitializeComponent() 
{ 
this.pictureBox1 = new System.Windows.Forms.PictureBox(); 
this.SuspendLayout(); 
// 
// pictureBox1 
// 
this.pictureBox1.BackColor = System.Drawing.SystemColors.HotTrack; 
this.pictureBox1.Location = new System.Drawing.Point(120, 88); 
this.pictureBox1.Name = "pictureBox1"; 
this.pictureBox1.Size = new System.Drawing.Size(248, 176); 
this.pictureBox1.TabIndex = 0; 
this.pictureBox1.TabStop = false; 
// 
// Form1 
// 
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
this.ClientSize = new System.Drawing.Size(504, 357); 
this.Controls.Add(this.pictureBox1); 
this.Name = "Form1"; 
this.Text = "Form1"; 
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); 
this.Load += new System.EventHandler(this.Form1_Load); 
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseUp); 
this.ResumeLayout(false); 
} 
#endregion 
/// <summary> 
/// The main entry point for the application. 
/// </summary> 
[STAThread] 
static void Main() 
{ 
Application.Run(new Form1()); 
} 
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) 
{ 
this.tmpx = e.X; 
this.tmpy = e.Y; 
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.form1_MouseMove); 
} 
private void Form1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) 
{ 
this.MouseMove -= new System.Windows.Forms.MouseEventHandler(this.form1_MouseMove); 
System.Drawing.Rectangle pictureBox1Rect=Screen.GetWorkingArea(pictureBox1); 
for(int i=0;i<ScreensRect.Length;i++) 
{ 
if(ScreensRect[i].X==pictureBox1Rect.X && ScreensRect[i].Y==pictureBox1Rect.Y) 
this.Location=new Point(ScreensRect[i].X,pictureBox1Rect.Y); 
} 
//MessageBox.Show(" WorkingArea:" + re.ToString()); 
} 
private void form1_MouseMove(object sender, MouseEventArgs e) 
{ 
this.Location = new System.Drawing.Point(this.Location.X + e.X - this.tmpx, this.Location.Y + e.Y - this.tmpy); 
} 
private void Form1_Load(object sender, System.EventArgs e) 
{ 
Screen[] s=Screen.AllScreens; 
ScreensRect=new Rectangle[s.Length]; 
for(int i=0;i<s.Length;i++) 
{ 
ScreensRect[i]= s[i].WorkingArea; 
} 
} 
} 
} 

相關(guān)文章

  • C#讀寫INI文件的方法

    C#讀寫INI文件的方法

    這篇文章主要介紹了C#讀寫INI文件的方法,涉及C#讀寫ini文件的相關(guān)實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-09-09
  • C#實(shí)現(xiàn)圖像選擇驗(yàn)證碼的示例代碼

    C#實(shí)現(xiàn)圖像選擇驗(yàn)證碼的示例代碼

    為了防止網(wǎng)站被非法登陸,網(wǎng)站一般通過(guò)驗(yàn)證碼的方式,防止黑客用軟件非法登陸,本文主要介紹了C#實(shí)現(xiàn)圖像選擇驗(yàn)證碼的示例代碼,具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-08-08
  • C#做線形圖的方法

    C#做線形圖的方法

    在本篇內(nèi)容中小編給大家總結(jié)了C#怎么做線形圖的教程內(nèi)容,對(duì)此有需要的朋友們可以跟著學(xué)習(xí)下。
    2018-12-12
  • c# List和Dictionary常用的操作

    c# List和Dictionary常用的操作

    這篇文章主要介紹了c# List和Dictionary常用的操作,幫助大家更好的理解和學(xué)習(xí)使用c#,感興趣的朋友可以了解下
    2021-04-04
  • c#關(guān)于非托管內(nèi)存的釋放問(wèn)題及解讀

    c#關(guān)于非托管內(nèi)存的釋放問(wèn)題及解讀

    這篇文章主要介紹了c#關(guān)于非托管內(nèi)存的釋放問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-02-02
  • C#權(quán)限管理和設(shè)計(jì)淺談

    C#權(quán)限管理和設(shè)計(jì)淺談

    權(quán)限管理是很多軟件中相當(dāng)重要的一個(gè)模塊——它的設(shè)計(jì)的好壞直接影響到軟件的安全性、權(quán)限管理的可擴(kuò)展性和易操作性 以及代碼中權(quán)限判斷的復(fù)雜程度和效率等方面
    2012-02-02
  • C#實(shí)現(xiàn)拆分合并Word表格中的單元格

    C#實(shí)現(xiàn)拆分合并Word表格中的單元格

    我們?cè)谑褂肳ord制作表格時(shí),由于表格較為復(fù)雜,只是簡(jiǎn)單的插入行、列并不能滿足我們的需要。要做一個(gè)完整的表格,很多時(shí)候需要將單元格進(jìn)行拆分或者合并。本文將詳細(xì)為您介紹在Word表格中拆分或合并單元格的思路及方法,希望對(duì)大家有所幫助
    2022-12-12
  • C#簡(jiǎn)單了解接口(Interface)使用方法

    C#簡(jiǎn)單了解接口(Interface)使用方法

    這篇文章主要介紹了C#簡(jiǎn)單了解接口(Interface)使用方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09
  • C# XML操作類分享

    C# XML操作類分享

    這篇文章主要分享了C# XML操作類的實(shí)例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-06-06
  • C# yield在WCF中的錯(cuò)誤用法(一)

    C# yield在WCF中的錯(cuò)誤用法(一)

    這篇文章主要介紹了C# yield在WCF中的錯(cuò)誤使用(一),本文講解的內(nèi)容據(jù)說(shuō)是99%的開發(fā)人員都有可能犯的錯(cuò)誤,需要的朋友可以參考下
    2015-04-04

最新評(píng)論