小编jtu*_*ney的帖子

绘制一个标准框架和透明内容的窗口

对于xtow,我想绘制一个顶级窗口,其中包含标准的非客户区域,客户区域填充了一个具有alpha通道的位图.

我现在发现我在Windows 7上实现此方法的方法,但在Windows 8.1上无法正确呈现,在移动或最大化时留下窗口内容的图像.

为了调查,我做了一个简单的测试程序alpha测试,其中

  • 使用DwmEnableBlurBehindWindow()设置非交叉模糊区域,以便窗口中的alpha值得到尊重,而不会模糊.
  • 使用BitBlt()将带有alpha的位图复制到其中.
//
// g++ alpha-test.cc -o alpha-test -mwindows -lgdiplus -ldwmapi
//

#define  _WIN32_WINNT 0x0600

#include <assert.h>
#include <stdio.h>
#include <windows.h>
#include <gdiplus.h>
#include <dwmapi.h>

int width = 360;
int height = 360;
HBITMAP hBitmap;

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  switch (message)
    {
    case WM_PAINT:
      {
        PAINTSTRUCT ps;
        HDC hdcUpdate = BeginPaint(hWnd, &ps);

        RECT rc;
        GetClientRect(hWnd, &rc);
        HBRUSH hbrush = CreateSolidBrush(RGB(0,0,0));
        FillRect(hdcUpdate, &rc, hbrush);
        DeleteObject(hbrush); …
Run Code Online (Sandbox Code Playgroud)

windows winapi

7
推荐指数
1
解决办法
563
查看次数

标签 统计

winapi ×1

windows ×1