C# [Win32] [API] Layered Windows
static void* WndProc(void* hwnd, uint uMsg, void* wParam, void* lParam)
{
switch (uMsg)
{
case WM_PAINT:
case WM_CTLCOLORMSGBOX:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORBTN:
case WM_CTLCOLORDLG:
case WM_CTLCOLORSCROLLBAR:
case WM_CTLCOLORSTATIC:
case WM_CAPTURECHANGED:
{
if (_pimg != null)
{
void* _hwnd = GetAncestor(hwnd, GA_ROOT); uint uw, uh;
GdipGetImageWidth(_pimg, &uw); GdipGetImageHeight(_pimg, &uh); RECT rcc, rcs;
GetClientRect(_hwnd, &rcc);
GetWindowRect(_hwnd, &rcs); PAINTSTRUCT ps;
void* hdc = BeginPaint(_hwnd, &ps); //GetDC(hwnd);
void* hdcmem = CreateCompatibleDC(hdc); BITMAPINFO bi;
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = (int)uw;
bi.bmiHeader.biHeight = (int)uh;
bi.bmiHeader.biPlanes = ;
bi.bmiHeader.biBitCount = ;
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biClrUsed = ;
bi.bmiHeader.biSizeImage = ; void* pvbits;
void* hbmpmem = CreateDIBSection(hdc, &bi, DIB_RGB_COLORS, &pvbits, null, 0u); if (hbmpmem != null)
{
SelectObject(hdcmem, hbmpmem); GpGraphics* g;
if (GdipCreateFromHDC(hdcmem, &g) == )
{
GdipDrawImageRectI(g, _pimg, , , (int)uw, (int)uh); #if true
RECT rc;
for (int i = ; i < ; i++)
{
void* h = GetDlgItem(_hwnd, i);
if (IsWindowVisible(h) == )
{
GetWindowRect(h, &rc);
MapWindowPoints(null, _hwnd, (POINT*)&rc, );
GpBitmap* gpbmp;
GdipCreateBitmapFromScan0(rc.right - rc.left, rc.bottom - rc.top, , PixelFormat32bppARGB, null, &gpbmp);
GpGraphics* gpg;
if (GdipGetImageGraphicsContext((GpImage*)gpbmp, &gpg) == )
{
void* hdc2;
GdipGetDC(gpg, &hdc2);
SendMessageW(h, WM_PRINT, hdc2, (void*)(PRF_NONCLIENT | PRF_CLIENT | PRF_ERASEBKGND | PRF_CHILDREN));
GdipReleaseDC(gpg, hdc2);
GdipDeleteGraphics(gpg);
}
GdipDrawImageRectI(g, (GpImage*)gpbmp, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
GdipDisposeImage((GpImage*)gpbmp);
}
}
#endif POINT ptscr; POINT ptdst;
ptdst.x = rcs.left;
ptdst.y = rcs.top; SIZE szwnd;
szwnd.cx = (int)uw;
szwnd.cy = (int)uh; BLENDFUNCTION bf;
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0x0;
bf.SourceConstantAlpha = 0xff;
bf.AlphaFormat = AC_SRC_ALPHA; UPDATELAYEREDWINDOWINFO ulwi;
ulwi.cbSize = sizeof(UPDATELAYEREDWINDOWINFO);
ulwi.hdcDst = hdc;
ulwi.pptDst = &ptdst;
ulwi.psize = &szwnd;
ulwi.hdcSrc = hdcmem;
ulwi.pptSrc = &ptscr;
ulwi.crKey = (COLORREF)0u;
ulwi.pblend = &bf;
ulwi.dwFlags = ULW_ALPHA;
ulwi.prcDirty = null; //UpdateLayeredWindow(_hWnd, hdc, &ptdst, &szwnd, hdcmem, &ptscr, (COLORREF)0u, &bf, ULW_ALPHA);
UpdateLayeredWindowIndirect(_hwnd, &ulwi); GdipDeleteGraphics(g);
}
DeleteObject(hbmpmem);
} DeleteDC(hdcmem);
//ReleaseDC(hwnd, hdc);
EndPaint(_hwnd, &ps);
}
}
break;
}
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}


C# [Win32] [API] Layered Windows的更多相关文章
- Serial Port Programming using Win32 API(转载)
In this tutorial we will learn How to communicate with an external device like a microcontroller boa ...
- How to change windows applicatioin's position via Win32 API
可以使用的Win32 API是: [DllImport("user32.dll")] private extern static bool SetWindowPos(IntPtr ...
- WIN32 API ------ 最简单的Windows窗口封装类
1 开发语言抉择 1.1 关于开发Win32 程序的语言选择 C还是C++ 在决定抛弃MFC,而使用纯Win32 API 开发Window桌面程序之后,还存在一个语言的选择,这就是是否使用C++.C+ ...
- 使用Win32 API创建不规则形状&带透明色的窗口
前一阵突然想起了9月份电面某公司实习时的二面题,大概就是说怎么用Win32 API实现一个透明的窗口,估计当时我的脑残答案肯定让面试官哭笑不得吧.所以本人决定好好研究下这个问题.经过一下午的摸索,基本 ...
- 初次认识 C# win32 api
第一次接触win32api,刚开始的时候有点迷迷糊糊的. Windows API 就是windows应用程序接口. win api向上就是windows应用程序,向下就是windows操作系统核心. ...
- 【温故Delphi】GAEA用到Win32 API目录
Delphi是Windows平台下著名的快速应用程序开发工具,它在VCL中封装并使用了大量的Win32 API. GAEA基于VCL开发的工具类产品,在程序中使用了大量的Win32 API,将经常用到 ...
- 【C#】分享基于Win32 API的服务操作类(解决ManagedInstallerClass.InstallHelper不能带参数安装的问题)
注:这里的服务是指Windows 服务. ------------------201508250915更新------------------ 刚刚得知TransactedInstaller类是支持带 ...
- C#中导入Win32 API函数
C#中导入Win32 API的方法: 1.引用命名空间 using System.Net.Security; using System.Runtime.InteropServices; 2. [Dll ...
- C#调用Win32 api学习总结
从.NET平台调用Win32 API Win32 API可以直接控制Microsoft Windows的核心,因为API(Application Programming Interface)本来就是微 ...
随机推荐
- asp.net 对象转XML,XML转对象
//对象转XML public static string ObjToXml(object obj) { using (MemoryStream Stream = new MemoryStream() ...
- GIT命令介绍
Linus花了两周时间自己用C写了一个分布式版本控制系统,这就是Git!一个月之内,Linux系统的源码已经由Git管理了!牛是怎么定义的呢?大家可以体会一下. 区别与集中式的分布式实现!!!! 集中 ...
- Java并发编程的艺术读后总结
2019.04.26 - 2019.04.28扫了一遍 Chapter volatile synchronized实现原理 Java内存模型 happen-before 重排序 顺序一致性 JMM 线 ...
- centos 7安装phantomjs
centos 7安装phantomjs wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_6 ...
- [MySQL] timestamp和datetime的区别
建表语句如下: create table strong_passwd_whitelist( id int unsigned not null auto_increment, email_id int ...
- Java问题解决:"错误:编码GBK 的不可映射字符"
参考资料:http://blog.csdn.net/l1028386804/article/details/46583279 场景: 在使用javac编译java文件时出现以下错误: 解决方法: 使用 ...
- [CentOS_7.4]Linux编译安装ffmpeg
[CentOS_7.4]Linux编译安装ffmpeg 安装过程: 下载安装源,配置,编译,安装,设置环境变量. # wget http://www.ffmpeg.org/releases/ffm ...
- week 10--了解原型设计的工具
了解原型设计的工具 随着原型应用的普及,越来越多的产品会采用原型设计来表述.完善整体需求,这样做自然有其原因.首先原型的制作成本和演示成本都比较低,除非比较复杂或者保真度要求比较高的原型,在描述一个功 ...
- 雷林鹏分享:解决CI框架的Disallowed Key Characters错误提示
用CI框架时,有时候会遇到这么一个问题,打开网页,只显示 Disallowed Key Characters 错误提示.有人说 url 里有非法字符.但是确定 url 是纯英文的,问题还是出来了.但清 ...
- LDA(线性判别分类器)学习笔记
Linear Discriminant Analysis(线性判别分类器)是对费舍尔的线性鉴别方法(FLD)的归纳,属于监督学习的方法. LDA的基本思想是将高维的模式样本投影到最佳鉴别矢量空间,以达 ...