15,979
社区成员
发帖
与我相关
我的任务
分享
void CBkDashboardDlg::DrawLeds(int index, BOOL bright)
{
CRect rcClient;
GetWindowRect(&rcClient);
CRect rc = m_rcLedsArry[index];
//ClientToScreen(rc);
//ClientToScreen(&rcClient);
HDC dc =::GetDC(m_hWnd);
CDC memDc;
memDc.CreateCompatibleDC(dc);
int nWidth = rcClient.Width();
int nHeight = rcClient.Height();
m_bmpInfo.bmiHeader.biWidth = nWidth; // bmp宽度,单位像素
m_bmpInfo.bmiHeader.biHeight = nHeight;
HBITMAP hBitMap =
::CreateDIBSection(
memDc,
&m_bmpInfo,
DIB_RGB_COLORS,
NULL,
NULL,
0);
HBITMAP hOldBmp = memDc.SelectBitmap(hBitMap);
Graphics graph(memDc.m_hDC);
int nImageIndex = bright?index+ICONS_NUM:index;
graph.DrawImage(m_pLedsImageArry[nImageIndex], 0, 0, nWidth, nHeight);
SIZE sz = {rcClient.Width(), rcClient.Height()};
// UpdateLayeredWindowIndirect
UPDATELAYEREDWINDOWINFO updateinfo = {0};
updateinfo.cbSize = sizeof(UPDATELAYEREDWINDOWINFO);
updateinfo.pptDst = &CPoint(rcClient.left, rcClient.top);
SIZE szz = {rcClient.Width(), rcClient.Height()};
updateinfo.psize = &szz;
updateinfo.hdcSrc = memDc.m_hDC;
//updateinfo.dwFlags = ULW_ALPHA;
updateinfo.hdcDst = dc;
updateinfo.pblend = &m_blend;
updateinfo.pptSrc = &CPoint(0, 0);
//ScreenToClient(rc);
RECT rcDirty = {rc.left, rc.top,rc.right, rc.bottom};
updateinfo.prcDirty = &rcDirty;
//UpdateLayeredWindow(m_hWnd, dc, &CPoint(rcClient.left, rcClient.top), &sz, memDc,
// &CPoint( rc.left, rc.top), 0, &m_blend, ULW_ALPHA);
UpdateLayeredWindowIndirect(m_hWnd, &updateinfo);
DWORD db = GetLastError();
if (hOldBmp)
memDc.SelectBitmap(hOldBmp);
DeleteObject(hBitMap);
graph.ReleaseHDC(memDc.m_hDC);
memDc.DeleteDC();
ReleaseDC(dc);
}
在分层窗口中说这个UpdateLayeredWindowIndirect函数可以局部更新但是我怎么搞都没办法啊,