MouseMove

1 . void  CRaku2ScrollView::LoadMoveSmallBK()
{    
    CDC 
*pDC = GetDC();
    
int m=    nBinderRectcopy.right - nBinderRectcopy.left;
    
int n=    nBinderRectcopy.bottom - nBinderRectcopy.top;
    
    CBitmap bitmap;
    bitmap.LoadBitmap( IDB_BINDER_SMALLL);
    
    BITMAP bmp;
    bitmap.GetBitmap(
&bmp);
    
    CDC m_MemoryDC;
    m_MemoryDC.CreateCompatibleDC(pDC);
    m_MemoryDC.SelectObject(
&bitmap);
    pDC
->BitBlt( nBinderRectcopy.left, 
        nBinderRectcopy.top,
        m,n,
&m_MemoryDC, 00,
        SRCCOPY );    
    CBitmap bitmap2;
    bitmap2.LoadBitmap(IDB_BINDER_SMALLR);
    
    BITMAP bmp2;
    bitmap2.GetBitmap(
&bmp2);
    
    CDC m_MemoryDC2;
    m_MemoryDC2.CreateCompatibleDC(pDC);
    
    m_MemoryDC2.SelectObject(
&bitmap2);
    
    pDC
->BitBlt( nBinderRectcopy.left+m-13
        nBinderRectcopy.top
+2,
        m,n,
&m_MemoryDC2, 00,
        SRCCOPY );

}


void  CRaku2ScrollView::LoadMoveBk()
{
    CDC 
*pDC = GetDC();
    
int m=    nBinderRectcopy.right - nBinderRectcopy.left;
    
int n=    nBinderRectcopy.bottom - nBinderRectcopy.top;
    
    CBitmap bitmap;
    bitmap.LoadBitmap( IDB_BINDER_NEW);
    
    BITMAP bmp;
    bitmap.GetBitmap(
&bmp);
    
    CDC m_MemoryDC;
    m_MemoryDC.CreateCompatibleDC(pDC);
    m_MemoryDC.SelectObject(
&bitmap);
    pDC
->BitBlt( nBinderRectcopy.left, 
        nBinderRectcopy.top,
        m,n,
&m_MemoryDC, 00,
        SRCCOPY );    
    CBitmap bitmap2;
    bitmap2.LoadBitmap(IDB_BINDER_RF);
    
    BITMAP bmp2;
    bitmap2.GetBitmap(
&bmp2);
    
    CDC m_MemoryDC2;
    m_MemoryDC2.CreateCompatibleDC(pDC);
    
    m_MemoryDC2.SelectObject(
&bitmap2);
    
    pDC
->BitBlt( nBinderRectcopy.left+m-15
        nBinderRectcopy.top,
        m,n,
&m_MemoryDC2, 00,
        SRCCOPY );
    

}

2
void  CRaku2ScrollView::MouseMoveChange()
{CDC *pDC = GetDC();
int m=    nBinderRectcopy.right - nBinderRectcopy.left;
int n=    nBinderRectcopy.bottom - nBinderRectcopy.top;
int c=15;
    
if (m_moveflag)
    
{
        
if( m_iShowMode == ONE_SHOW_MODE)
        
{
        LoadMoveBk();
        
//    LoadMoveBk(IDB_BINDER_RF);
            
//    DrawBmpObject(pDC, nBinderRect, m_pBinderKindBmpF);
        }

        
        
else 
                
{LoadMoveSmallBK();
            
//    LoadMoveBk(IDB_BINDER_SMALLBK);
                
//    DrawBmpObject(pDC, nBinderRect, m_pBinderSmallKindBmpF[pBinderInfo->iBackColor - 1]);
                }

        m_moveflag
=false;
            
    }

    
else
    
{
//    InvalidateRect(FALSE);
    /*
        if( m_iShowMode == ONE_SHOW_MODE)
                {
                    DrawBmpObject(pDC,nBinderRectcopy,m_pBinderKindBmp[BinderInfoCopy->iBackColor - 1]);
                }
                else 
                {
                    DrawBmpObject(pDC,nBinderRectcopy,m_pBinderSmallKindBmp[BinderInfoCopy->iBackColor - 1]);
                }
*/

    
    
    }

3.void CRaku2ScrollView::OnMouseMove(UINT nFlags, CPoint point) 
{  // flag=0;
    
// TODO: Add your message handler code here and/or call default
    
//    CScrollView::OnMouseMove(nFlags, point);
    
//start丂003
    BOOL bFind = FALSE;
    CRect nBinderRect(
0,0,0,0);
    CRect nWndRect(
0,0,0,0);
    
int      iBinderPos     = 0;    
    
int      iScrollLeftPos = GetScrollPos( SB_HORZ );
    
int   iScrollTopPos  = GetScrollPos( SB_VERT );
    
int   i = 0;
     
//m_iMovePicture=TRUE;//kqy 

    nWndRect 
= m_nMaxViewRect;

    BINDERINFO        BinderInfo;
    memset(
&BinderInfo,0,sizeof(BinderInfo));
    
/*
    if(m_iShowMode == ONE_SHOW_MODE)
        {
            goto DRAG_DROP;
        }
*/

    
    
//#032 end 僣乕儖僠僢僾昞帵
       if ((m_dwMousePress&LBUTTON_PRESSED) && !(nFlags & MK_CONTROL))    
    
{
        
goto DRAG_DROP;
    }

    
//end丂003
//m_moveflag=1;
//KQY start
//    if(m_moveflag%2==1)
//{   //CString str1,str2;//kqy
   
  
/*
   for(i = 0;i < m_iBinderTotal; i++)
         {  
              BinderInfo      = m_BinderInfoArray.GetAtBinder(i);
             // now selected binder
             iBinderPos      = BinderInfo.iBinderPos;
             
             nBinderRect        = GetSelBinderRect(nWndRect,iBinderPos);
             //Get the relative size of the selected rect when scrolling
             nBinderRect.OffsetRect(-iScrollLeftPos, -iScrollTopPos);
             //selected
         //    if(!nBinderRect.PtInRect(point) )
             //SetCapture();
             if(nBinderRect.PtInRect(point) == TRUE )
             {      //    m_moveflag++;
         //    if(m_moveflag%2==0)
                 m_moveflag=1;
                 InvalidateRect(nBinderRect,FALSE);
         //    UpdateWindow();
             
         //    InvalidateRect(nBinderRect,FALSE);
             }
             //else m_moveflag=0;
     //    ReleaseCapture();
             //else     m_moveflag++;
        }
     
  
*/

  
  
// }

         
// InvalidateRect(nBinderRect,FALSE);
            
//摨偠僶僀儞僟偺忋偱堏摦偡傞
        
//    if(m_iCurrentBinderID == i)
        
//    { 
        
//    if(m_iTimerID == 0 && m_bDisplayingHint == FALSE && m_bDisplayedHint == FALSE)
        
//    {
                    
//set display timer
        
//        m_iTimerID = SetTimer(SHOW_HINT_TIMER, WAIT_TIME, 0);
                    
//record the mouse point
            
//        m_pMousePoint = point;            
        
//    }
            
//UpdateWindow();
        
//    }
        
            
//str1.Format("%d",iBinderPos );//kqy
        
//    str2.Format("%d,%d",point.x,point.y );//kqy    
        
//    AfxMessageBox(str2);//kqy
        
//    AfxMessageBox(str1+"Now Reddraw");//kqy
    
//    OnEraseBkgnd()
    
//    InvalidateRect(nBinderRect,FALSE);
            
         
// Redraw();
        
// ((CMainFrame*)AfxGetMainWnd())->OnBinderNew();
    
//    ((CMainFrame*)AfxGetMainWnd())->OnBinderMoveChange();
//        }
    
//    else m_moveflag=false;
        
         
//    m_moveflag=false;
        
//    else flag=false;
            
//    }
  
//    }
    
//kqy end

    
//#032 start 僣乕儖僠僢僾昞帵

      
//find the binder inclue the point
    
    
for(i = 0;i < m_iBinderTotal; i++)
    
{   
        BinderInfo      
= m_BinderInfoArray.GetAtBinder(i);
        
// now selected binder
        iBinderPos      = BinderInfo.iBinderPos;
        nBinderRect        
= GetSelBinderRect(nWndRect,iBinderPos);
        
//Get the relative size of the selected rect when scrolling
        nBinderRect.OffsetRect(-iScrollLeftPos, -iScrollTopPos);
        
//selected

        
if(nBinderRect.PtInRect(point) == TRUE)
        

                  
//InvalidateRect(nBinderRect,FALSE);
                m_moveflag=1;
                
if(    m_moveflag==1)
                
{    nBinderRectcopy=nBinderRect;
                   
//  *BinderInfoCopy=BinderInfo ;
                MouseMoveChange();
            
            
                }

                
            
//    UpdateWindow();
            
//摨偠僶僀儞僟偺忋偱堏摦偡傞
            if(m_iCurrentBinderID == i)
            
{
                
if(m_iTimerID == 0 && m_bDisplayingHint == FALSE && m_bDisplayedHint == FALSE)
                
{
                    
//set display timer
                    m_iTimerID = SetTimer(SHOW_HINT_TIMER, WAIT_TIME, 0);
                    
//record the mouse point
                    m_pMousePoint = point;
                }
    
              

            }

             
            
//懠偺僶僀儞僟傊堏摦偡傞
            else
            
{   
            
                
//record the new binder id
                m_iCurrentBinderID = i;
                
//check the hint window displaying
                if(m_bDisplayingHint == TRUE)
                
{
                    
//hide the hint window
                    m_lpBinderHintWnd->ShowWindow(SW_HIDE);
                    m_bDisplayingHint 
= FALSE;
                }

                
if( m_iTimerID != 0)
                
{
                    KillTimer(m_iTimerID);
                    m_iTimerID 
= 0;
                }

                m_bDisplayedHint 
= FALSE;
            }

            
//find the binder
            bFind = TRUE;
        
            
break;
        }
   
        
else{    //MousePressOP(nFlags, point, 1);
    
//    TRACE0("LBUTTON DOWN\n");
            
//m_moveflag=0;
    InvalidateRect(nBinderRect,FALSE);
            
//m_pBinderSmallKindBmp[i].LoadBitmap(szBmpFilePath);
        
//    DrawBinderBackground(m_iShowMode,i,i);
            
//    DrawBmpObject(&m_MemoryDC,nBinderRect,m_BinderWndBackBmp1);
        }

        
//m_moveflag=0;
        
//    goto DRAG_DROP;
    
    }


    
//not find the binder
    if(bFind == FALSE)
    
{  
        m_iCurrentBinderID 
= -1;

        
//check the hint window displaying
        if(m_bDisplayingHint == TRUE)
        
{      
            
//hide the hint window
            m_lpBinderHintWnd->ShowWindow(SW_HIDE);
            m_bDisplayingHint 
= FALSE;
            InvalidateRect(nBinderRect,FALSE);
        }

    }



DRAG_DROP:


    
if ((m_dwMousePress&LBUTTON_PRESSED) && !(nFlags & MK_CONTROL) && !(nFlags & MK_SHIFT)
        
&& (MK_LBUTTON & nFlags))    
    
{
        m_bDragDrop 
= true;
        StartDragDrop(point);
        ReleaseCapture();
    }

    
    
else if (nFlags & MK_LBUTTON)
    
{
        SIZE szDrag;
        szDrag.cx 
= GetSystemMetrics(SM_CXDRAG);
        szDrag.cy 
= GetSystemMetrics(SM_CYDRAG);
        
if (abs(m_ptLast.x - point.x) > szDrag.cx ||
            abs(m_ptLast.y 
- point.y) > szDrag.cy)
        
{
            
if (!m_bDragSelStart)
            
{
            
//    if (!(nFlags & MK_CONTROL))
            
//    {
            
//        m_selBinderID.RemoveAll();
            
//    }
                m_bDragSelStart = TRUE;
                m_selBinderID.SetDragStartPoint(point);
                m_selBinderID.CreateTracker();
                
//drag selection rectangle here
            }

            
else 
            
{
                CDC 
* pDC = GetDC();
                m_selBinderID.DrawRectTracker(pDC, point, 
this);
                ReleaseDC(pDC);
            }

        }

    }

    
    m_dwMousePress    
= NOT_PRESSED;
    CScrollView::OnMouseMove(nFlags, point);
    UpdateWindow();
    
//    KillTimer( m_id );    
}

你可能感兴趣的:(move)