Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

透明窗口:UpdateLayeredWindow failed, error code is 317 #3

Open
suhao opened this issue Apr 22, 2019 · 0 comments
Open

透明窗口:UpdateLayeredWindow failed, error code is 317 #3

suhao opened this issue Apr 22, 2019 · 0 comments

Comments

@suhao
Copy link
Member

suhao commented Apr 22, 2019

原因:

  1. 大小不一样
  2. 电脑开启了16位增强色

电脑开启16位增强色解决办法

::UpdateLayeredWindow的源位图应该使用独立位图,而不是兼容位图

# 创建独立位图:

BITMAPINFO bmi;
memset(&bmi, 0, sizeof(bmi));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height; // top-down image
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 32;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
BYTE* lpBitmapBits = NULL;
m_hbmpOffscreen = ::CreateDIBSection(m_hDcOffscreen, &bmi, DIB_RGB_COLORS, (LPVOID*)&lpBitmapBits, NULL, 0);

# 创建兼容位图:
m_hbmpOffscreen = ::CreateCompatibleBitmap(hdc, width, height);

触发16位增强色

屏幕右键--个性化--左下角--显示--左上角--更改显示器设置--右边中部--高级设置--监示器--下方--颜色--有真彩色32位和增强色16位选择

高级设置
监视器

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant