Ejemplo n.º 1
0
void KKSliderVolume::updateLayout()
{
	m_sliderPannel->setFixSize(m_popupSize);
	m_pWindow->setWindowSize(m_popupSize);
	QPointF offsetPt(0, height());
	m_pWindow->setPosOffset(offsetPt);
	m_pWindow->adjustGeometry();
	m_pWindow->setFixedWidth(m_popupSize.width());
}
Ejemplo n.º 2
0
void CTreeFileCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	*pResult = 0;

  SelectItem(pNMTreeView->itemNew.hItem);
  if (!IsDropSource(pNMTreeView->itemNew.hItem) || !m_bAllowDragDrop)
    return;

  m_pilDrag = CreateDragImage(pNMTreeView->itemNew.hItem);
  if (!m_pilDrag)
    return;

  m_hItemDrag = pNMTreeView->itemNew.hItem;
  m_hItemDrop = NULL;

  // Calculate the offset to the hotspot
  CPoint offsetPt(8,8);   // Initialize a default offset

  CPoint dragPt = pNMTreeView->ptDrag;    // Get the Drag point
  UINT nHitFlags = 0;
  HTREEITEM htiHit = HitTest(dragPt, &nHitFlags);
  if (htiHit != NULL)
  {
    // The drag point has Hit an item in the tree
    CRect itemRect;
    if (GetItemRect(htiHit, &itemRect, FALSE))
    {
      // Count indent levels
      HTREEITEM htiParent = htiHit;
      int nIndentCnt = 0;
      while (htiParent != NULL)
      {
        htiParent = GetParentItem(htiParent);
        nIndentCnt++;
      }

      if (!(GetStyle() & TVS_LINESATROOT)) 
        nIndentCnt--;

      // Calculate the new offset
      offsetPt.y = dragPt.y - itemRect.top;
      offsetPt.x = dragPt.x - (nIndentCnt * GetIndent()) + GetScrollPos(SB_HORZ);
    }
  }

  //Begin the dragging  
  m_pilDrag->BeginDrag(0, offsetPt);
  POINT pt = pNMTreeView->ptDrag;
  ClientToScreen(&pt);
  m_pilDrag->DragEnter(NULL, pt);
  SetCapture();

  m_nTimerID = SetTimer(1, 300, NULL);
}