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)本来就是微 ...
随机推荐
- python文件读书笔记
一.打开文件 1 f=open('text.txt',r) 二.读取文件 print(f.read) 三.关闭文件 f.close() 比较好用的是运用with with open('text.tx ...
- Vue/Egg大型项目开发(二)数据库设计
项目Github地址:前端(https://github.com/14glwu/stuer)后端(https://github.com/14glwu/stuer-server) 项目线上预览:http ...
- topcoder srm 615 div1
problem1 link 对于数字$x$,检验每个满足$x=y*2^{t}$的$y$能否变成$x$即可. problem2 link 如果起点到终点有一条长度为$L$的路径,那么就存在长度为$L+k ...
- Windows 控制面板调用命令
使用命令打开 Windows 控制面板指定页面 control.exe /name microsoft.folderoptions 启动资源管理器的 文件夹属性 选项卡 control.exe /na ...
- snmp模拟器snmpsid使用
snmpsim使用 安装 pip install snmpsim 简单使用 生成snmpwalk文件: snmpwalk -v2c -c 'password' -ObentU 218.200.x.15 ...
- 分治(超级easy 不要看)
P1226快速幂 #include<bits/stdc++.h> using namespace std; #define int long long ; int f(int b,int ...
- parquet列式文件实战(未完,待续)
parquet列式文件实战 parquet code demo http://www.programcreek.com/java-api-examples/index.php?source_dir=h ...
- wireshark基础学习—第四部分wireshark过滤器总结
这两天一直在熟悉wireshark的过滤器语法规则,以前也接触过这个工具,但只是学校老师教的如何去选择一个接口进行抓取,以及如何去分析一个包的数据.可惜当时对此也没有过多深入.对于我当前,并未接触太多 ...
- CPU高的排查
之前有朋友反馈说发的内容希望有个梯度,逐步加深,前面发了几篇关于jvm源码分析的文章,可能我觉得我已经把内容写得浅显易懂了,但是对于某些没怎么接触的同学来说还是比较难理解,这个我以后慢慢改进吧,今天发 ...
- 51nod 1405 树的距离之和 树形dp
1405 树的距离之和 基准时间限制:1 秒 空间限制:131072 KB 收藏 关注 给定一棵无根树,假设它有n个节点,节点编号从1到n, 求任意两点之间的距离(最短路径)之和. Input ...