作者:冬日暖光816 | 来源:互联网 | 2023-08-30 20:42
在窗口的中间有一个System.Windows.Forms.PictureBox控件(该控件区域的面积为所在窗口的14),当该控件的大部分区域落在其中一台显示器时,在另一台显示器将
在窗口的中间有一个System.Windows.Forms.PictureBox控件(该控件区域的面积为所在窗口的1/4),当该控件的大部分区域落在其中一台显示器时,在另一台显示器将不显示该控件,(该PictureBox控件将移动到主显示器所在的窗口区域)。
实现方法:
usingSystem; usingSystem.Drawing; usingSystem.Collections; usingSystem.ComponentModel; usingSystem.Windows.Forms; usingSystem.Data; namespaceWindowsApplication12 { /// ///SummarydescriptionforForm1. /// publicclassForm1:System.Windows.Forms.Form { privateinttmpx=0; privateinttmpy=0; privateSystem.Windows.Forms.PictureBoxpictureBox1; /// ///Requireddesignervariable. /// privateSystem.ComponentModel.COntainercomponents=null; System.Drawing.Rectangle[]ScreensRect; publicForm1() { // //RequiredforWindowsFormDesignersupport // InitializeComponent(); // //TODO:AddanyconstructorcodeafterInitializeComponentcall // } /// ///Cleanupanyresourcesbeingused. /// protectedoverridevoidDispose(booldisposing) { if(disposing) { if(components!=null) { components.Dispose(); } } base.Dispose(disposing); } #regionWindowsFormDesignergeneratedcode /// ///RequiredmethodforDesignersupport-donotmodify ///thecontentsofthismethodwiththecodeeditor. /// privatevoidInitializeComponent() { this.pictureBox1=newSystem.Windows.Forms.PictureBox(); this.SuspendLayout(); // //pictureBox1 // this.pictureBox1.BackColor=System.Drawing.SystemColors.HotTrack; this.pictureBox1.Location=newSystem.Drawing.Point(120,88); this.pictureBox1.Name="pictureBox1"; this.pictureBox1.Size=newSystem.Drawing.Size(248,176); this.pictureBox1.TabIndex=0; this.pictureBox1.TabStop=false; // //Form1 // this.AutoScaleBaseSize=newSystem.Drawing.Size(5,13); this.ClientSize=newSystem.Drawing.Size(504,357); this.Controls.Add(this.pictureBox1); this.Name="Form1"; this.Text="Form1"; this.MouseDown+=newSystem.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); this.Load+=newSystem.EventHandler(this.Form1_Load); this.MouseUp+=newSystem.Windows.Forms.MouseEventHandler(this.Form1_MouseUp); this.ResumeLayout(false); } #endregion /// ///Themainentrypointfortheapplication. /// [STAThread] staticvoidMain() { Application.Run(newForm1()); } privatevoidForm1_MouseDown(objectsender,System.Windows.Forms.MouseEventArgse) { this.tmpx=e.X; this.tmpy=e.Y; this.MouseMove+=newSystem.Windows.Forms.MouseEventHandler(this.form1_MouseMove); } privatevoidForm1_MouseUp(objectsender,System.Windows.Forms.MouseEventArgse) { this.MouseMove-=newSystem.Windows.Forms.MouseEventHandler(this.form1_MouseMove); System.Drawing.RectanglepictureBox1Rect=Screen.GetWorkingArea(pictureBox1); for(inti=0;i 您可能感兴趣的文章:C#实现Winform中打开网页页面的方法C#实现WinForm禁止最大化、最小化、双击标题栏、双击图标等操作的方法C#中如何使用Winform实现炫酷的透明动画界面C#实现winform用子窗体刷新父窗体及子窗体改变父窗体控件值的方法C#WinForm程序处理后台繁忙导致前台控件假死现象解决方法C#实现windowsform拷贝内容到剪贴板的方法C#实现Winform动态添加菜单的方法C#调用dos窗口获取相关信息的方法C#执行DOS命令的方法C#实现在Form里面内嵌dos窗体的方法
标签: fo form info orm 编程技巧 技巧 rm for nf infor