//注意在工程上添加系統引用System.Drawing 否則System點不出Drawing來。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
namespace TaskBarFloatWnd
{
public partial class Form1 : Office2007Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TaskBarWnd taskWnd = new TaskBarWnd();
System.Drawing.Rectangle r = System.Windows.Forms.Screen.GetWorkingArea(taskWnd);
taskWnd.Location = new System.Drawing.Point(r.Right - taskWnd.Width, r.Bottom - taskWnd.Height);
taskWnd.Show();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
namespace TaskBarFloatWnd

{
public partial class TaskBarWnd : Office2007Form
{
public TaskBarWnd()
{
InitializeComponent();
actform = GetActiveWindow();
}
private bool isFristShow = true;//標識是否是首次加載
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr GetActiveWindow();//獲得當前活動窗體
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern IntPtr SetActiveWindow(IntPtr hwnd);//設置活動窗體
private IntPtr actform = IntPtr.Zero;//保存自己得到焦點前擁有活動窗體的柄
private void TaskBarWnd_Load(object sender, EventArgs e)
{
textBox1.Text = DateTime.Now + "——";
textBox1.Text = textBox1.Text + "目前正對網元1進行做單操作,10分鐘內請大家避讓";
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
if (isFristShow == true)
{
SetActiveWindow(actform);
isFristShow = false;
}
}

private void TaskBarWnd_FormClosing(object sender, FormClosingEventArgs e)
{
}
}
}

