void CFlashingWnd::PaintBorder(bool bInvert, bool bDraw) { if ((m_cRect.right <= m_cRect.left) || (m_cRect.bottom <= m_cRect.top)) { return; } COLORREF clrColor = (bDraw & !bInvert) ? m_clrBorderON : m_clrBorderOFF; clrColor = m_clrBorderON; CWindowDC cWindowDC(CWnd::FromHandle(m_hWnd)); cWindowDC.SetROP2(R2_XORPEN); CBrush newbrush; newbrush.CreateSolidBrush(clrColor); CPen newpen; newpen.CreatePen(PS_SOLID, 1, clrColor); CBrush * pOldBrush = cWindowDC.SelectObject(&newbrush); CPen * pOldPen = cWindowDC.SelectObject(&newpen); if (bInvert) { cWindowDC.PatBlt(0, 0, maxxScreen, maxyScreen, PATINVERT); } else { CRect rectNew(m_cRect); rectNew.InflateRect(THICKNESS, THICKNESS); cWindowDC.Rectangle(&rectNew); } cWindowDC.SelectObject(pOldPen); cWindowDC.SelectObject(pOldBrush); }
void ScrollBar::OnHorzTrack(suic::Element* pSender, suic::MouseEventArg& e) { if (!_rcTrack.Empty()) { int iMin = 0; suic::Point ptWindow = e.MousePoint(); suic::Point ptSelf = PointToScreen(suic::Point()); suic::Rect rect(ptSelf.x, ptSelf.y, RenderSize().cx, RenderSize().cy); suic::Size szClamp(0, 0); int nThumbLength = 0; szClamp.cx = rect.left + (_decreaseBtn.IsVisible() ? (int)_decreaseBtn.GetWidth() : 0); szClamp.cy = rect.right - (_increaseBtn.IsVisible() ? (int)_increaseBtn.GetWidth() : 0); nThumbLength = _rcTrackStart.Width(); szClamp.cy -= nThumbLength; suic::Point ptOffset(ptWindow.x - _ptTrackStart.x, ptWindow.y - _ptTrackStart.y); suic::Rect rectNew(_rcTrackStart); if (abs(ptOffset.y) < 150) { rectNew.Offset(ptOffset.x, 0); if (rectNew.left < szClamp.cx) { rectNew.left = szClamp.cx; rectNew.right = rectNew.left + nThumbLength; } else if (szClamp.cy < rectNew.left) { rectNew.left = szClamp.cy; rectNew.right = rectNew.left + nThumbLength; } } if (!rectNew.Equal(&_rcTrack)) { _rcTrack = rectNew; int nPosNew = PosFromThumb(_rcTrack.left - szClamp.cx, szClamp); if (_scroInfo.iVisualPos != nPosNew) { _scroInfo.iVisualPos = nPosNew; DoScroll(true); } } } }
//鼠标移动,移动对象 void CGuiderView::OnMouseMove(UINT nFlags, CPoint point) { // TODO: 在此添加消息处理程序代码和/或调用默认值 CGuiderDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; CDC*pDC=this->GetDC (); int i=0;//判断鼠标位置 if(this->WhetherOnPoint (point.x ,point.y )!=0) //点 i=1; else if(this->WhetherOnRoad (point.x ,point.y )) //边 i=2; /////////////////////////////////////////////////////////////////////////// int sp=sitelist.OnSite(point.x,point.y); Site * s=sitelist.GetOfID(sp); Route *rp=routelist.OnRoute(point.x,point.y); if(i==0) { if(sp!=0) i=3;//是地点 if(rp!=NULL) i=4;//是路径 } ///////////////////////////////////////////////////////////// //...........................................................修改状态栏-方案2-成功 CString str,str1; switch(i) { case 0:str1.Format (L"新建地点...");break; case 1:str1.Format (L"路口");break; case 2:str1.Format (L"路 长度:%d",(int)this->length );break; case 3:str1.Format(L"%s",s->SiteInfo);break; case 4: double l=rp->Length(); l*=2.287; str1.Format(L"%s 长度:%d",rp->RouteInfo,int(l));break; } str.Format (L"%d - %d %s",point.x ,point.y,str1); CStatusBar * pStatus=(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow (ID_VIEW_STATUS_BAR); pStatus->SetPaneText (0,str); ////////////////////////////////////////////////////////////// if(App_Veriable::LBDown==true&&App_Veriable::IsAddingRoute==false)//添加路径不要移动,防止误删!!! { int i=routelist.RemoveRoutesOfSite(App_Veriable::SelectedSiteID);//删除周围路径 if(i!=0)//既保证了移动之前的全屏刷新,又避免了无条件的Move刷新! Invalidate(); //////////////////////////////////////////////删除一起系列的边的时候的处理方法//////////////////////////// CGuiderDoc* pDoc = GetDocument(); pDoc->graph_doc.removev(App_Veriable::SelectedSiteID);//删除点和周围的路径 pDoc->graph_doc.insertv(App_Veriable::SelectedSiteID);//恢复删除的点 Site*s=sitelist.GetOfID(App_Veriable::SelectedSiteID);//找鼠标按下的地点对象 s->Position=point; //Invalidate(); CRect rectOld(App_Veriable::LastMovePoint .x -s->Size ,App_Veriable::LastMovePoint .y -s->Size ,App_Veriable::LastMovePoint .x +s->Size ,App_Veriable::LastMovePoint .y +s->Size ); this->InvalidateRect (rectOld); App_Veriable::LastMovePoint =point; CRect rectNew(App_Veriable::LastMovePoint .x -s->Size,App_Veriable::LastMovePoint .y -s->Size ,App_Veriable::LastMovePoint .x +s->Size,App_Veriable::LastMovePoint .y +s->Size); this->InvalidateRect (rectOld); } ReleaseDC(pDC); CView::OnMouseMove(nFlags, point); }