xFocus 集中你的注意力

xFocus是一款绿色、免费软件。他的功能十分简单,可以让当前获得焦点的窗口亮度保持不变,其他部分则变暗,既可以帮助大家提高注意力,又可以节电,提高笔记本的续航能力。 下面是源代码, 

 
  
[DllImport( " user32.dll " , EntryPoint = " GetWindowLong " )]
public static extern long GetWindowLong(IntPtr hwnd, int nIndex);
[DllImport(
" user32.dll " , EntryPoint = " SetWindowLong " )]
public static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong);
[DllImport(
" user32 " , EntryPoint = " SetLayeredWindowAttributes " )]
public static extern int SetLayeredWindowAttributes(IntPtr Handle, int crKey, byte bAlpha, int dwFlags);
const int GWL_EXSTYLE = - 20 ;
const int WS_EX_TRANSPARENT = 0x20 ;
const int WS_EX_LAYERED = 0x80000 ;
const int LWA_ALPHA = 2 ;  

public Form1()
{
InitializeComponent();
// 无边框
this .FormBorderStyle = FormBorderStyle.None;
// 不在任务栏中显示,用户按开始键或Ctrl+Tab时
this .ShowInTaskbar = false ;
// 置于顶层
this .TopMost = true ;
// this.TopLevel = true ;
// 窗口布满整个屏幕
this .StartPosition = FormStartPosition.Manual;
this .Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
// 查看任务管理器时用
// this.Height -= 30;
// 接受键盘输入,用于快捷键,如Esc
this .KeyPreview = true ;
}

private void Form1_Load( object sender, EventArgs e)
{

this .notifyIcon1.Visible = true ;
// Color myColor = new Color(100, 1, 1, 1);
// Color cl = new Color(100, 1, 1);
this .BackColor = Color.FromArgb( 0 , 0 , 0 );
// this.BackColor = Color.Black;
       this .WindowState = FormWindowState.Maximized;  
      SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(Handle,GWL_EXSTYLE)
| WS_EX_TRANSPARENT | WS_EX_LAYERED);  
      SetLayeredWindowAttributes(Handle,
0 , 133 ,LWA_ALPHA);  

}
下载地址:http://dl.dbank.com/c0i91fbwi0 2011061618082188.jpg

转载于:https://www.cnblogs.com/geekzph/archive/2011/06/16/2082964.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值