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. zeros()和ones()和eye()

    python--zeros函数和ones函数 使用numpy.zeros,numpy.ones,numpy.eye等方法可以构造特定的矩阵 >>>from numpy import ...

  2. Vue学习——使用vue-cli搭建一个简单的本地vue项目

    前提 安装好node.js.npm.vue-cli.为什么要先安装这些,建议查看https://www.cnblogs.com/jixue/p/10673875.html,这个对于vue-cli理解很 ...

  3. mpvue小程序开发tips(1)

    wx.setStorageSync('vipId',vipId)-----存储   wx.getStorageSync('vipId')-------读取   wx.navigateTo({ url: ...

  4. 机器学习实战(笔记)------------KNN算法

    1.KNN算法 KNN算法即K-临近算法,采用测量不同特征值之间的距离的方法进行分类. 以二维情况举例:         假设一条样本含有两个特征.将这两种特征进行数值化,我们就可以假设这两种特种分别 ...

  5. Ubuntu 14.04 安装 sysrepo v0.7.5

    参考: Tentative gNMI support with sysrepo protobuf-c/protobuf-c Ubuntu 14.04 安装 sysrepo v0.7.5 安装依赖: s ...

  6. Lintcode85-Insert Node in a Binary Search Tree-Easy

    85. Insert Node in a Binary Search Tree Given a binary search tree and a new tree node, insert the n ...

  7. python笔记---@classmethod @staticmethod

    python定义类方法的三种方式: 1.常规方式--需要通过self参数隐式的传递当前类对象的实例 2.@classmethod修饰方式--@classmethod修饰的方法class_foo()需要 ...

  8. NetSec2019 20165327 exp1+ 逆向进阶

    NetSec2019 20165327 exp1+ 一.实验内容介绍 第一个实践是在非常简单的一个预设条件下完成的: (1)关闭堆栈保护 (2)关闭堆栈执行保护 (3)关闭地址随机化 (4)在x32环 ...

  9. 《Professional JavaScript for Web Developers》day01

    <professional JavaScript for Web Developers>day01 1.JavaScript简介 1.1JavaScript简史:略 1.2JavaScri ...

  10. Python 进度条原理

    #进度条原理 import sys,time for i in range(50): sys.stdout.write("#")#标准输出 #若不能够按照时间一个一个依次显示,则代 ...