English 中文(简体)
我利用C++and WinAPI创建了一个窗口,并使用更新的LayeredWindow功能,但我无法理解对窗户的沥青有何控制。
原标题:I created a window using C++and WinAPI and used the UpdateLayeredWindow function, but I cannot understand what controls the alpha of the window

该法典使用了《最新消息》。

HDC hdc = GetWindowDC(hWnd);
int width = 400;
int height = 300;
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);

HDC hdcMem = CreateCompatibleDC(hdc);
SelectObject(hdcMem, hBitmap);


BLENDFUNCTION blend = { 0 };
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.AlphaFormat = AC_SRC_ALPHA;
blend.SourceConstantAlpha = 255; 

RECT rcClient;
GetClientRect(hWnd, &rcClient);
HBRUSH brush = CreateSolidBrush(RGB(128, 128, 128));
FillRect(hdcMem, &rcClient,brush);
POINT ptDst = { 0, 0 };
SIZE sizeWnd = { width, height };
POINT ptSrc = { 0, 0 };
UpdateLayeredWindow(hWnd, hdc, NULL, &sizeWnd, hdcMem, &ptSrc, 0, &blend, ULW_ALPHA);

// 释放资源
DeleteDC(hdcMem);
DeleteObject(hBitmap);
ReleaseDC(hWnd, hdc);

In my opinion, this window should be completely opaque, with a SourceConstantAlpha value of 255 for blend, but in reality, it is semi transparent. It looks like this enter image description here But when i use RGB(255, 255, 255),it s completely opaque.And When i use RGB(0, 0, 0),it s compltely transparent. It seems that the RGB of brush affects transparency.I can t understand how the aplha blend.

我试图修改《刑法》和《刑法》。 两者都对甲型六氯环己烷的价值产生影响。 我已经咨询了温和会的文件。 表格为Dst.Alpha = Src.Alpha + (1 - Src.Alpha) * Dst.Alpha。 看来,如果来源商法为255,那么窗户就应该 op,但不是这样。 这对我来说非常令人困惑。 我想知道甲型肝脏如何。

问题回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签