Ejemplo n.º 1
0
BOOL CMainToolBar::OnDrop(COleDataObject *pDataObject, DROPEFFECT dropEffect,
                          CPoint point) {
  int cmd_id = HitTestButton(point);
  if (cmd_id == ID_RECYCLEBIN) {
    FileOperation(this, m_DropFiles, FO_DELETE, FOF_ALLOWUNDO, NULL);
    return TRUE;
  }

  if (cmd_id == ID_MYDOCUMENTS) {
    UINT file_oper = FO_COPY;

    switch (dropEffect) {
    case DROPEFFECT_COPY:
      file_oper = FO_COPY;
      break;

    case DROPEFFECT_MOVE:
      file_oper = FO_MOVE;
      break;
    case DROPEFFECT_LINK:
      return CreateShortcuts(m_DropFiles, m_LastDropFolder);

    default:
      TRACE(_T("Invalide file operation %d\n"), dropEffect);
      return false;
    }

    FileOperation(this, m_DropFiles, file_oper, FOF_ALLOWUNDO,
                  m_LastDropFolder);
    return TRUE;
  }

  return false;
}
LRESULT CXTPSkinObjectFrame::HandleNcHitTest(CPoint point)
{
    ScreenToFrame(&point);

    DWORD dwStyle = GetStyle();

    if ((dwStyle & WS_VSCROLL) && m_spi[SB_VERT].fVisible && ::PtInRect(&m_spi[SB_VERT].rc, point))
        return (LRESULT)HTVSCROLL;

    if ((dwStyle & WS_HSCROLL) &&m_spi[SB_HORZ].fVisible && ::PtInRect(&m_spi[SB_HORZ].rc, point))
        return (LRESULT)HTHSCROLL;

    if ((dwStyle & WS_VSCROLL) && m_spi[SB_VERT].fVisible && (dwStyle & WS_HSCROLL) && m_spi[SB_HORZ].fVisible && IsSizeBox())
    {
        CRect rcSizeGripper(m_spi[SB_HORZ].rc.right, m_spi[SB_VERT].rc.bottom,
                            m_spi[SB_VERT].rc.right, m_spi[SB_HORZ].rc.bottom);

        if (rcSizeGripper.PtInRect(point))
            return GetExStyle() & WS_EX_LAYOUTRTL ? HTBOTTOMLEFT : HTBOTTOMRIGHT;
    }

    CCaptionButton* pButtonHot = HitTestButton(point);

    if (pButtonHot)
    {
        return pButtonHot->m_nHTCode;
    }

    return (LRESULT)HTNOWHERE;
}
void CXTPSkinObjectFrame::TrackCaptionButton()
{
    SetCapture();
    BOOL bAccept = FALSE;
    m_pButtonPressed = m_pButtonHot;
    CCaptionButton* pButtonPressed = m_pButtonHot;
    ASSERT(pButtonPressed);

    RedrawFrame();

    while (::GetCapture() == m_hWnd)
    {
        MSG msg;

        if (!::GetMessage(&msg, NULL, 0, 0))
        {
            AfxPostQuitMessage((int)msg.wParam);
            break;
        }

        if (msg.message == WM_LBUTTONUP)
        {
            bAccept = m_pButtonPressed == pButtonPressed;
            break;
        }
        else if (msg.message == WM_NCMOUSELEAVE)
        {

        }
        else if (msg.message == WM_MOUSEMOVE)
        {
            POINT point = msg.pt;
            ScreenToFrame(&point);

            CCaptionButton* pButton = HitTestButton(point) == pButtonPressed ? pButtonPressed : NULL;

            if (pButton != m_pButtonPressed)
            {
                m_pButtonPressed = pButton;
                RedrawFrame();
            }
        }
        else
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    m_pButtonPressed = NULL;
    m_pButtonHot = NULL;
    ReleaseCapture();
    RedrawFrame();

    if (bAccept)
    {
        SendMessage(WM_SYSCOMMAND, pButtonPressed->m_nCommand);
    }
}
BOOL CXTPSkinObjectFrame::HandleMouseMove(CPoint point)
{
    CPoint ptClient(point);
    ScreenToFrame(&ptClient);

    CCaptionButton* pButton = HitTestButton(ptClient);

    if (m_pButtonHot != pButton)
    {
        if (m_pButtonHot && !pButton)
            CancelMouseLeaveTracking();

        m_pButtonHot = pButton;
        InvalidateButtons();

        if (m_pButtonHot)
        {
            SetTimer(XTP_TID_MOUSELEAVE, 50, &OnTimerInternal);
            return  TRUE;
        }
    }

    if (m_pSBTrack)
        return TRUE;

    BOOL bResult = FALSE;
    for (int i = 0; i < 2; i++)
    {
        XTP_SKINSCROLLBARPOSINFO* pSBInfo = &m_spi[i];
        int ht = HitTestScrollBar(pSBInfo, ptClient);

        if (ht != pSBInfo->ht && pSBInfo->fVisible)
        {
            if (pSBInfo->ht != HTNOWHERE && ht == HTNOWHERE && !bResult)
            {
                CancelMouseLeaveTracking();
            }

            pSBInfo->ht = ht;
            RedrawScrollBar(pSBInfo);
        }

        if (ht != HTNOWHERE)
        {
            SetTimer (XTP_TID_MOUSELEAVE, 50, &OnTimerInternal);
            bResult = TRUE;
        }
    }

    return bResult;
}
Ejemplo n.º 5
0
DROPEFFECT CMainToolBar::OnDragOver(COleDataObject *pDataObject,
                                    DWORD dwKeyState, CPoint point) {
  DROPEFFECT dwEffect = DROPEFFECT_NONE;

  int cmd_id = HitTestButton(point);
  if (cmd_id == ID_RECYCLEBIN)
    dwEffect = DROPEFFECT_MOVE;

  if (cmd_id == ID_MYDOCUMENTS) {
    dwEffect =
        CalcDropEffect(m_DropFiles, m_LastDropFolder, m_DropFolder, dwKeyState);
  }

  return dwEffect;
}
Ejemplo n.º 6
0
DROPEFFECT CMainToolBar::OnDragEnter(COleDataObject *pDataObject,
                                     DWORD dwKeyState, CPoint point) {
  m_DropFiles.clear();
  m_LastDropFolder.Empty();
  TCHAR path[2094];
  SHGetSpecialFolderPath(m_hWnd, path, CSIDL_PERSONAL, FALSE);
  m_LastDropFolder = path;
  //	m_LastDropFolder.MakeLower ();
  SureBackSlash(m_LastDropFolder);
  if (ReadHDropData(pDataObject, m_DropFiles, m_DropFolder)) {
    int cmd_id = HitTestButton(point);
    if (cmd_id == ID_RECYCLEBIN)
      return DROPEFFECT_MOVE;

    if (cmd_id == ID_MYDOCUMENTS) {
      return CalcDropEffect(m_DropFiles, m_LastDropFolder, m_DropFolder,
                            dwKeyState);
    }
  }

  return DROPEFFECT_NONE;
}