Set Windows window translucency (using SetLayeredWindowAttributes API functions)

Source: Internet
Author: User

Required function Prototypes: BOOL WINAPI SetLayeredWindowAttributes (HWND hwnd, Colorrefcrkey, BYTE Balpha, DWORD flag);
Parameter meaning:
HWnd: The handle of the window to be set.
Flag: Transparent mode, two values are desirable: Lwa_colorkey (whose value is defined as 0x1) and Lwa_alpha (whose value is defined as 0x2). The combination of the two is desirable.
Crkey: Mask color, when the flag value is Lwa_colorkey, the place where the color value in the window is equal to Crkey becomes fully transparent. Otherwise, this parameter is not valid.
Balpha: The transparency of the window, the value range 0~255. Valid when flag contains the Lwa_alpha logo.

Calling Methods in MFC: SetLayeredWindowAttributes (M_hwnd, RGB (0, 0, 0), $, 0x1 | 0x2);

Note that in VC6.0, the header file does not have the declaration of this function, so you can only load the DLL module containing this function in the following way, and then look for the function entry address and then call it.
Hmodule hInst = LoadLibrary ("user32.dll");
if (hInst)
{
typedef BOOL (Winpai*setalpha) (HWND, COLORREF, BYTE, DWORD); Defining function pointer types
Setalpha Setalpha = (setalpha) GetProcAddress (HInst, "setlayeredwindowattributes");
if (Setalpha)
Setalpha (m_hwnd, RGB (0, 0, 0), $, 0x1 | 0x2);

FreeLibrary (HInst);
}

http://blog.csdn.net/yjwffgip456/article/details/43968247

Set Windows window translucency (using SetLayeredWindowAttributes API functions)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.