posts - 124,  comments - 29,  trackbacks - 0

//注意在工程上添加系统引用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)
        
{
            
        }

    }

}
posted on 2010-02-26 16:14 天书 阅读(2814) 评论(1)  编辑 收藏 引用

FeedBack:
# re: C# 浮动窗口 屏幕右下角显示但不获得焦点 工程上右键添加系统引用System.Drawing
2010-11-13 21:15 | Aita
您好,请问Office2007Form是个怎样的form?  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

常用链接

留言簿(5)

随笔档案

文章分类

文章档案

好友的Bolg

搜索

  •  

最新评论

阅读排行榜

评论排行榜