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的更多相关文章

  1. Serial Port Programming using Win32 API(转载)

    In this tutorial we will learn How to communicate with an external device like a microcontroller boa ...

  2. How to change windows applicatioin's position via Win32 API

    可以使用的Win32 API是: [DllImport("user32.dll")] private extern static bool SetWindowPos(IntPtr ...

  3. WIN32 API ------ 最简单的Windows窗口封装类

    1 开发语言抉择 1.1 关于开发Win32 程序的语言选择 C还是C++ 在决定抛弃MFC,而使用纯Win32 API 开发Window桌面程序之后,还存在一个语言的选择,这就是是否使用C++.C+ ...

  4. 使用Win32 API创建不规则形状&带透明色的窗口

    前一阵突然想起了9月份电面某公司实习时的二面题,大概就是说怎么用Win32 API实现一个透明的窗口,估计当时我的脑残答案肯定让面试官哭笑不得吧.所以本人决定好好研究下这个问题.经过一下午的摸索,基本 ...

  5. 初次认识 C# win32 api

    第一次接触win32api,刚开始的时候有点迷迷糊糊的. Windows API 就是windows应用程序接口. win api向上就是windows应用程序,向下就是windows操作系统核心. ...

  6. 【温故Delphi】GAEA用到Win32 API目录

    Delphi是Windows平台下著名的快速应用程序开发工具,它在VCL中封装并使用了大量的Win32 API. GAEA基于VCL开发的工具类产品,在程序中使用了大量的Win32 API,将经常用到 ...

  7. 【C#】分享基于Win32 API的服务操作类(解决ManagedInstallerClass.InstallHelper不能带参数安装的问题)

    注:这里的服务是指Windows 服务. ------------------201508250915更新------------------ 刚刚得知TransactedInstaller类是支持带 ...

  8. C#中导入Win32 API函数

    C#中导入Win32 API的方法: 1.引用命名空间 using System.Net.Security; using System.Runtime.InteropServices; 2. [Dll ...

  9. C#调用Win32 api学习总结

    从.NET平台调用Win32 API Win32 API可以直接控制Microsoft Windows的核心,因为API(Application Programming Interface)本来就是微 ...

随机推荐

  1. FIT2096 Assignment 2 2019

    FIT2096 Assignment 2 2019_v1.2.docx 9/04/2019 11:34 AMPage 1 | 4FIT2096 Assignment 2 2019Transformat ...

  2. tcp的三次握手,四次挥手

    为了更好的记住知识点,所以将最近学习的知识点记录下来: 最开始A和B都处于closed(关闭连接状态) 1.tcp的第一次握手:客户端A  向服务器端B 发送请求连接报文段(包含SYN=1,初始序号s ...

  3. [系统相关]WPS Office 2016 专业增强版 10.8.0.6470 免序列号无限制

    WPS Office (10.8.0.6470)  新增功能列表 ============================================= 改进功能列表 ------------ W ...

  4. 2019 年 SpreadJS产品路线图(Roadmap)

    前言 | 问题背景 SpreadJS已经发展成为市场上最好的纯前端JavaScript电子表格之一,但对于用户的需要和产品功能的改善,我们才刚刚开始! 在过去的一年中,我们发布了两个Service P ...

  5. ASP.NET MVC 访问静态文件

    When use asp.net MVC, we can add a special route to access the image files. the code like below: 1. ...

  6. C语言--第3次作业

    1.本章学习总结 1.1思维导图 1.2 本章学习体会及代码量学习体会 1.2.1学习体会 我眼中的函数 这一章接触到了新的知识--函数,不同于之前所学的编程,函数具有很清楚的分工性,且可以用来多次调 ...

  7. Vue-admin工作整理(四):路由组件传参

    路由组件传参:如果在一个页面中,需要根据路由去获得参数,去对页面进行一些逻辑处理,首先可以通过this.$router来获取路由实例的参数,这样页面组件和路由就进行了耦合,为了进行分离,更大程度复用, ...

  8. [Linux]ubuntu安装基本流程

    ubuntu安装基本流程 1.设置分辨率2.设置语言环境3.设置服务器镜像源4.添加终端5.apt.apt-get更新和升级系统软件 sudo apt update/upgrade sudo apt- ...

  9. printf打印输出

    int PrintVal = 9;    /*按整型输出,默认右对齐*/    printf("%d\n",PrintVal);    /*按整型输出,补齐4位的宽度,补齐位为空格 ...

  10. python爬虫采集网站数据

    1.准备工作: 1.1安装requests: cmd >> pip install requests 1.2 安装lxml: cmd >>  pip install lxml ...