本文整理汇总了C++中CGraphic::GetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CGraphic::GetRect方法的具体用法?C++ CGraphic::GetRect怎么用?C++ CGraphic::GetRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGraphic
的用法示例。
在下文中一共展示了CGraphic::GetRect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCommand
BOOL CEx_DrawView::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
CEx_DrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (wParam == 0x200)
{
GraphicDeleteById(pDoc->m_sel);
pDoc->m_sel = -1;
return TRUE;
}
if (wParam == 0x201)
{
ASSERT(pDoc->m_sel >= 0);
ConfigDlg dlg;
CGraphic* P = Convert_To_Graphic(pDoc->m_obArray[pDoc->m_sel]);
ASSERT_VALID(P);
CRect rt;
P->GetRect(rt);
P->UpdateData(&dlg.m_GM, FALSE);
CGraphic* pSave = CGraphic::CreateGraphic(&dlg.m_GM);
pSave->m_modifiedTime = dlg.m_GM.m_modifiedTime;
dlg.m_typeName = P->GetName();
if (dlg.DoModal() == IDOK)
{
if (dlg.m_GM.m_bHidden) pDoc->m_sel = -1;
P->UpdateData(&dlg.m_GM);
pDoc->WriteLog(CGraphicLog::GOS_UPDATE, pSave, pDoc->m_sel);
pDoc->UpdateAllViews(NULL, 0x4000);
pDoc->UpdateAllViews(NULL, 0x4001);
Invalidate();
}
else
{
delete pSave;
}
return TRUE;
}
if (wParam == 0x202)
{
GraphicDeleteById(pDoc->m_sel);
pDoc->m_sel = -1;
return TRUE;
}
return CScrollView::OnCommand(wParam, lParam);
}
示例2: OnKeyDown
void CEx_DrawView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CEx_DrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
UINT type = pDoc->m_GM.m_DrawType;
if (nChar == VK_SHIFT && type != SELECT)
{
m_bShiftDown = TRUE;
CPoint pt;
GetCursorPos(&pt);
ScreenToClient(&pt);
OnMouseMove(0, pt);
}
else if (nChar == VK_CONTROL && type == SELECT)
{
m_bCtrlDown = TRUE;
}
else if (nChar == VK_DELETE && type == SELECT)
{
int sel = pDoc->m_sel;
if (sel != -1)
{
GraphicDeleteById(sel);
pDoc->m_sel = -1;
}
}
else if (nChar >= VK_LEFT && nChar <= VK_DOWN)
{
int sel = pDoc->m_sel;
if (sel != -1)
{
CGraphic* P = Convert_To_Graphic(pDoc->m_obArray[pDoc->m_sel]);
switch (nChar)
{
case VK_LEFT: P->m_pt1.x--; P->m_pt2.x--; break;
case VK_RIGHT: P->m_pt1.x++; P->m_pt2.x++; break;
case VK_DOWN: P->m_pt1.y++; P->m_pt2.y++; break;
case VK_UP: P->m_pt1.y--; P->m_pt2.y--; break;
}
CRect rt;
P->GetRect(rt);
P->m_modifiedTime = CTime::GetCurrentTime();
rt.OffsetRect(-GetScrollPosition());
InvalidateRect(&rt, FALSE);
}
}
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
示例3: GraphicDeleteById
void CEx_DrawView::GraphicDeleteById( int id )
{
CEx_DrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int size = pDoc->m_obArray.GetSize();
ASSERT(id >= 0 && id < size);
CRect rt;
CGraphic* pDelete = Convert_To_Graphic(pDoc->m_obArray[id]);
pDelete->GetRect(rt);
pDoc->WriteLog(CGraphicLog::GOS_DELETE, pDelete, id);
pDelete = NULL;
pDoc->UpdateAllViews(NULL, 0x4000);
rt.OffsetRect(-GetScrollPosition());
InvalidateRect(&rt, TRUE);
}
示例4: OnContextMenu
void CEx_DrawView::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
CEx_DrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_bContextMenu = TRUE;
if (pDoc->m_GM.m_DrawType == SELECT)
{
CPoint pt;
GetCursorPos(&pt);
ScreenToClient(&pt);
pt += m_ptLocalScroll;
BOOL bResult = FALSE;
GraphicHitTest(pt, bResult, m_iTrackID);
if (bResult && pDoc->m_sel == m_iTrackID && m_iTrackID != -1)
{
CGraphic* P = Convert_To_Graphic(pDoc->m_obArray[m_iTrackID]);
CRect rt;
P->GetRect(rt);
GraphicMember GM;
P->UpdateData(&GM, FALSE);
CMenu menu;
CString title;
GetCursorPos(&pt);
menu.CreatePopupMenu();
menu.AppendMenu(MF_STRING, 0x80, _T("----===== 画布信息 =====----"));
title.Format(_T("图布大小: %dx%d"), m_size.cx, m_size.cy);
menu.AppendMenu(MF_STRING, 0x81, title);
menu.AppendMenu(MF_STRING, 0x200, _T("----===== 操作命令 =====----"));
menu.AppendMenu(MF_STRING | MF_BYCOMMAND, 0x201, _T("编辑当前图形"));
menu.AppendMenu(MF_STRING | MF_BYCOMMAND, 0x202, _T("删除当前图形"));
menu.AppendMenu(MF_STRING, 0x100, _T("----===== 图形信息 =====----"));
title.Format(_T("自定义名称: %s"), GM.m_lpszName);
menu.AppendMenu(MF_STRING, 0x106, title);
title.Format(_T("图像类型: %s"), P->GetName());
menu.AppendMenu(MF_STRING, 0x101, title);
title.Format(_T("存放序号: %d"), m_iTrackID);
menu.AppendMenu(MF_STRING, 0x102, title);
title.Format(_T("节点数量: %d"), P->GetPts());
menu.AppendMenu(MF_STRING, 0x103, title);
title.Format(_T("图像大小: %dx%d"), rt.Width(), rt.Height());
menu.AppendMenu(MF_STRING, 0x104, title);
title.Format(_T("是否隐藏: %s"), GM.m_bHidden ? _T("是") : _T("否"));
menu.AppendMenu(MF_STRING, 0x107, title);
title.Format(_T("逻辑坐标: (%d, %d, %d, %d)"), rt.left, rt.top, rt.right, rt.bottom);
menu.AppendMenu(MF_STRING, 0x105, title);
menu.AppendMenu(MF_SEPARATOR);
title.Format(_T("创建时间: %s"), GM.m_createTime.Format("%c"));
menu.AppendMenu(MF_STRING, 0x300, title);
title.Format(_T("修改时间: %s"), GM.m_modifiedTime.Format("%c"));
menu.AppendMenu(MF_STRING, 0x301, title);
menu.AppendMenu(MF_SEPARATOR);
title.Format(_T("画笔类型: %s"), CGraphic::GetPenStyleById(GM.m_iPenStyle, FALSE));
menu.AppendMenu(MF_STRING, 0x125, title);
if (!IF_NULL_PEN(GM.m_iPenStyle))
{
title.Format(_T("画笔颜色: RGB(%d, %d, %d)"), GetRValue(GM.m_clrPen), GetGValue(GM.m_clrPen), GetBValue(GM.m_clrPen));
menu.AppendMenu(MF_STRING, 0x120, title);
title.Format(_T("画笔粗细: %d"), GM.m_iPenWidth);
menu.AppendMenu(MF_STRING, 0x122, title);
}
menu.AppendMenu(MF_SEPARATOR);
if (P->EnableBrush())
{
title.Format(_T("画笔类型: %s"), CGraphic::GetBrushStyleById(GM.m_iBrushStyle, FALSE));
menu.AppendMenu(MF_STRING, 0x400, title);
if (!IF_NULL_BRUSH(GM.m_iBrushStyle))
{
title.Format(_T("画刷颜色: RGB(%d, %d, %d)"), GetRValue(GM.m_clrBrush), GetGValue(GM.m_clrBrush), GetBValue(GM.m_clrBrush));
menu.AppendMenu(MF_STRING, 0x401, title);
}
}
menu.TrackPopupMenu(0, pt.x, pt.y, this);
}
}
else
{
pDoc->m_GM.m_DrawType = SELECT;
pDoc->UpdateAllViews(NULL, 0x2000);
}
}
示例5: OnLButtonUp
void CEx_DrawView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CEx_DrawDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_ptLocalScroll = GetScrollPosition();
CPoint ptLocal = point + m_ptLocalScroll;
ReleaseCapture();
if (m_bLButtonDown)
{
m_bLButtonDown = FALSE;
pDoc->m_GM.m_pt2 = ptLocal;
if (pDoc->m_GM.m_DrawType != SELECT)
{
BOOL bCreate = TRUE;
if (pDoc->m_GM.m_DrawType == RECTANGLE || pDoc->m_GM.m_DrawType == ELLIPSE)
{
CRect rt;
rt.SetRect(pDoc->m_GM.m_pt1, pDoc->m_GM.m_pt2);
rt.NormalizeRect();
if (rt.Width() < 5 || rt.Height() < 5)
{
bCreate = FALSE;
}
}
if (bCreate)
{
// 创建新的对象
CGraphic* pGraphic = CGraphic::CreateGraphic(&pDoc->m_GM);
pGraphic->m_createTime = CTime::GetCurrentTime();
pGraphic->m_modifiedTime = pGraphic->m_createTime;
pGraphic->m_bHidden = FALSE;
pGraphic->m_lpszName.Format(_T("%s_%d"), pGraphic->GetName(), ++pDoc->m_createID);
ASSERT(pGraphic);
if (pDoc->m_GM.m_DrawType == CURVE)
{
pDoc->m_GM.m_pts.RemoveAll();
m_pen.DeleteObject();
}
else
{
if (m_bShiftDown)
pGraphic->m_pt2.y = pGraphic->m_pt1.y + labs (pGraphic->m_pt2.x - pGraphic->m_pt1.x);
}
CRect rt;
pGraphic->GetRect(rt);
InvalidateRect(&rt, TRUE);
pDoc->WriteLog(CGraphicLog::GOS_ADD, pGraphic, pDoc->m_obArray.GetSize());
pDoc->UpdateAllViews(NULL, 0x4000);
pDoc->UpdateAllViews(NULL, 0x4001);
}
}
else
{
if (m_pMoveTarget)
{
if (!m_bFirstMove) m_pMoveTarget->m_modifiedTime = CTime::GetCurrentTime();
static GraphicMember GM;
m_pMoveTarget->UpdateData(&GM, FALSE);
Convert_To_Graphic(pDoc->m_obArray[pDoc->m_sel])->UpdateData(&GM); // 修改坐标
if (m_pLogBuffer)
{
if (!m_bFirstMove || m_bSizingMode)
{
pDoc->WriteLog(CGraphicLog::GOS_UPDATE, m_pLogBuffer, pDoc->m_sel);
}
else
{
delete m_pLogBuffer;
m_pLogBuffer = NULL;
}
}
if (!m_bDup) delete m_pMoveTarget;
else m_bDup = FALSE;
m_pMoveTarget = NULL;
m_bSizingMode = FALSE;
}
}
}
m_bFirstMove = FALSE;
CScrollView::OnLButtonUp(nFlags, point);
}