调用WindowsAPI使窗体始终保持置顶效果,不被其他窗体遮盖: [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags); /// <summary> /// 得到当前活动的窗口 /// &…
1.通过tag属性传输,tag属性是存储与空间密切相关的数据.比如登陆界面的数据传输给主界面. 子窗体 主窗体 定义一个类 namespace FrmLogin { public class User { public string UserName { set; get; } public string PassWorld { set;…
using System.Runtime.InteropServices; public class Win32 { public const Int32 AW_HOR_POSITIVE = 0x00000001; // 从左到右打开窗口 public const Int32 AW_HOR_NEGATIVE = 0x00000002; // 从右到左打开窗口 public const Int32 AW_VER_POSITIVE = 0x00000004; // 从上到下打开窗口 public c…
#region 方法一 Point first = this.Location; for (int i = 0; i < 50; i++) { Application.DoEvents(); Random ran = new Random(); Point p = new Point(this.Location.X + ran.Next(10) - 4, this.Location.Y + ran.Next(10) - 4); System.Threading.Thread.Sleep(10);…
using System;using System.Collections.Generic;using System.Text;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;using System.Runtime.InteropServices; partial class CYMessageBox : Form { [DllImport("user32.dll",…