我的c++在picture控制元件區域用了雙緩沖之后,點擊按鈕無法彈出子對話框,而且主對話框也沒有反應

這是剛運行之后出現的界面,沒有寫子對話框的按鈕都可以實作

這是點擊了“圓形”按鈕,也就是級聯了一個子對話框的按鈕之后的界面,主對話框沒有反應,不能移動也不能關閉

但后來發現在資源管理器關閉主對話框,或者點擊鍵盤上的Alt之后子對話框就可以彈出來了
這是我的代碼
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyShapeDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
// CDialog::OnPaint();
CRect rect;
CDC *pDC=GetDlgItem(IDC_PICTURE)->GetDC();
GetDlgItem(IDC_PICTURE)->GetClientRect(&rect);
CPen pen(PS_SOLID,1,RGB(255,0,0));
//使用雙緩沖技術
CDC dcMem; //記憶體DC
CBitmap bmpMem; //位圖
dcMem.CreateCompatibleDC(pDC); //創建兼容DC
dcMem.SelectObject(pen);
bmpMem.CreateCompatibleBitmap(pDC,rect.right-rect.left,rect.bottom-rect.top); //創建和picture區域一樣大小的(空)位圖
//把位圖選到設備背景關系的環境中
CBitmap *pOld=dcMem.SelectObject(&bmpMem);
dcMem.FillSolidRect(rect,pDC->GetBkColor());
//內置圓
CRect rect1=new CRect(0,0,80,80);
dcMem.Ellipse(rect1);
//內置矩形
CRect rect2=new CRect(110,50,210,100);
dcMem.Rectangle(rect2);
//內置三角形
CPoint point[3]={CPoint(250,200),CPoint(300,150),CPoint(350,200)};
dcMem.Polygon(point,3);
//內置橢圓
CRect rect3=new CRect(410,0,510,60);
dcMem.Ellipse(rect3);
//內置梯形
dcMem.MoveTo(25,150);
dcMem.LineTo(75,150);
dcMem.MoveTo(25,150);
dcMem.LineTo(0,200);
dcMem.MoveTo(75,150);
dcMem.LineTo(100,200);
dcMem.MoveTo(0,200);
dcMem.LineTo(100,200);
//點擊按鈕畫圓
for(int i=0;i<m_Circle_Count;i++)
{
dcMem.Ellipse((cx[i]-40),(cy[i]-40),(cx[i]+40),(cy[i]+40));
}
//將記憶體拷貝懂啊設備dc中
pDC->BitBlt(0,0,rect.right-rect.left,rect.bottom-rect.top,&dcMem, 0, 0, SRCCOPY);
pDC->SelectObject(pOld);
bmpMem.DeleteObject();
dcMem.DeleteDC();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyShapeDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyShapeDlg::OnCircle()
{
// TODO: Add your control notification handler code here
CDlgAddCircle dlg;
dlg.DoModal();
UpdateData(false);
}
uj5u.com熱心網友回復:
樓主你這是MFC的問題,去那個版塊問問吧,這里是C++語言比較多轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/133298.html
標籤:界面
上一篇:關于cef的問題,請大神幫忙?
下一篇:求助opencv報錯R6010
