using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using ControlExs; namespace TransForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); //// 定义在窗体上,光标显示为手形
this.Cursor = System.Windows.Forms.Cursors.Hand;
//// 定义窗体的标题名称
this.Text = "透明的WinForm窗体!";
//// 定义窗体的开始显示位置是屏幕的中间
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
//// 窗体的边界是Fixed3D类型
//this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
////以桌面的前景色作为窗体的前景色
this.ForeColor = System.Drawing.SystemColors.Desktop;
//// 定义字体类型,大小
this.Font = new System.Drawing.Font("宋体", );
//// 定义背景色为蓝色
this.BackColor = System.Drawing.Color.White;
// 设置窗体的大小
//this.ClientSize = new System.Drawing.Size(440, 170);
// Opacity属性设立窗体的透明程度,只对于视窗2000有效
this.Opacity = 0.60;
} 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 = 0x00000080 | 0x00000008; //WS_EX_TOOLWINDOW | WS_EX_TOPMOST
return cp;
}
}
}
}
 public 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 = 0x00000001;
public static uint LWA_ALPHA = 0x00000002; [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 = 0x00080000 }
}

C# 制作透明窗体的更多相关文章

  1. WPF透明窗体制作

    原文:WPF透明窗体制作 窗体的样式: <Grid Width="{Binding Width, ElementName=w}" Height="{Binding ...

  2. C#在透明窗体WinForm上面画图(电子尺小工具的实现)

    前几天要做一个微信调一调的外挂,里面用到了尺子测量距离,然后就自己下载了一个电子尺,最近要升级我的跳一跳外挂,然后就准备自己做一个电子尺,嵌入到我的外挂里面,在嵌入到我的外挂之前,我自己做了一个完整版 ...

  3. 【flash】关于flash的制作透明gif的一个小技巧

    关于flash的制作透明gif的一个小技巧 或者说是一个需要注意的地方 1.导出影片|gif,得到的肯定是不透明的.2.想要透明背景,必须通过发布.3.flash中想要发布gif动画的话,不能有文字, ...

  4. gdi+ 高速绘制透明窗体

    gdi+ 高速绘制透明窗体: 方法一: 1.用Iamge对象载入png资源, 2.调用drawimage函数讲图片绘制出了 3.UpdateLayeredWindow对窗体进行布局 方法二: 1.用B ...

  5. qt 获取windows 的消息(通过MFC的DLL的透明窗体转发消息)good

    qt 给win32 发送消息很简单,但是要获取windows 消息却十分复杂,最后想了一个不是很完美 但是也是以现在本人能力所能实现的唯一途径了,基本原理是 利用vc编写一个mfc 的dll ,这个d ...

  6. C/S模式开发中如何利用WebBrowser控件制作导航窗体

    原文:C/S模式开发中如何利用WebBrowser控件制作导航窗体 转自: CSDN 相信不少同学们都做过MIS系统的开发,今天这里不讨论B/S模式开发的问题.来谈谈winform开发.用过市面上常见 ...

  7. DSAPI实现简单的透明窗体

    代码 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim B As New Bitmap( ...

  8. 【转载】Layered Window(分层窗体,透明窗体)

    本文转载自花间醉卧<Layered Window(分层窗体,透明窗体)> //为窗体添加WS_EX_LAYERED属性,该属性使窗体支持透明 ModifyStyleEx(0, WS_EX_ ...

  9. WPF透明窗体不支持缩放解决方案

    方案一 WPF中的无边框透明窗体,由于没有边并且透明,窗体无法进行缩放操作,今天来讲解如何解决这个问题. 先说一下思路,我们先手为该窗体添加4个边,4个角用于缩放操作,然后再为他们写事件,完成拖放操作 ...

随机推荐

  1. 关于在 mac上配置pytesseract的相关问题

    因为踩了两个小时坑 特别是在配置依赖tesseract-ORC识别库时候的问题 特别麻烦 一定要用brewhome 一定要用brewhome 一定要用brewhome 重要的事情说三遍. 刚开始我在网 ...

  2. 异常处理与MiniDump详解(转)

    一.   综述 总算讲到MiniDump了. Dump有多有用我都无法尽数,基本上属于定位错误修复BUG的倚天剑.(日志可以算是屠龙刀)这些都是对于那些不是必出的BUG,放在外面运行的时候出现的BUG ...

  3. C语言中返回字符串函数的四种实现方法 2015-05-17 15:00 23人阅读 评论(0) 收藏

    C语言中返回字符串函数的四种实现方法 分类: UNIX/LINUX C/C++ 2010-12-29 02:54 11954人阅读 评论(1) 收藏 举报 语言func存储 有四种方式: 1.使用堆空 ...

  4. Working with nil

    [Working with nil] It’s always a good idea to initialize scalar variables at the time you declare th ...

  5. stm32 usb数据接收与数据发送程序流程分析

    http://blog.csdn.net/u011318735/article/details/17424349 既然学习了USB,那就必须的搞懂USB设备与USB主机数据是怎么通讯的.这里主要讲设备 ...

  6. Python基础 练习题

    DAY .1 1.使用while循环输出 1 2 3 4 5 6     8 9 10 n = 1 while n < 11: if n == 7: pass else: print(n) n ...

  7. POJ2299Ultra-QuickSort (线段树和归并排序的解法)

    题目大意就是说帮你给一些(n个)乱序的数,让你求冒泡排序需要交换数的次数(n<=500000) 此题最初真不会做,我也只是在听了章爷的讲解后才慢慢明白过来的 首先介绍线段树的解法: 我们先将原数 ...

  8. windows server 2008 支持 .net framework 4.0

    windows server 2008平台下需要安装sp1,或打KB958854补丁,IIS7.0才能支持.net framework 4.0. 否则,IIS7.0中的应用程序虽然被配置为.net 4 ...

  9. hdoj 5358 First One

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5358 一开始一直以为是一道数学题,在找有什么规律化简Log2(S(i,j)),结束了以后才造  ⌊lo ...

  10. 浅析 JavaScript 中的闭包(Closures)

    a { text-decoration: none; color: #4094c7 } h4,h5 { margin: 0; font-weight: 700; color: inherit; lin ...