在C#中,如果你需要对一个控件的背景色赋值,你可用 Color.FromArgb(int,int,int) 方法:
panel3.BackColor = Color.FromArgb(128, 128, 255);
在c#中,你想让鼠标经过控件,空间变色,你可以利用事件;
在C#中,鼠标点击窗体后窗体随鼠标拖动,代码最少的方法是利用WinApi:
panel3.BackColor = Color.FromArgb(128, 128, 255);
在c#中,你想让鼠标经过控件,空间变色,你可以利用事件;
private void panel3_MouseEnter(object sender, EventArgs e) //鼠标经过
{
panel3.BackColor = Color.FromArgb(128, 128, 255);
}
private void panel3_MouseLeave(object sender, EventArgs e) //鼠标移出
{
panel3.BackColor = Color.FromArgb(192, 192, 255);
}
在C#中,鼠标点击窗体后窗体随鼠标拖动,代码最少的方法是利用WinApi:
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MOVE = 0xF010;
public const int HTCAPTION = 0x0002;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
}