void ZSplitter::move(CPoint point,CPoint dif) { if(!(ownStyle&sp_StyleRight) ) dif.x = min(dif.x,0); if(!(ownStyle&sp_StyleLeft) ) dif.x = max(dif.x,0); if(!(ownStyle&sp_StyleBottom) )dif.y = max(dif.y,0); if(!(ownStyle&sp_StyleTop) ) dif.y = min(dif.y,0); CRect rc,parent; GetWindowRect(&rc); GetParent()->GetClientRect(&parent); GetParent()->ScreenToClient(&rc); int left = rc.left+dif.x; int top = rc.top+dif.y; bool canAll = true; CRect rect; for(int i=0; i<(int)idxs.size();i++) if (!countRect(rect,i,dif)) canAll = false; if(canAll && left>0 && left<parent.right && top>0 && top<parent.bottom ) { for(int i=0; i<(int)idxs.size();i++) { countRect(rect,i,dif); CWnd *wnd = GetParent()->GetDlgItem(idxs[i]); wnd->MoveWindow(&rect); GetParent()->PostMessage(WM_MOVE_ZSPLITTER,0,(long)wnd->m_hWnd); wnd->UpdateWindow(); } SetWindowPos(0,left,top,0,0,SWP_NOSIZE|SWP_NOZORDER); m_pointDragStart = point-dif; } }
void CStageEyeDialog::OnEyeRestoreTo() { CMainFrame *pMainFrame = (CMainFrame *)GetTopLevelFrame(); if (!pMainFrame || !pMainFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) { return; } CStageView *pView = (CStageView *)pMainFrame->GetActiveView(); if (!pView || !pView->IsKindOf(RUNTIME_CLASS(CStageView))) { return; } CStageDoc *pDoc = pView->GetDocument(); if (!pDoc || !pDoc->IsKindOf(RUNTIME_CLASS(CStageDoc))) { return; } CWnd *pCBox; char s[32]; pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_TOX); pView->m_eye[3] = m_eyeOrig[3]; sprintf(s, "%.1lf", pView->m_eye[3] * pDoc->m_unitScaleFactor); pCBox->SetWindowText(s); pCBox->UpdateWindow(); pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_TOY); pView->m_eye[4] = m_eyeOrig[4]; sprintf(s, "%.1lf", pView->m_eye[4] * pDoc->m_unitScaleFactor); pCBox->SetWindowText(s); pCBox->UpdateWindow(); pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_TOZ); pView->m_eye[5] = m_eyeOrig[5]; sprintf(s, "%.1lf", pView->m_eye[5] * pDoc->m_unitScaleFactor); pCBox->SetWindowText(s); pCBox->UpdateWindow(); ::glMatrixMode(GL_MODELVIEW); ::glLoadIdentity(); ::gluLookAt(pView->m_eye[0], pView->m_eye[1], pView->m_eye[2], pView->m_eye[3], pView->m_eye[4], pView->m_eye[5], pView->m_eye[6], pView->m_eye[7], pView->m_eye[8]); pView->YoRender(YO_RENDER_LIGHT); pView->YoRender(YO_RENDER_FULL); return; }
void COleResizeBar::OnLButtonDown(UINT /*nFlags*/, CPoint point) { // track to parent of the parent CWnd* pFrameWnd = GetParentFrame(); ASSERT_VALID(pFrameWnd); CWnd* pParent = pFrameWnd->GetParent(); pFrameWnd->UpdateWindow(); // update ourselves // limit tracking to parent client rectangle if (pParent != NULL) { pParent->UpdateWindow(); // always update before tracking // clip cursor to parent window CRect rect; pParent->GetClientRect(&rect); pParent->ClientToScreen(&rect); ::ClipCursor(&rect); } // save the rect, track, then restore CRect rectSave = m_tracker.m_rect; BOOL bNotify = m_tracker.Track(this, point, FALSE, pParent); CRect rectNew = m_tracker.m_rect; m_tracker.m_rect = rectSave; // allow full mouse movement again ::ClipCursor(NULL); // notify owner window if tracker changed if (bNotify) { CWnd* pOwner = GetOwner(); ASSERT_VALID(pOwner); // convert relative to parent coordinates ClientToScreen(&rectNew); pOwner->ScreenToClient(&rectNew); // send notification to owner pOwner->SendMessage(WM_SIZECHILD, (WPARAM)_AfxGetDlgCtrlID(m_hWnd), (LPARAM)(LPCRECT)&rectNew); } }
void CTrackFile::OutputString(LPCTSTR lpsz) { if (m_pFrameWnd != NULL) { m_pFrameWnd->SetMessageText(lpsz); CWnd* pBarWnd = m_pFrameWnd->GetMessageBar(); if (pBarWnd != NULL) pBarWnd->UpdateWindow(); } }
void DlgMidf::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CDialogEx::OnPaint() CWnd* pWnd = GetDlgItem(IDC_pic); CDC* pDC = pWnd->GetDC(); pWnd->Invalidate(); pWnd->UpdateWindow(); m_adp->Draw(pDC); }
void CStageEyeDialog::OnKillfocusEyeClipfront() { // TODO: Add your control notification handler code here CMainFrame *pMainFrame = (CMainFrame *)GetTopLevelFrame(); if (!pMainFrame || !pMainFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) { return; } CStageView *pView = (CStageView *)pMainFrame->GetActiveView(); if (!pView || !pView->IsKindOf(RUNTIME_CLASS(CStageView))) { return; } CStageDoc *pDoc = pView->GetDocument(); if (!pDoc || !pDoc->IsKindOf(RUNTIME_CLASS(CStageDoc))) { return; } CWnd *pCBox; char s[32]; GLdouble clipFront; RECT rect; pMainFrame->GetWindowRect(&rect); if (rect.right - rect.left < YO_THRESH_WIDTH || pMainFrame->m_wndDlgEyeVisible == FALSE || pMainFrame->m_wndDlgEye == NULL) { return; } pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_CLIPFRONT); pCBox->GetWindowText(s, 32); sscanf(s, "%lf", &clipFront); pView->m_clipFront = clipFront / pDoc->m_unitScaleFactor; pView->m_clipFront = YO_MAX(pView->m_clipFront, 0.1); pView->m_clipFront = YO_MIN(pView->m_clipFront, pView->m_clipRear); sprintf(s, "%.2lf", pView->m_clipFront * pDoc->m_unitScaleFactor); pCBox->SetWindowText(s); pCBox->UpdateWindow(); ::glMatrixMode(GL_PROJECTION); ::glLoadIdentity(); ::gluPerspective(pView->m_fieldOfView, pView->m_aspectRatio, pView->m_clipFront, pView->m_clipRear); ::glMatrixMode(GL_MODELVIEW); pView->YoRender(YO_RENDER_LIGHT); pView->YoRender(YO_RENDER_FULL); return; }
void CMainFrame::OnUnsplit() { if ( m_wndSplitter.GetRowCount() == 1 ) return; m_wndSplitter.SavePosition(); m_wndSplitter.DeleteRow(0); CWnd* pWnd = m_wndSplitter.GetPane(0, 0); pWnd->InvalidateRect(NULL, FALSE); pWnd->UpdateWindow(); }
void CStageEyeDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { CMainFrame *pMainFrame = (CMainFrame *)GetTopLevelFrame(); if (!pMainFrame || !pMainFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) { return; } CStageView *pView = (CStageView *)pMainFrame->GetActiveView(); if (!pView || !pView->IsKindOf(RUNTIME_CLASS(CStageView))) { return; } char s[32]; CWnd *pCBox; if ((CSliderCtrl *)pScrollBar == &m_eyeSliderFOV) { pView->m_fieldOfView = m_eyeSliderFOV.GetPos(); sprintf(s, "%.1lf", pView->m_fieldOfView); pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_FOV); pCBox->SetWindowText(s); pCBox->UpdateWindow(); ::glMatrixMode(GL_PROJECTION); ::glLoadIdentity(); ::gluPerspective(pView->m_fieldOfView, pView->m_aspectRatio, pView->m_clipFront, pView->m_clipRear); ::glMatrixMode(GL_MODELVIEW); //::glMatrixMode(GL_MODELVIEW); //::glLoadIdentity(); //::gluLookAt(pView->m_eye[0], pView->m_eye[1], pView->m_eye[2], // pView->m_eye[3], pView->m_eye[4], pView->m_eye[5], // pView->m_eye[6], pView->m_eye[7], pView->m_eye[8]); if (nSBCode == SB_ENDSCROLL) { pView->YoRender(YO_RENDER_LIGHT); pView->YoRender(YO_RENDER_FULL); } else { pView->YoRender(YO_RENDER_QUICK); } } CDialog::OnHScroll(nSBCode, nPos, pScrollBar); }
void CStageEyeDialog::OnKillfocusEyeFov() { CMainFrame *pMainFrame = (CMainFrame *)GetTopLevelFrame(); if (!pMainFrame || !pMainFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) { return; } CStageView *pView = (CStageView *)pMainFrame->GetActiveView(); if (!pView || !pView->IsKindOf(RUNTIME_CLASS(CStageView))) { return; } CWnd *pCBox; char s[32]; RECT rect; pMainFrame->GetWindowRect(&rect); if (rect.right - rect.left < YO_THRESH_WIDTH || pMainFrame->m_wndDlgEyeVisible == FALSE || pMainFrame->m_wndDlgEye == NULL) { return; } pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_FOV); pCBox->GetWindowText(s, 32); sscanf(s, "%lf", &pView->m_fieldOfView); pView->m_fieldOfView = YO_MAX(pView->m_fieldOfView, 0.0); pView->m_fieldOfView = YO_MIN(pView->m_fieldOfView, 180.0); sprintf(s, "%.1lf", pView->m_fieldOfView); pCBox->SetWindowText(s); pCBox->UpdateWindow(); m_eyeSliderFOV.SetPos((int)pView->m_fieldOfView); ::glMatrixMode(GL_PROJECTION); ::glLoadIdentity(); ::gluPerspective(pView->m_fieldOfView, pView->m_aspectRatio, pView->m_clipFront, pView->m_clipRear); ::glMatrixMode(GL_MODELVIEW); pView->YoRender(YO_RENDER_LIGHT); pView->YoRender(YO_RENDER_FULL); return; }
void CxStatic::SetWindowText( LPCTSTR strText) { m_strText = strText; CRect Rect; GetClientRect(&Rect); if ( m_bTransparentBk ){ ClientToScreen(&Rect); Rect.InflateRect(1,1,1,1); CWnd *Parent = GetParent(); Parent->ScreenToClient(&Rect); Parent->InvalidateRect(&Rect); Parent->UpdateWindow(); //SendMessage(WM_ERASEBKGND); } else RedrawWindow(); }
void MenuBaseC::MenuOpen(bool defaultButtonOK, bool clearButtonOK) { FormContainer* pForm = m_pFormContainer; ASSERT(pForm); CWnd* currWnd = pForm->GetWindow(); buttonForm.Create(currWnd, WS_DLGFRAME); mainForm.Create(currWnd); pForm->ResetForm(); mainForm.ShowWindow(SW_SHOW); mainForm.GetParentWnd()->ShowWindow(SW_SHOW); propClear.SetSensitive(clearButtonOK); propDefault.SetSensitive(defaultButtonOK); if (currWnd) { currWnd->Invalidate(); // attempt to fix RRs bug with overlaying menus currWnd->UpdateWindow(); } }
void CStageEyeDialog::OnEyeRestoreFov() { CMainFrame *pMainFrame = (CMainFrame *)GetTopLevelFrame(); if (!pMainFrame || !pMainFrame->IsKindOf(RUNTIME_CLASS(CMainFrame))) { return; } CStageView *pView = (CStageView *)pMainFrame->GetActiveView(); if (!pView || !pView->IsKindOf(RUNTIME_CLASS(CStageView))) { return; } CStageDoc *pDoc = pView->GetDocument(); if (!pDoc || !pDoc->IsKindOf(RUNTIME_CLASS(CStageDoc))) { return; } CWnd *pCBox; char s[32]; pCBox = (CComboBox*)pMainFrame->m_wndDlgEye->GetDlgItem(IDC_EYE_FOV); pView->m_fieldOfView = m_fieldOfViewOrig; sprintf(s, "%.1lf", pView->m_fieldOfView); pCBox->SetWindowText(s); pCBox->UpdateWindow(); m_eyeSliderFOV.SetPos((int)pView->m_fieldOfView); ::glMatrixMode(GL_PROJECTION); ::glLoadIdentity(); ::gluPerspective(pView->m_fieldOfView, pView->m_aspectRatio, pView->m_clipFront, pView->m_clipRear); ::glMatrixMode(GL_MODELVIEW); pView->YoRender(YO_RENDER_LIGHT); pView->YoRender(YO_RENDER_FULL); return; }
void CResizablePage::ArrangeLayout() { // init some vars CRect wndrc; GetClientRect(&wndrc); Layout *pl; POSITION pos = m_plLayoutList.GetHeadPosition(); HDWP hdwp = BeginDeferWindowPos(m_plLayoutList.GetCount()); while (pos != NULL) { pl = (Layout*)m_plLayoutList.GetNext(pos); CRect objrc, newrc; CWnd* wnd = CWnd::FromHandle(pl->hwnd); // temporary solution wnd->GetWindowRect(&objrc); ScreenToClient(&objrc); // calculate new top-left corner newrc.left = pl->tl_margin.cx + wndrc.Width() * pl->tl_type.cx / 100; newrc.top = pl->tl_margin.cy + wndrc.Height() * pl->tl_type.cy / 100; // calculate new bottom-right corner newrc.right = pl->br_margin.cx + wndrc.Width() * pl->br_type.cx / 100; newrc.bottom = pl->br_margin.cy + wndrc.Height() * pl->br_type.cy / 100; if (!newrc.EqualRect(&objrc)) { BOOL add = TRUE; if (pl->adj_hscroll) { // needs repainting, due to horiz scrolling int diff = newrc.Width() - objrc.Width(); int max = wnd->GetScrollLimit(SB_HORZ); if (max > 0 && wnd->GetScrollPos(SB_HORZ) > max - diff) { wnd->MoveWindow(&newrc); wnd->Invalidate(); wnd->UpdateWindow(); add = FALSE; } } if (pl->need_refresh) { wnd->MoveWindow(&newrc); wnd->Invalidate(); wnd->UpdateWindow(); add = FALSE; } if (add) DeferWindowPos(hdwp, pl->hwnd, NULL, newrc.left, newrc.top, newrc.Width(), newrc.Height(), SWP_NOZORDER | SWP_NOACTIVATE); } } // go re-arrange child windows EndDeferWindowPos(hdwp); }
void CDlgHistogram::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here if (m_pGreyScale == NULL) { return; } CRect rect; CWnd *pWnd = GetDlgItem(IDC_STATIC_HISTOGRAM); // this->GetWindowRect(&rect); pWnd->GetWindowRect(&rect); ScreenToClient(&rect); CDC *pDC = &dc; pWnd->UpdateWindow(); // this->UpdateWindow(); pDC->Rectangle(rect); CPen *pRedPen = new CPen; pRedPen->CreatePen(PS_SOLID,2,RGB(255,0,0));//画坐标轴的笔,红色 CPen *pOldPen = pDC->SelectObject(pRedPen);//选择新画笔,返回并保存原值 CPen *pBluePen = new CPen; pBluePen->CreatePen(PS_SOLID,2,RGB(0,0,255)); rect.DeflateRect(20, 20); /* pDC->Rectangle(&rect);*/ pDC->MoveTo(rect.left,rect.bottom);//从当前点移动到参数点 pDC->LineTo(rect.left,rect.top);//画纵坐标 pDC->LineTo(rect.left-5,rect.top + 5);//画箭头 pDC->MoveTo(rect.left,rect.top); pDC->LineTo(rect.left+5,rect.top + 5); pDC->MoveTo(rect.left,rect.bottom);//画横坐标 pDC->LineTo(rect.right,rect.bottom); pDC->LineTo(rect.right-5,rect.bottom - 5); pDC->MoveTo(rect.right,rect.bottom); pDC->LineTo(rect.right-5,rect.bottom + 5); float DeltaCount = float(rect.Width()-10)/m_nGreyCount; pDC->SelectObject(pBluePen);//选择蓝色画笔,开始画直方图 int GreyNumberMax = 0; for (int i=0; i< m_nGreyCount; i++) { if (GreyNumberMax < m_pGreyScale[i]) { GreyNumberMax = m_pGreyScale[i];//直方图中灰度次数最多的值 } } for (i=0; i< m_nGreyCount; i++) { if (GreyNumberMax != 0) { double Ratio = (( double )m_pGreyScale[i])/GreyNumberMax; pDC->MoveTo(rect.left +(int)(i* DeltaCount)+2, rect.bottom - 2); pDC->LineTo(rect.left +(int)(i* DeltaCount)+2, rect.bottom - 2 - (int)(Ratio * (rect.Height()-10))); } } for (i=0; i< m_nGreyCount; i++) { if (i % 10 == 0) { pDC->MoveTo(rect.left +(int)(i* DeltaCount)+2, rect.bottom - 2); pDC->LineTo(rect.left +(int)(i* DeltaCount)+2, rect.bottom - 2 + 4); } if (i % 50 == 0) { pDC->MoveTo(rect.left +(int)(i* DeltaCount)+2, rect.bottom - 2); pDC->LineTo(rect.left +(int)(i* DeltaCount)+2, rect.bottom - 2 + 10); } } pDC->SelectObject(pOldPen); delete pRedPen; delete pBluePen; // Do not call CDialog::OnPaint() for painting messages }
void COutputWnd::WriteLog(eLogTarget etarget, eLogType etype, bool bringFrontWnd, bool mb, LPCTSTR lpszLog) { CWnd* target = NULL; switch (etarget) { case eLOG_TARGET_OUTPUT: target = &m_wndOutputGeneral; break; case eLOG_TARGET_DEBUG: target = &m_wndOutputDebug; break; case eLOG_TARGET_PARAM: target = &m_wndOutputFind; break; default: return; } // prepare log string. CString log = lpszLog; // append prefix if needed. switch (etype) { case eLOG_WARN: log = _T("[WARN] ") + log; break; case eLOG_ERROR: log = _T("[ERROR] ") + log; break; } // attach time & date time_t timer; TCHAR szTime[25]; struct tm tm_info; time(&timer); localtime_s(&tm_info, &timer); _tcsftime(szTime, 25, _T("[%Y/%m/%d %H:%M:%S] "), &tm_info); log = szTime + log; // show log string. switch (etarget) { case eLOG_TARGET_OUTPUT: case eLOG_TARGET_DEBUG: case eLOG_TARGET_PARAM: ((COutputList*)target)->AddString(log); break; } target->Invalidate(); target->UpdateWindow(); // set the selected log window as active(front) window. if (bringFrontWnd) m_wndTabs.SetActiveTab(m_wndTabs.GetTabFromHwnd(target->GetSafeHwnd())); // message box if (mb) AfxMessageBox(log); // scroll down to the bottom ((COutputList*)target)->SetSel(((COutputList*)target)->GetCount()-1, 1); ((COutputList*)target)->SetTopIndex(((COutputList*)target)->GetCount()-1); ((COutputList*)target)->SetScrollPos(SB_VERT, ((COutputList*)target)->GetCount()-1); }
BOOL CPropPageRestore::CheckData() { switch(m_iSource) { case FILE_MODE: if(m_strBackupPath.IsEmpty()) { ::AfxMessageBox(IDS_ERR_NO_BACKUP_PATH); CWnd* pWnd = GetDlgItem(IDC_BACKUP_PATH_EDIT); GotoDlgCtrl(pWnd); return FALSE; } else { if(m_strBackupPath.Find(_T('.')) == -1) { m_strBackupPath += _T(".4cb"); CWnd* pWnd = GetDlgItem(IDC_BACKUP_PATH_EDIT); pWnd->SetWindowText(m_strBackupPath); pWnd->UpdateWindow(); } CFileStatus tStatus; if(!CFile::GetStatus(m_strBackupPath, tStatus)) { ::AfxMessageBox(_T("Specified backup file does not exist.")); CWnd* pWnd = GetDlgItem(IDC_BACKUP_PATH_EDIT); GotoDlgCtrl(pWnd); return FALSE; } } break; case TARGET_MODE: if(m_strAddress.IsEmpty()) { ::AfxMessageBox(IDS_ERR_NO_ADDRESS); CWnd* pWnd = GetDlgItem(IDC_ADDRESS_EDIT); GotoDlgCtrl(pWnd); return FALSE; } break; } if(m_strProjectPath.IsEmpty()) { ::AfxMessageBox(IDS_ERR_NO_PROJECT_PATH); CWnd* pWnd = GetDlgItem(IDC_PROJECT_PATH_EDIT); GotoDlgCtrl(pWnd); return FALSE; } CFileStatus tStatus; if(CFile::GetStatus(m_strProjectPath, tStatus)) { CString strMessage(_T("Project Path already exists.")); ::AfxMessageBox(strMessage); m_pMainSheet->SetStatusText(strMessage); CWnd* pWnd = GetDlgItem(IDC_PROJECT_PATH_EDIT); GotoDlgCtrl(pWnd); return FALSE; } return TRUE; }
void CDlgIntensity::OnPaint() { // 字符串 CString str; // 循环变量 LONG i; // 最大计数 LONG lMaxCount = 0; // 设备上下文 CPaintDC dc(this); // 获取绘制坐标的文本框 CWnd* pWnd = GetDlgItem(IDC_COORD); // 指针 CDC* pDC = pWnd->GetDC(); pWnd->Invalidate(); pWnd->UpdateWindow(); pDC->Rectangle(0,0,330,300); // 创建画笔对象 CPen* pPenRed = new CPen; // 红色画笔 pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0)); // 创建画笔对象 CPen* pPenBlue = new CPen; // 蓝色画笔 pPenBlue->CreatePen(PS_SOLID,1,RGB(0,0, 255)); // 创建画笔对象 CPen* pPenGreen = new CPen; // 绿色画笔 pPenGreen->CreatePen(PS_DOT,1,RGB(0,255,0)); // 选中当前红色画笔,并保存以前的画笔 CGdiObject* pOldPen = pDC->SelectObject(pPenRed); // 绘制坐标轴 pDC->MoveTo(10,10); // 垂直轴 pDC->LineTo(10,280); // 水平轴 pDC->LineTo(320,280); // 写X轴刻度值 str.Format("0"); pDC->TextOut(10, 283, str); str.Format("50"); pDC->TextOut(60, 283, str); str.Format("100"); pDC->TextOut(110, 283, str); str.Format("150"); pDC->TextOut(160, 283, str); str.Format("200"); pDC->TextOut(210, 283, str); str.Format("255"); pDC->TextOut(265, 283, str); // 绘制X轴刻度 for (i = 0; i < 256; i += 5) { if ((i & 1) == 0) { // 10的倍数 pDC->MoveTo(i + 10, 280); pDC->LineTo(i + 10, 284); } else { // 10的倍数 pDC->MoveTo(i + 10, 280); pDC->LineTo(i + 10, 282); } } // 绘制X轴箭头 pDC->MoveTo(315,275); pDC->LineTo(320,280); pDC->LineTo(315,285); // 绘制X轴箭头 pDC->MoveTo(10,10); pDC->LineTo(5,15); pDC->MoveTo(10,10); pDC->LineTo(15,15); // 计算最大计数值 for (i = m_iLowGray; i <= m_iUpGray; i ++) { // 判断是否大于当前最大值 if (m_lCount[i] > lMaxCount) { // 更新最大值 lMaxCount = m_lCount[i]; } } // 输出最大计数值 pDC->MoveTo(10, 25); pDC->LineTo(14, 25); str.Format("%d", lMaxCount); pDC->TextOut(11, 26, str); // 更改成绿色画笔 pDC->SelectObject(pPenGreen); // 绘制窗口上下限 pDC->MoveTo(m_iLowGray + 10, 25); pDC->LineTo(m_iLowGray + 10, 280); pDC->MoveTo(m_iUpGray + 10, 25); pDC->LineTo(m_iUpGray + 10, 280); // 更改成蓝色画笔 pDC->SelectObject(pPenBlue); // 判断是否有计数 if (lMaxCount > 0) { // 绘制直方图 for (i = m_iLowGray; i <= m_iUpGray; i ++) { pDC->MoveTo(i + 10, 280); pDC->LineTo(i + 10, 281 - (int) (m_lCount[i] * 256 / lMaxCount)); } } // 恢复以前的画笔 pDC->SelectObject(pOldPen); // 删除新的画笔 delete pPenRed; delete pPenBlue; delete pPenGreen; }
void CEx24dView::OnExceloleExecute() { LPDISPATCH pRange, pWorkbooks; CWnd* pWnd = CWnd::FindWindow("XLMAIN", NULL); if (pWnd != NULL) { TRACE("Excel window found\n"); pWnd->ShowWindow(SW_SHOWNORMAL); pWnd->UpdateWindow(); pWnd->BringWindowToTop(); } m_app.SetSheetsInNewWorkbook(1); VERIFY(pWorkbooks = m_app.GetWorkbooks()); m_workbooks.AttachDispatch(pWorkbooks); LPDISPATCH pWorkbook = NULL; if (m_workbooks.GetCount() == 0) { // Add returns a Workbook pointer, but we // don't have a Workbook class pWorkbook = m_workbooks.Add(); // Save the pointer for // later release } LPDISPATCH pWorksheets = m_app.GetWorksheets(); ASSERT(pWorksheets != NULL); m_worksheets.AttachDispatch(pWorksheets); LPDISPATCH pWorksheet = m_worksheets.GetItem(COleVariant((short) 1)); m_worksheet.AttachDispatch(pWorksheet); m_worksheet.Select(); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A1"))); m_range[0].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A2"))); m_range[1].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"))); m_range[2].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A3"), COleVariant("C5"))); m_range[3].AttachDispatch(pRange); VERIFY(pRange = m_worksheet.GetRange(COleVariant("A6"))); m_range[4].AttachDispatch(pRange); m_range[4].SetValue(COleVariant(COleDateTime(1994, 4, 24, 15, 47, 8))); // retrieve the stored date and print it as a string COleVariant vaTimeDate = m_range[4].GetValue(); TRACE("returned date type = %d\n", vaTimeDate.vt); COleVariant vaTemp; vaTemp.ChangeType(VT_BSTR, &vaTimeDate); CString str = vaTemp.bstrVal; TRACE("date = %s\n", (const char*) str); m_range[0].SetValue(COleVariant("test string")); COleVariant vaResult0 = m_range[0].GetValue(); if (vaResult0.vt == VT_BSTR) { CString str = vaResult0.bstrVal; TRACE("vaResult0 = %s\n", (const char*) str); } m_range[1].SetValue(COleVariant(3.14159)); COleVariant vaResult1 = m_range[1].GetValue(); if (vaResult1.vt == VT_R8) { TRACE("vaResult1 = %f\n", vaResult1.dblVal); } m_range[2].SetFormula(COleVariant("=$A2*2.0")); COleVariant vaResult2 = m_range[2].GetValue(); if (vaResult2.vt == VT_R8) { TRACE("vaResult2 = %f\n", vaResult2.dblVal); } COleVariant vaResult2a = m_range[2].GetFormula(); if (vaResult2a.vt == VT_BSTR) { CString str = vaResult2a.bstrVal; TRACE("vaResult2a = %s\n", (const char*) str); } m_range[3].FillRight(); m_range[3].FillDown(); // cleanup if (pWorkbook != NULL) { pWorkbook->Release(); } }
void CDlgPointWin::OnPaint() { // 字符串 CString str; // 设备上下文 CPaintDC dc ( this ); // 获取绘制坐标的文本框 CWnd* pWnd = GetDlgItem ( IDC_COORD ); // 指针 CDC* pDC = pWnd->GetDC(); pWnd->Invalidate(); pWnd->UpdateWindow(); pDC->Rectangle ( 0, 0, 330, 300 ); // 创建画笔对象 CPen* pPenRed = new CPen; // 红色画笔 pPenRed->CreatePen ( PS_SOLID, 2, RGB ( 255, 0, 0 ) ); // 创建画笔对象 CPen* pPenBlue = new CPen; // 蓝色画笔 pPenBlue->CreatePen ( PS_SOLID, 2, RGB ( 0, 0, 255 ) ); // 创建画笔对象 CPen* pPenGreen = new CPen; // 绿色画笔 pPenGreen->CreatePen ( PS_DOT, 1, RGB ( 0, 255, 0 ) ); // 选中当前红色画笔,并保存以前的画笔 CGdiObject* pOldPen = pDC->SelectObject ( pPenRed ); // 绘制坐标轴 pDC->MoveTo ( 10, 10 ); // 垂直轴 pDC->LineTo ( 10, 280 ); // 水平轴 pDC->LineTo ( 320, 280 ); // 写坐标 str.Format ( L"0" ); pDC->TextOut ( 10, 281, str ); str.Format ( L"255" ); pDC->TextOut ( 265, 281, str ); pDC->TextOut ( 11, 25, str ); // 绘制X轴箭头 pDC->LineTo ( 315, 275 ); pDC->MoveTo ( 320, 280 ); pDC->LineTo ( 315, 285 ); // 绘制X轴箭头 pDC->MoveTo ( 10, 10 ); pDC->LineTo ( 5, 15 ); pDC->MoveTo ( 10, 10 ); pDC->LineTo ( 15, 15 ); // 更改成绿色画笔 pDC->SelectObject ( pPenGreen ); // 绘制窗口上下限 pDC->MoveTo ( m_bLow + 10, 25 ); pDC->LineTo ( m_bLow + 10, 280 ); pDC->MoveTo ( m_bUp + 10, 25 ); pDC->LineTo ( m_bUp + 10, 280 ); // 更改成蓝色画笔 pDC->SelectObject ( pPenBlue ); // 绘制坐标值 str.Format ( L"(%d, %d)", m_bLow, m_bLow ); pDC->TextOut ( m_bLow + 10, 281 - m_bLow, str ); str.Format ( L"(%d, %d)", m_bUp, m_bUp ); pDC->TextOut ( m_bUp + 10, 281 - m_bUp, str ); // 绘制用户指定的窗口(注意转换坐标系) pDC->MoveTo ( 10, 280 ); pDC->LineTo ( m_bLow + 10, 280 ); pDC->LineTo ( m_bLow + 10, 280 - m_bLow ); pDC->LineTo ( m_bUp + 10, 280 - m_bUp ); pDC->LineTo ( m_bUp + 10, 25 ); pDC->LineTo ( 265, 25 ); // 恢复以前的画笔 pDC->SelectObject ( pOldPen ); // 绘制边缘 pDC->MoveTo ( 10, 25 ); pDC->LineTo ( 265, 25 ); pDC->LineTo ( 265, 280 ); // 删除新的画笔 delete pPenRed; delete pPenBlue; delete pPenGreen; }
void CLDlg::OnPaint() { /////////////////////////////////////////////////////////////////////////////////////// ////OnPaint redefined // CBitmap bm; // bm.LoadBitmap(IDB_BITMAP2); //DisplayBitmap(pControlDC,&bm,0,0,100,100); CWnd* pWnd = GetDlgItem(IDC_STATIC1); // IDC_STATIC1 specified // in the dialog editor CDC* pControlDC = pWnd->GetDC(); pWnd->Invalidate(); pWnd->UpdateWindow(); pControlDC->SelectStockObject(0); pBrush=new CBrush(); pBrush->CreateSolidBrush(RGB(50,25,50)); CRect rect; rect.left=0; rect.top=0; rect.bottom=650; rect.right=650; pControlDC->Rectangle(rect); // black square bullet // pControlDC->Ellipse(CRect(0,0,100,100)); pControlDC->FillRect(rect,pBrush); switch(lflag) { case 0: { int intrval=650/cnt; for(int cntr=1;cntr<cnt;cntr++) { pControlDC->MoveTo(0,intrval*cntr); pControlDC->LineTo(650,intrval*cntr); } } break; case 1: { if(flDV) { int interval=650/flrows[crflid]; for(int i=1;i<flrows[crflid];i++) { pControlDC->MoveTo(0,interval*i); pControlDC->LineTo(650,interval*i); } interval=650/flclmns[crflid]; for(i=1;i<flclmns[crflid];i++) { pControlDC->MoveTo(interval*i,0); pControlDC->LineTo(interval*i,650); } } ///////// formation of labs /////////// CBrush *pBrush=new CBrush(); pBrush->CreateSolidBrush(RGB(0,0,155)); for(int tempcntr=0;tempcntr<labcount;tempcntr++) { if(labfl[tempcntr]==crflid) { //int x1=pt1[tempcntr].y*(650/flclmns[crflid]),y1=pt1[tempcntr].x*(650/flrows[crflid]) ; //int x2=pt2[tempcntr].y*(650/flclmns[crflid]),y2=pt2[tempcntr].x*(650/flrows[crflid]) ; long xx1=pt1[tempcntr].x,yy1=pt1[tempcntr].y; long xx2=pt2[tempcntr].x,yy2=pt2[tempcntr].y; if(xx1>xx2) { int temp=xx1; xx1=xx2; xx2=temp; } if(yy1>yy2) { int temp=yy1; yy1=yy2; yy2=temp; } char str1[30],str2[10]; itoa(xx1,str1,10); itoa(yy1,str2,10); strcat(str1,"#"); strcat(str1,str2); itoa(xx2,str2,10); strcat(str1,"#"); strcat(str1,str2); itoa(yy2,str2,10); strcat(str1,"#"); strcat(str1,str2); //AfxMessageBox(str1); pControlDC->SelectStockObject(1); //rect.left=5000; //rect.top=5000; //rect.right=0; //rect.bottom=0; //int xyflag=1; //int xleft,ytop,xright,ybottom; //for(int i=xx1;i<=xx2;i++) // for(int j=yy1;j<=yy2;j++) //{ rect.left=yy1*(650/flclmns[crflid]); rect.top=xx1*(650/flrows[crflid]); rect.bottom=(xx2+1)*(650/flrows[crflid]); rect.right=(yy2+1)*(650/flclmns[crflid]); //} pControlDC->FillRect(rect,pBrush); pControlDC->Draw3dRect(rect,COLORREF(RGB(255,0,0)),COLORREF(RGB(255,0,0))); } } ///////// formation of labs /////////// } break; case 2: { int interval=650/crrows; for(int i=1;i<crrows;i++) { pControlDC->MoveTo(0,interval*i); pControlDC->LineTo(650,interval*i); } interval=650/crclmns; for(i=1;i<crclmns;i++) { pControlDC->MoveTo(interval*i,0); pControlDC->LineTo(interval*i,650); } //////////////////// placing computers /////////////// for(int tempcntr=0;tempcntr<cmcount;tempcntr++) { if(cmlabid[tempcntr]==crlabid) { long xx1=cmpt[tempcntr].x,yy1=cmpt[tempcntr].y; /////////////// place computer img ///////////////////// /// ........................... rect.left=yy1*(650/crclmns); rect.top=xx1*(650/crrows); rect.bottom=(xx1+1)*(650/crrows); rect.right=(yy1+1)*(650/crclmns); //} pControlDC->FillRect(rect,pBrush); pControlDC->Draw3dRect(rect,COLORREF(RGB(255,0,0)),COLORREF(RGB(255,0,0))); /////////////// place computer img ///////////////////// } } //////////////////// placing computers /////////////// }break; } pWnd->ReleaseDC(pControlDC); //////////////////////////////////////////////////////////////////////////////////////// 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(); } }
BOOL CStageGripperDlg::YoInitDialog() { CFrameWnd *pMainFrame = GetTopLevelFrame(); CView *pView = pMainFrame->GetActiveView(); CStageDoc *pDoc = ((CStageView *)pView)->GetDocument(); int dWidth; int dHeight; RECT rect; RECT mfRect; CREATESTRUCT cs; char s[128]; CWnd *pCBox; m_init = TRUE; CDialog::OnInitDialog(); // TODO: Add extra initialization here cs.cy = ::GetSystemMetrics(SM_CYSCREEN); cs.cx = ::GetSystemMetrics(SM_CXSCREEN); this->GetWindowRect(&rect); dWidth = (rect.right - rect.left); dHeight = rect.bottom - rect.top; ((CMainFrame *)pMainFrame)->m_viewPart->GetWindowRect(&mfRect); //rect.right = YO_MIN(mfRect.right + dWidth, cs.cx); //rect.left = rect.right - dWidth; rect.top = YO_MIN(mfRect.bottom, cs.cy - dHeight); rect.bottom = rect.top + dHeight; rect.left = mfRect.left; rect.right = rect.left + dWidth; //rect.right -= 3; //rect.left -= 3; //rect.top -= 8; //rect.bottom -= 8; this->MoveWindow(&rect, TRUE); sprintf(s, "%.3f", ((CStageGripper *)pDoc->m_currentDevice)->m_displacementOpen); pCBox = (CComboBox*)this->GetDlgItem(IDC_GRIPPER_DISPLACEMENT_OPEN); pCBox->SetWindowText(s); pCBox->UpdateWindow(); sprintf(s, "%.3f", ((CStageGripper *)pDoc->m_currentDevice)->m_displacementClose); pCBox = (CComboBox*)this->GetDlgItem(IDC_GRIPPER_DISPLACEMENT_CLOSE); pCBox->SetWindowText(s); pCBox->UpdateWindow(); if (((CStageGripper *)pDoc->m_currentDevice)->m_typeTranslating == TRUE) { pCBox = (CComboBox*)this->GetDlgItem(IDC_GRIPPER_TYPE_TRANSLATING); ((CButton *)pCBox)->SetCheck(1); pCBox = (CComboBox*)this->GetDlgItem(IDC_GRIPPER_TYPE_ROTATING); ((CButton *)pCBox)->SetCheck(0); } else { pCBox = (CComboBox*)this->GetDlgItem(IDC_GRIPPER_TYPE_TRANSLATING); ((CButton *)pCBox)->SetCheck(0); pCBox = (CComboBox*)this->GetDlgItem(IDC_GRIPPER_TYPE_ROTATING); ((CButton *)pCBox)->SetCheck(1); } UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
//--------------------------------------------------------------------------- BOOL ReportView::OnPreparePrinting(CPrintInfo* pInfo) { if(pInfo->m_bPreview) { return this->DoPreparePrinting(pInfo); } //if(!mPrintMultiple) { pInfo->m_bDirect = this->mPrintDirect; this->GetParentFrame()->SetActiveWindow(); this->GetParentFrame()->BringWindowToTop(); //this->SetActiveWindow(); //this->BringWindowToTop(); return this->DoPreparePrinting(pInfo); //} // printing from print multiple reports C_Main_Frame* lMainFramePtr = MainFramePtr(); if (mDibViewPtr == NULL) { mDibViewPtr = lMainFramePtr->Create_Dib_Window(); } CWnd* lFramePtr = this->GetParent(); ASSERT( lFramePtr != NULL ); //--- Save existing placement --- WINDOWPLACEMENT lSavePlacement; lFramePtr->GetWindowPlacement( & lSavePlacement ); //--- Compute and set print placement --- /*lFramePtr->ShowWindow( SW_RESTORE ); this->ResizeParentToFit( FALSE );*/ WINDOWPLACEMENT lPrintPlacement; lFramePtr->GetWindowPlacement( & lPrintPlacement ); // JTK - Commented out to fix print preview issue /*lPrintPlacement.rcNormalPosition.right -= lPrintPlacement.rcNormalPosition.left; lPrintPlacement.rcNormalPosition.bottom -= lPrintPlacement.rcNormalPosition.top ; lPrintPlacement.rcNormalPosition.left = 0; lPrintPlacement.rcNormalPosition.top = 0; lFramePtr->MoveWindow(&lPrintPlacement.rcNormalPosition); lFramePtr->SetWindowPlacement( & lPrintPlacement );*/ //--- Create the DIB --- lFramePtr->SetActiveWindow(); lFramePtr->BringWindowToTop(); lFramePtr->UpdateWindow(); mDibViewPtr->LoadDib(lFramePtr); //--- Call normal printing --- pInfo->m_bDirect = mPrintDirect; BOOL lPrintResult = mDibViewPtr->OnPreparePrinting( pInfo ); //--- Restore the window --- lFramePtr->SetWindowPlacement( & lSavePlacement ); lFramePtr->ShowWindow( lSavePlacement.showCmd ); lFramePtr->UpdateWindow(); return lPrintResult; }
/*--------------------------------------*/ void CFrontier_API_SVDlg::OnPaitMap(void) { 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(); } int m_CXpos=0,m_CYpos=0,m_CorYLenth = 160,m_CorXLenth = 160; int GraphLimit; struct { int RobRadia;// 机器人的半径 }VisRobot = {25};// 机器人的图形显示参数 CRect rect2,rect3; CWnd* pWnd = GetDlgItem(IDC_LOCDRAW);// CDC* pControlDC = pWnd->GetDC(); pWnd->Invalidate(); pWnd->UpdateWindow(); pWnd->GetWindowRect(rect2); m_CXpos = (rect2.right-rect2.left)/2; m_CYpos = (rect2.bottom-rect2.top)/2; GraphLimit = 150; pControlDC->MoveTo(m_CXpos,m_CYpos-m_CorYLenth);// 机器人朝向,纵轴 pControlDC->LineTo(m_CXpos,m_CYpos+m_CorYLenth); pControlDC->SelectStockObject(LTGRAY_BRUSH);//LTGRAY_BRUSH pControlDC->Ellipse(m_CXpos-5, m_CYpos-m_CorYLenth-5,m_CXpos+5, m_CYpos-m_CorYLenth+5 ); pControlDC->MoveTo(m_CXpos-m_CorXLenth,m_CYpos);// 机器人横轴 pControlDC->LineTo(m_CXpos+m_CorXLenth,m_CYpos); pControlDC->SelectStockObject(LTGRAY_BRUSH);//LTGRAY_BRUSH pControlDC->Ellipse(m_CXpos-m_CorXLenth-5, m_CYpos-5,m_CXpos-m_CorXLenth+5, m_CYpos+5 ); pControlDC->SelectStockObject(HOLLOW_BRUSH);//LTGRAY_BRUSH pControlDC->Ellipse(m_CXpos-140-VisRobot.RobRadia, m_CYpos-140-VisRobot.RobRadia,m_CXpos+140+VisRobot.RobRadia, m_CYpos+140+VisRobot.RobRadia); // 远处 pControlDC->Ellipse(m_CXpos-20-VisRobot.RobRadia, m_CYpos-20-VisRobot.RobRadia,m_CXpos+20+VisRobot.RobRadia,m_CYpos+20+VisRobot.RobRadia); //近处 float temp_dist,temp_ang; int temp_far,temp_near; temp_far = 2500; temp_near = 300; int m_tempXPos; int m_tempYPos; BOOL temp_Blob[6]; temp_Blob[0] = m_Blob1; temp_Blob[1] = m_Blob2; temp_Blob[2] = m_Blob3; temp_Blob[3] = m_Blob4; temp_Blob[4] = m_Blob5; temp_Blob[5] = m_Blob6; UpdateData(TRUE); /*------目标物显示------*/ for (int k=0;k<6;k++) { if (temp_Blob[k] && VisionBlob[k][0].area>0) { DISTANG temp_DistAng; memcpy(&temp_DistAng,&VisionDistAng[k][0],sizeof(temp_DistAng)); CPen pen,*ppen; COLORREF ObjColor; ObjColor = ColorHLSToRGB((WORD)VisionBlob[k][0].hue,150,240); pen.CreatePen(PS_SOLID,1,ObjColor); CBrush ObjBrush; ObjBrush.CreateSolidBrush(ObjColor); pControlDC->SelectObject(&ObjBrush); ppen = pControlDC->SelectObject(&pen); if (temp_DistAng.Dist >= temp_far) { temp_dist = (float)temp_far; } else if (temp_DistAng.Dist <= temp_near) { temp_dist = (float)temp_near; } else { temp_dist = (float)temp_DistAng.Dist; } temp_dist = (temp_dist-temp_near)*120/(temp_far-temp_near+300)+(20+VisRobot.RobRadia); temp_ang = temp_DistAng.Angle; m_tempXPos = (int)(m_CXpos - temp_dist*sin(temp_ang*PI/180)); m_tempYPos = (int)(m_CYpos - temp_dist*cos(temp_ang*PI/180)); if (m_bVision) pControlDC->Ellipse(m_tempXPos-10,m_tempYPos-10,m_tempXPos+10,m_tempYPos+10); pen.DeleteObject(); ppen->DeleteObject(); } } pWnd->ReleaseDC(pControlDC); }