Windows Mobile 使用GDI实现BUTTON效果
2010-08-23 05:19:00 来源:WEB开发网{
rc[m_nCurrentCount] = rc;
}
void MyButton::InitButtonImage(HWND hWnd)
{
HDC hdc = GetDC(hWnd);
// 利用双缓冲绘图
for(int n = 0; n < m_nCurrentCount; n ++)
{
HDC hMemDc = CreateCompatibleDC(hdc);
HBITMAP hOldBmp = (HBITMAP)SelectObject(hMemDc, hDownBitmap[m_nCurrentCount]);
BITMAP bm;
GetObject(hDownBitmap[m_nCurrentCount], sizeof(bm), &bm);
StretchBlt(hdc, rc[m_nCurrentCount].left, rc[m_nCurrentCount].top, rc[m_nCurrentCount].right - rc[m_nCurrentCount].left, rc[m_nCurrentCount].bottom - rc[m_nCurrentCount].top, &dcSrc, 0, 0, nWidthOld, nHeightOld, SRCCOPY);
BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hMemDc, 0, 0, SRCCOPY);
SelectObject(hMemDc, hOldBmp);
DeleteDC(hMemDc);
}
}
void MyButton::InitButtonImage(HWND hWnd)
{
HDC hdc = GetDC(hWnd);
// 利用双缓冲绘图
for(int n = 0; n < m_nCurrentCount; n ++)
{
HDC hMemDc = CreateCompatibleDC(hdc);
HBITMAP hOldBmp = (HBITMAP)SelectObject(hMemDc, hDownBitmap[m_nCurrentCount]);
BITMAP bm;
GetObject(hDownBitmap[m_nCurrentCount], sizeof(bm), &bm);
StretchBlt(hdc, rc[m_nCurrentCount].left, rc[m_nCurrentCount].top, rc[m_nCurrentCount].right - rc[m_nCurrentCount].left, rc[m_nCurrentCount].bottom - rc[m_nCurrentCount].top, &dcSrc, 0, 0, nWidthOld, nHeightOld, SRCCOPY);
SelectObject(hMemDc, hOldBmp);
DeleteDC(hMemDc);
}
}
void MyButton::SetUpButtonImage(HWND hWnd, int nSel)
{
HDC hdc = GetDC(hWnd);
CRect rcSel;
rcSel = rc[nSel];
m_nPreSel = nSel;
// 利用双缓冲绘图
HDC hMemDc = CreateCompatibleDC(hdc);
更多精彩
赞助商链接