2 sunnyli3166 sunnyli3166 于 2014.12.15 09:19 提问

MFC绘图撤销问题 急急急!

各位,帮忙看下啊。。我在MFC单文档中实现透明桌面和白色背景绘图2中模式。现在有个问题是透明桌面时,撤销与返回程序执行但是没效果?、调试时显示OK,就是直接运行时没效果啊?/急急急!

void CMainFrame::OnPizhu()
{
// TODO: Add your command handler code here

CMainFrame* frm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CHDrawView* pView=(CHDrawView*)frm->GetActiveView();
CHDrawDoc* pDoc=(CHDrawDoc*)frm->GetActiveDocument();   
pDoc->OnDrawClear();
pDoc->DeleteContents();
if(DeleteAll("C:\\Windows\\Temp3\\"))
{
    pDoc->m_backup.RemoveAll();
}
else
    AfxMessageBox("ERROR");

pDoc->m_picType = PIC_poly;
pDoc->m_picColor = RGB(0,0,0);
pDoc->m_picWidth = 1;
pDoc->m_picStyle = PS_SOLID;
pDoc->m_cavasH = 1000;
pDoc->m_cavasW =1500;

pDoc->m_backup_index =0;
pDoc->BackUp();

Width   = GetSystemMetrics(SM_CXSCREEN);    
Heigth  = GetSystemMetrics(SM_CYSCREEN);
MoveWindow(40,50,Width-100,Heigth-100);
ShowWindow(SW_HIDE);
Sleep(100);
ShowWindow(SW_SHOW);
CWnd*  wnd = GetDesktopWindow();  
CWindowDC cdc(wnd);  
memdc.CreateCompatibleDC(&cdc);  
btmp.CreateCompatibleBitmap(&cdc, Width, Heigth); 
memdc.BitBlt(0,0, Width,  Heigth, &cdc, 0, 0, SRCCOPY); 
ShowWindow(SW_SHOW);
pView->flags=2;

void CMainFrame::OnUndo()
{
CMainFrame* frm=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CHDrawDoc* pDoc=(CHDrawDoc*)frm->GetActiveDocument();

pDoc->OnEditUndo();
pDoc->UpdateAllViews(NULL);
}

void CHDrawView::OnDraw(CDC* pDC)

{
CHDrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here

OnPrepareDC(pDC);
if(flags==1)
{
    CClientDC dc(this);
    CRect   rect;  
    GetClientRect(&rect);     //得到窗体的大小  
    CDC   dcMem;    
    dcMem.CreateCompatibleDC(&dc);    
    CBitmap   bmpBackground;  
    bmpBackground.LoadBitmap(IDB_BITMAP2);//加载背景图片

    BITMAP   bitMap;  
    bmpBackground.GetBitmap(&bitMap);  
    CBitmap   *pbmpOld=dcMem.SelectObject(&bmpBackground);  
    dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY); 

void CHDrawDoc::ReStore(BOOL backward)

{
m_backup_index -= backward ? 1 : -1;
//make m_backup[m_backup_index] the current document data
int num=m_backup.GetSize();
if((m_backup_indexm_backup.GetSize())
{
MessageBox(NULL,"操作错误","Warning",MB_OK|MB_ICONWARNING);
}

else
{
    OnOpenDocument(m_backup.GetAt(m_backup_index-1));
}

}

1个回答

devmiao
devmiao   Ds   Rxr 2014.12.15 15:01
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!