📄 dib.cpp
字号:
return DisplayFadeIn(pDC, x, y, nDeta, dwDelayTime);
else if (nEffect == EFFECT_MOSAIC)
return DisplayMosaicIn(pDC, x, y, nDeta, dwDelayTime, dwRop);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap* pOldBmp = MemDC.SelectObject(m_pBitmap);
CPalette* pOldPal = pDC->SelectPalette(m_pPalette, TRUE);
pDC->RealizePalette();
LONG i = 0;
BOOL bDone = FALSE;
while (! bDone)
{
switch (nEffect)
{
case EFFECT_SCANDOWN:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x,
y+i,
GetWidth(),
nDeta,
&MemDC,
0,
i,
dwRop);
i += nDeta;
break;
case EFFECT_SCANUP:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x,
y+GetHeight()-i,
GetWidth(),
nDeta,
&MemDC,
0,
GetHeight()-i,
dwRop);
i += nDeta;
break;
case EFFECT_SCANRIGHT:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x+i,
y,
nDeta,
GetHeight(),
&MemDC,
i,
0,
dwRop);
i += nDeta;
break;
case EFFECT_SCANLEFT:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x+GetWidth()-i,
y,
nDeta,
GetHeight(),
&MemDC,
GetWidth()-i,
0,
dwRop);
i += nDeta;
break;
case EFFECT_VSPLITSCAN:
if (i > GetHeight()/2)
{
i = GetHeight()/2;
bDone = TRUE;
}
pDC->BitBlt(x,
y+i,
GetWidth(),
nDeta,
&MemDC,
0,
i,
dwRop);
pDC->BitBlt(x,
y+GetHeight()-i,
GetWidth(),
i,
&MemDC,
0,
GetHeight()-i,
dwRop);
i += nDeta;
break;
case EFFECT_HSPLITSCAN:
if (i > GetWidth()/2)
{
i = GetWidth()/2;
bDone = TRUE;
}
pDC->BitBlt(x+i,
y,
nDeta,
GetHeight(),
&MemDC,
i,
0,
dwRop);
pDC->BitBlt(x+GetWidth()-i,
y,
nDeta,
GetHeight(),
&MemDC,
GetWidth()-i,
0,
dwRop);
i += nDeta;
break;
case EFFECT_MOVEDOWN:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x,
y,
GetWidth(),
i+nDeta,
&MemDC,
0,
GetHeight()-i,
dwRop);
i += nDeta;
break;
case EFFECT_MOVEUP:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x,
y+GetHeight()-i,
GetWidth(),
i,
&MemDC,
0,
0,
dwRop);
i += nDeta;
break;
case EFFECT_MOVERIGHT:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x,
y,
i+nDeta,
GetHeight(),
&MemDC,
GetWidth()-i,
0,
dwRop);
i += nDeta;
break;
case EFFECT_MOVELEFT:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x+GetWidth()-i,
y,
i,
GetHeight(),
&MemDC,
0,
0,
dwRop);
i += nDeta;
break;
case EFFECT_VSPLITMOVE:
if (i > GetHeight()/2)
{
i = GetHeight()/2;
bDone = TRUE;
}
pDC->BitBlt(x,
y,
GetWidth(),
i+nDeta,
&MemDC,
0,
GetHeight()/2-i,
dwRop);
pDC->BitBlt(x,
y+GetHeight()-i,
GetWidth(),
i,
&MemDC,
0,
GetHeight()/2,
dwRop);
i += nDeta;
break;
case EFFECT_HSPLITMOVE:
if (i > GetWidth()/2)
{
i = GetWidth()/2;
bDone = TRUE;
}
pDC->BitBlt(x,
y,
i+nDeta,
GetHeight(),
&MemDC,
GetWidth()/2-i,
0,
dwRop);
pDC->BitBlt(x+GetWidth()-i,
y,
i,
GetHeight(),
&MemDC,
GetWidth()/2,
0,
dwRop);
i += nDeta;
break;
case EFFECT_VCROSSMOVE:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x,
y,
GetWidth()/2,
i+nDeta,
&MemDC,
0,
GetHeight()-i,
dwRop);
pDC->BitBlt(x+GetWidth()/2,
y+GetHeight()-i,
GetWidth(),
i,
&MemDC,
GetWidth()/2,
0,
dwRop);
i += nDeta;
break;
case EFFECT_HCROSSMOVE:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x,
y,
i+nDeta,
GetHeight()/2,
&MemDC,
GetWidth()-i,
0,
dwRop);
pDC->BitBlt(x+GetWidth()-i,
y+GetHeight()/2,
i,
GetHeight()/2,
&MemDC,
0,
GetHeight()/2,
dwRop);
i += nDeta;
break;
case EFFECT_VRASTER:
{
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
LONG j = 0;
BOOL bQuitLoop = FALSE;
while (! bQuitLoop)
{
if (j > GetWidth())
{
j = GetWidth();
bQuitLoop = TRUE;
}
pDC->BitBlt(x+j,
y,
nDeta,
i+1,
&MemDC,
j,
GetHeight()-i,
dwRop);
j += nDeta;
if (j > GetWidth())
{
j = GetWidth();
bQuitLoop = TRUE;
}
pDC->BitBlt(x+j,
y+GetHeight()-i,
nDeta,
i,
&MemDC,
j,
0,
dwRop);
j += nDeta;
}
i++;
break;
}
case EFFECT_HRASTER:
{
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
LONG j = 0;
BOOL bQuitLoop = FALSE;
while (! bQuitLoop)
{
if (j > GetHeight())
{
j = GetHeight();
bQuitLoop = TRUE;
}
pDC->BitBlt(x,
y+j,
i+1,
nDeta,
&MemDC,
GetWidth()-i,
j,
dwRop);
j += nDeta;
if (j > GetHeight())
{
j = GetHeight();
bQuitLoop = TRUE;
}
pDC->BitBlt(x+GetWidth()-i,
y+j,
i,
nDeta,
&MemDC,
0,
j,
dwRop);
j += nDeta;
}
i++;
break;
}
case EFFECT_HBLIND:
{
if (i > nDeta)
{
i = nDeta;
bDone = TRUE;
}
for (LONG j=i; j<GetHeight(); j+=nDeta)
pDC->BitBlt(x,
y+j,
GetWidth(),
1,
&MemDC,
0,
j,
dwRop);
i++;
break;
}
case EFFECT_VBLIND:
if (i > nDeta)
{
i = nDeta;
bDone = TRUE;
}
for (LONG j=i; j<GetWidth(); j+=nDeta)
pDC->BitBlt(x+j,
y,
1,
GetHeight(),
&MemDC,
j,
0,
dwRop);
i++;
break;
} // end of switch
//Delay(dwDelayTime);
} // end of while
MemDC.SelectObject(pOldBmp);
pDC->SelectPalette(pOldPal, TRUE);
return TRUE;
}
BOOL CDib::Clear(int nEffect, CDC* pDC, int x, int y, int nDeta, DWORD dwDelayTime)
{
if (nEffect == EFFECT_FADE)
return DisplayFadeOut(pDC, x, y, nDeta, dwDelayTime);
else if (nEffect == EFFECT_MOSAIC)
return DisplayMosaicOut(pDC, x, y, nDeta, dwDelayTime);
CDC MemDC;
MemDC.CreateCompatibleDC(pDC);
CBitmap* pOldBmp = MemDC.SelectObject(m_pBitmap);
CPalette* pOldPal = pDC->SelectPalette(m_pPalette, TRUE);
pDC->RealizePalette();
pDC->BitBlt(x,
y,
GetWidth(),
GetHeight(),
&MemDC,
0,
0,
SRCCOPY);
CBrush brush(GetSysColor(COLOR_WINDOW));
CBrush* oldbrush = pDC->SelectObject(&brush);
CPen pen(PS_SOLID,1,GetSysColor(COLOR_WINDOW));
CPen* oldpen = pDC->SelectObject(&pen);
LONG i = 0;
BOOL bDone = FALSE;
while (! bDone)
{
switch (nEffect)
{
case EFFECT_SCANDOWN:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->Rectangle(x,
y+i,
x+GetWidth(),
y+nDeta);
i += nDeta;
break;
case EFFECT_SCANUP:
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->Rectangle(x,
y+GetHeight()-i,
x+GetWidth(),
y+GetHeight()-i+nDeta);
i += nDeta;
break;
case EFFECT_SCANRIGHT:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->Rectangle(x+i,
y,
x+nDeta,
y+GetHeight());
i += nDeta;
break;
case EFFECT_SCANLEFT:
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->Rectangle(x+GetWidth()-i,
y,
x+GetWidth()-i+nDeta,
y+GetHeight());
i += nDeta;
break;
case EFFECT_VSPLITSCAN:
if (i > GetHeight()/2)
{
i = GetHeight()/2;
bDone = TRUE;
}
pDC->Rectangle(x,
y+i,
x+GetWidth(),
y+i+nDeta);
pDC->Rectangle(x,
y+GetHeight()-i,
x+GetWidth(),
y+GetHeight());
i += nDeta;
break;
case EFFECT_HSPLITSCAN:
if (i > GetWidth()/2)
{
i = GetWidth()/2;
bDone = TRUE;
}
pDC->Rectangle(x+i,
y,
x+i+nDeta,
y+GetHeight());
pDC->Rectangle(x+GetWidth()-i,
y,
x+GetWidth(),
y+GetHeight());
i += nDeta;
break;
case EFFECT_MOVEDOWN:
{
i += nDeta;
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x, //x dest
y+i, //y dest
GetWidth(), //width
GetHeight()-i, //depth
&MemDC,
0, //x source
0, //y source
SRCCOPY);
pDC->Rectangle(x, y+i-nDeta,
x+GetWidth(), y+i);
break;
}
case EFFECT_MOVEUP:
{
i += nDeta;
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x, //x dest
y, //y dest
GetWidth(), //width
GetHeight()-i, //depth
&MemDC,
0, //x source
i, //y source
SRCCOPY);
pDC->Rectangle( x,
y+GetHeight()-i,
x+GetWidth(),
y+GetHeight());
break;
}
case EFFECT_MOVERIGHT:
{
i += nDeta;
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x+i, //x dest
y, //y dest
GetWidth()-i, //width
GetHeight(), //depth
&MemDC,
0, //x source
0, //y source
SRCCOPY);
pDC->Rectangle(x+i-nDeta, y,
x+i, y+GetHeight());
break;
}
case EFFECT_MOVELEFT:
{
i += nDeta;
if (i > GetWidth())
{
i = GetWidth();
bDone = TRUE;
}
pDC->BitBlt(x, //x dest
y, //y dest
GetWidth()-i, //width
GetHeight(), //depth
&MemDC,
i, //y source
0, //x source
SRCCOPY);
pDC->Rectangle( x+GetWidth()-i,
y,
x+GetWidth(),
y+GetHeight());
break;
}
case EFFECT_VCROSSMOVE:
{
i += nDeta;
if (i > GetHeight())
{
i = GetHeight();
bDone = TRUE;
}
pDC->BitBlt(x, //x dest
y+i, //y dest
GetWidth()/2, //width
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -