using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices; namespace TransForm {
class WinAPI
{
[DllImport("user32.dll")]
public extern static IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public extern static bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags); public static uint LWA_COLORKEY = ×;
public static uint LWA_ALPHA = ×; [DllImport("user32.dll")]
public extern static uint SetWindowLong(IntPtr hwnd,int nIndex, uint dwNewLong); [DllImport("user32.dll")]
public extern static uint GetWindowLong(IntPtr hwnd, int nIndex); public enum WindowStyle : int
{
GWL_EXSTYLE = -
} public enum ExWindowStyle : uint
{
WS_EX_LAYERED = ×
}
}
} using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TransForm{ public partial class Form1 : Form
{
public Form1(){InitializeComponent();}
private void Form1_Load(object sender, EventArgs e)
{
this.SetWindowTransparent();
} private void SetWindowTransparent(byte bAlpha)
{
try {
WinAPI.SetWindowLong(this.Handle,(int)WinAPI.WindowStyle.GWL_EXSTYLE,WinAPI.GetWindowLong(this.Handle,(int)WinAPI.WindowStyle.GWL_EXSTYLE)|(uint)WinAPI.ExWindowStyle.WS_EX_LAYERED);
WinAPI.SetLayeredWindowAttributes( this.Handle, , bAlpha, WinAPI.LWA_COLORKEY | WinAPI.LWA_ALPHA);
}
catch
{ }
} protected override CreateParams CreateParams
{
get {
CreateParams cp = base.CreateParams;
cp.Parent = WinAPI.GetDesktopWindow();
cp.ExStyle = × | ×;
//WS_EX_TOOLWINDOW | WS_EX_TOPMOST
return cp;
}
}
}
}

C#透明窗体代码详解的更多相关文章

  1. 委托与事件代码详解与(Object sender,EventArgs e)详解

    委托与事件代码详解 using System;using System.Collections.Generic;using System.Text; namespace @Delegate //自定义 ...

  2. 使用Squid做代理服务器,Squid单网卡透明代理配置详解(转)

    使用Squid做代理服务器 说到代理服务器,我们最先想到的可能是一些专门的代理服务器网站,某些情况下,通过它们能加快访问互联网的速度.其实,在需要访问外部的局域网中,我们自己就能设置代理,把访问次数较 ...

  3. BM算法  Boyer-Moore高质量实现代码详解与算法详解

    Boyer-Moore高质量实现代码详解与算法详解 鉴于我见到对算法本身分析非常透彻的文章以及实现的非常精巧的文章,所以就转载了,本文的贡献在于将两者结合起来,方便大家了解代码实现! 算法详解转自:h ...

  4. ASP.NET MVC 5 学习教程:生成的代码详解

    原文 ASP.NET MVC 5 学习教程:生成的代码详解 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连接字符串 ...

  5. Github-karpathy/char-rnn代码详解

    Github-karpathy/char-rnn代码详解 zoerywzhou@gmail.com http://www.cnblogs.com/swje/ 作者:Zhouwan  2016-1-10 ...

  6. 代码详解:TensorFlow Core带你探索深度神经网络“黑匣子”

    来源商业新知网,原标题:代码详解:TensorFlow Core带你探索深度神经网络“黑匣子” 想学TensorFlow?先从低阶API开始吧~某种程度而言,它能够帮助我们更好地理解Tensorflo ...

  7. JAVA类与类之间的全部关系简述+代码详解

    本文转自: https://blog.csdn.net/wq6ylg08/article/details/81092056类和类之间关系包括了 is a,has a, use a三种关系(1)is a ...

  8. Java中String的intern方法,javap&cfr.jar反编译,javap反编译后二进制指令代码详解,Java8常量池的位置

    一个例子 public class TestString{ public static void main(String[] args){ String a = "a"; Stri ...

  9. Kaggle网站流量预测任务第一名解决方案:从模型到代码详解时序预测

    Kaggle网站流量预测任务第一名解决方案:从模型到代码详解时序预测 2017年12月13日 17:39:11 机器之心V 阅读数:5931   近日,Artur Suilin 等人发布了 Kaggl ...

随机推荐

  1. Options for Debugging Your Program or GCC

    [Options for Debugging Your Program or GCC] -g Produce debugging information in the operating system ...

  2. HDOJ_1010 Tempter of the Bone

    http://acm.hdu.edu.cn/showproblem.php?pid=1010 奇偶剪枝:可以把map看成这样: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 ...

  3. circle area

    circle area Github 链接:传送门 本次作业要求 Create a program that asks for the radius of a circle and prints th ...

  4. HDU 1561The more, The Better(树形DP)

    HDU 1561  The more, The Better 题目大意就不说了 直接DP[i][j]表示i为跟节点的子树上攻克j个城堡的所能获得的最多宝物的数量 DP[fa][j] = MAX{DP[ ...

  5. springMVC使用注解方式进行页面跳转

    <!--控制层-->package cn.org.spartacus.spring; import org.springframework.beans.factory.annotation ...

  6. MVC中Model用法

    Model:对于MVC来说,Model可不简单只是实体,它应该叫视图模型,这是我自己的理解,即视图中的数据由Model来提供,当视图的数据需要改变时,我们不用打开aspx或ascx文件,只需要修改相应 ...

  7. fastJson泛型如何转换

    引子 现在负责的业务 和 json 打交道比较多, 最近使用fastJson框架 json串转成泛型对象遇到了一个异常 : java.lang.ClassCastException 还原下场景 : 模 ...

  8. 浅析WINFORM工具条的重用实现

    一直以来,我都想看看别人家的工具栏重用(图1)到底是如何实现的,但在网上搜索了很久都没有找到过,即使找到一些程序,要么就是把这个工具栏写在具体的画面(图2),要么就是没有源代码的, 我在想,是否别人也 ...

  9. cocos2dx 手势识别

    转自:http://blog.csdn.net/qq634416025/article/details/8685187 g_rGemertricRecognizer = new GeometricRe ...

  10. 【转】【公司调查】车来了APP

    http://blog.sina.com.cn/s/blog_83b10acc0102vk7k.html   [APP简介] "车来了"是武汉元光科技有限公司开发的一款查询公交车实 ...