在窗口大小变化时,让位图区域外重绘。 不属于怪问题。 谢谢!
代码:http://www.yanglihao.com/filesUploaded/displayViaGDIView.cpp工程压缩包:http://www.yangl...
代码:http://www.yanglihao.com/filesUploaded/displayViaGDIView.cpp
工程压缩包:http://www.yanglihao.com/filesUploaded/displayViaGDI.rar
void CdisplayViaGDIView::OnDrawBegin()
{
// TODO: Add your command handler code here
if ( MemDC == NULL )
{
createDC(m_pDC);
}
CBrush brush(RGB(0,255,0));
MemDC.SelectObject(&brush);
MemDC.Rectangle(0,0,100,100);
Invalidate();
}
void CdisplayViaGDIView::drawTest(char* Text, int i, DWORD colorref)
{
if ( MemDC == NULL )
{
createDC(m_pDC);
}
int len = strlen(Text);
CFont font;
//CClientDC dc(this);
//MemDC.CreateCompatibleDC(&dc);
CBrush brushA(RGB(0,200,58));
CBrush brushB(RGB(200,0,233));
MemDC.SelectObject(brushA);
font.CreateFont(WIDTH, WIDTH, 0, 0, 150, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, NULL);
MemDC.SelectObject(&font);
MemDC.SetTextColor(colorref);
MemDC.TextOutW(0, yIncreat, CString(Text), strlen(Text));
MemDC.SetTextColor(RGB(200,0,233));
MemDC.TextOutW(i*WIDTH, yIncreat, CString(Text[i]), 1);
yIncreat += WIDTH;
Invalidate();
}
void CdisplayViaGDIView::drawKMP(char *Text, char *Pattern, int i, int j, DWORD colorref)
{
drawTest(Text, i, colorref);
drawTest(Pattern, j, colorref);
}
void CdisplayViaGDIView::OnDrawKmp()
{
// TODO: Add your command handler code here
KMP KMPInstence;
KMPInstence.m_displayViaGDIView = this;
KMPInstence.search("aaaaaaaaaaaabaaaaaaaaaaaaaaaaaaabaaaaaaabcaab", "aaaaaaabc");
}
void CdisplayViaGDIView::createDC(CDC* pdc)
{
bitmap.CreateCompatibleBitmap(pdc, 1000, 3000);
MemDC.CreateCompatibleDC(pdc);
pOldBmp = MemDC.SelectObject(&bitmap);
MemDC.FillSolidRect(0,0,1000,3000,RGB(255,255,255));
pdc->BitBlt(0,0,1000,3000, &MemDC,0,0,SRCCOPY);
}
void CdisplayViaGDIView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
OnDraw(GetDC());
}
我QQ:459281182
我按你的改了,还是不行。 展开
工程压缩包:http://www.yanglihao.com/filesUploaded/displayViaGDI.rar
void CdisplayViaGDIView::OnDrawBegin()
{
// TODO: Add your command handler code here
if ( MemDC == NULL )
{
createDC(m_pDC);
}
CBrush brush(RGB(0,255,0));
MemDC.SelectObject(&brush);
MemDC.Rectangle(0,0,100,100);
Invalidate();
}
void CdisplayViaGDIView::drawTest(char* Text, int i, DWORD colorref)
{
if ( MemDC == NULL )
{
createDC(m_pDC);
}
int len = strlen(Text);
CFont font;
//CClientDC dc(this);
//MemDC.CreateCompatibleDC(&dc);
CBrush brushA(RGB(0,200,58));
CBrush brushB(RGB(200,0,233));
MemDC.SelectObject(brushA);
font.CreateFont(WIDTH, WIDTH, 0, 0, 150, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, NULL);
MemDC.SelectObject(&font);
MemDC.SetTextColor(colorref);
MemDC.TextOutW(0, yIncreat, CString(Text), strlen(Text));
MemDC.SetTextColor(RGB(200,0,233));
MemDC.TextOutW(i*WIDTH, yIncreat, CString(Text[i]), 1);
yIncreat += WIDTH;
Invalidate();
}
void CdisplayViaGDIView::drawKMP(char *Text, char *Pattern, int i, int j, DWORD colorref)
{
drawTest(Text, i, colorref);
drawTest(Pattern, j, colorref);
}
void CdisplayViaGDIView::OnDrawKmp()
{
// TODO: Add your command handler code here
KMP KMPInstence;
KMPInstence.m_displayViaGDIView = this;
KMPInstence.search("aaaaaaaaaaaabaaaaaaaaaaaaaaaaaaabaaaaaaabcaab", "aaaaaaabc");
}
void CdisplayViaGDIView::createDC(CDC* pdc)
{
bitmap.CreateCompatibleBitmap(pdc, 1000, 3000);
MemDC.CreateCompatibleDC(pdc);
pOldBmp = MemDC.SelectObject(&bitmap);
MemDC.FillSolidRect(0,0,1000,3000,RGB(255,255,255));
pdc->BitBlt(0,0,1000,3000, &MemDC,0,0,SRCCOPY);
}
void CdisplayViaGDIView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
OnDraw(GetDC());
}
我QQ:459281182
我按你的改了,还是不行。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询