Exemplo n.º 1
0
void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
{
	int32_t nHitIndex = GetItemIndex(point);

	if (IsMultipleSel())
	{
		if (bCtrl)
		{
			if (m_bCtrlSel)
				m_aSelItems.Add(m_nFootIndex,nHitIndex);
			else
				m_aSelItems.Sub(m_nFootIndex,nHitIndex);

			SelectItems();
		}
		else
		{
			m_aSelItems.DeselectAll();
			m_aSelItems.Add(m_nFootIndex,nHitIndex);
			SelectItems();
		}

		SetCaret(nHitIndex);
	}
	else
	{
		SetSingleSelect(nHitIndex);
	}

	if (!IsItemVisible(nHitIndex))
		ScrollToListItem(nHitIndex);
}
Exemplo n.º 2
0
void CFX_ListCtrl::OnVK(int32_t nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl)
{
	if (IsMultipleSel())
	{
		if (nItemIndex >= 0 && nItemIndex < GetCount())
		{
			if (bCtrl)
			{
			}
			else if (bShift)
			{
				m_aSelItems.DeselectAll();
				m_aSelItems.Add(m_nFootIndex,nItemIndex);
				SelectItems();
			}
			else
			{
				m_aSelItems.DeselectAll();
				m_aSelItems.Add(nItemIndex);
				SelectItems();
				m_nFootIndex = nItemIndex;
			}

			SetCaret(nItemIndex);
		}
	}
	else
	{
		SetSingleSelect(nItemIndex);
	}

	if (!IsItemVisible(nItemIndex))
		ScrollToListItem(nItemIndex);
}
Exemplo n.º 3
0
COptionTreeItem * COptionTree::FocusFirst()
{
	// Declare variable
	COptionTreeItem *otiOld;

	// Set old to focus
	otiOld = m_otiFocus;

	// Set focused item
	SetFocusedItem(m_otiVisibleList);

	// Select items
	if (m_otiFocus != NULL)
	{
		SelectItems(NULL, FALSE);
		m_otiFocus->Select();
	}

	// Notify of selection change
	if (otiOld != m_otiFocus)
	{
		SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus);
	}

	return m_otiFocus;
}
Exemplo n.º 4
0
COptionTreeItem * COptionTree::FocusLast()
{
	// Declare variables
	COptionTreeItem* otiNext;
	COptionTreeItem* otiChange;

	// Set pointers
	otiChange = m_otiFocus;
	otiNext = m_otiVisibleList;

	// Set focu on last
	if (otiNext != NULL)
	{
		while (otiNext->GetNextVisible())
		{
			otiNext = otiNext->GetNextVisible();
		}
		SetFocusedItem(otiNext);

		if (m_otiFocus != NULL)
		{
			SelectItems(NULL, FALSE);
			m_otiFocus->Select();
		}
	}

	// Send notify to user
	if (otiChange != m_otiFocus)
	{
		SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus);
	}

	return otiNext;
}
Exemplo n.º 5
0
CEGPropertyGridItem* CEGPropertyGrid::FocusPrev()
{
	CEGPropertyGridItem* pNext;
	CEGPropertyGridItem* pChange;

	pChange = m_pFocus;

	if (m_pFocus==NULL)
	{
		// get the last visible item
		pNext = m_pVisbleList;
		while (pNext && pNext->GetNextVisible())
			pNext = pNext->GetNextVisible();
	}
	else
	{
		pNext = m_pVisbleList;
		while (pNext && pNext->GetNextVisible()!=m_pFocus)
			pNext = pNext->GetNextVisible();
	}

	if (pNext)
		SetFocusedItem(pNext);
	
	if (m_pFocus)
	{
		SelectItems(NULL, FALSE);
		m_pFocus->Select();
	}

	if (pChange!=m_pFocus)
		SendNotify(PTN_SELCHANGE, m_pFocus);

	return pNext;
}
Exemplo n.º 6
0
CEGPropertyGridItem* CEGPropertyGrid::FocusLast()
{
	CEGPropertyGridItem* pNext;
	CEGPropertyGridItem* pChange;

	pChange = m_pFocus;

	pNext = m_pVisbleList;

	if (pNext)
	{
		while (pNext->GetNextVisible())
			pNext = pNext->GetNextVisible();

		SetFocusedItem(pNext);

		if (m_pFocus)
		{
			SelectItems(NULL, FALSE);
			m_pFocus->Select();
		}
	}

	if (pChange!=m_pFocus)
		SendNotify(PTN_SELCHANGE, m_pFocus);

	return pNext;
}
Exemplo n.º 7
0
CEGPropertyGridItem* CEGPropertyGrid::FocusNext()
{
	CEGPropertyGridItem* pNext;
	CEGPropertyGridItem* pChange;

	pChange = m_pFocus;

	if (m_pFocus==NULL)
		pNext = m_pVisbleList;
	else
	if (m_pFocus->GetNextVisible())
		pNext = m_pFocus->GetNextVisible();
	else
		pNext = NULL;

	if (pNext)
		SetFocusedItem(pNext);

	if (m_pFocus)
	{
		SelectItems(NULL, FALSE);
		m_pFocus->Select();
	}

	if (pChange!=m_pFocus)
		SendNotify(PTN_SELCHANGE, m_pFocus);

	return pNext;
}
Exemplo n.º 8
0
LOCAL void Select_OnMouseMove(HWND hWindow, int x, int y, UINT keyFlags)
/***********************************************************************/
{
RECT rect;

LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;

// if we are above or below the list box, then we are scrolling it, and
// we shouldn't be drawing here              
GetClientRect(hWindow, &rect);        

// see if we are outside the listbox
if ( y < rect.top)
	y = rect.top;
else
if (y >= rect.bottom)
	y = rect.bottom - 1;

// new position changes half way thru items
int iSelect = y / lpData->iItemHeight;

// add top index to get a real index
iSelect += ListBox_GetTopIndex(hWindow);
SelectItems(hWindow, iSelect);
UpdateWindow(hWindow);
}
void CWildcardSelectDialog::OnOk()
{
	TCHAR szPattern[512];

	GetDlgItemText(m_hDlg,IDC_SELECTGROUP_COMBOBOX,
		szPattern,SIZEOF_ARRAY(szPattern));

	if(lstrcmp(szPattern,EMPTY_STRING) != 0)
	{
		SelectItems(szPattern);

		bool bStorePattern = true;

		/* If the current text isn't the same as the
		most recent text (if any), add it to the history
		list. */
		auto itr = m_pwsdps->m_PatternList.begin();

		if(itr != m_pwsdps->m_PatternList.end())
		{
			if(lstrcmp(itr->c_str(),szPattern) == 0)
			{
				bStorePattern = false;
			}
		}

		if(bStorePattern)
		{
			m_pwsdps->m_PatternList.push_front(szPattern);
		}
	}

	EndDialog(m_hDlg,1);
}
Exemplo n.º 10
0
LOCAL void Select_OnTimer(HWND hWindow, UINT id)
/***********************************************************************/
{
POINT pt;                  
int iTopItem;
RECT rect;

LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;
GetCursorPos(&pt); 
// convert the point to client coordinates
ScreenToClient(hWindow, &pt);
iTopItem = ListBox_GetTopIndex(hWindow);
GetClientRect(hWindow, &rect);        
if (pt.y < rect.top) // scroll up
	{
 	if (iTopItem > 0)
 		{
      	iTopItem--;
		// make sure the new top item is selected
		SelectItems(hWindow, iTopItem);
		// scroll the listbox and make sure it gets repainted
		ListBox_SetTopIndex(hWindow, iTopItem);
		UpdateWindow(hWindow);
 		}                  
	}
else if (pt.y > rect.bottom) // scroll down
	{                       
	// see if there is anything to scroll
  	if (lpData->iVisible + iTopItem < lpData->iCount)
  		{                                
	  	// scroll down and make sure it gets repainted
      	iTopItem++;
		// make sure the new bottom item is selected
		SelectItems(hWindow, iTopItem+lpData->iVisible-1);
		// scroll the listbox and make sure it gets repainted
		ListBox_SetTopIndex(hWindow, iTopItem);
		UpdateWindow(hWindow);
	  	}
	}
}
Exemplo n.º 11
0
void CFX_ListCtrl::Select(int32_t nItemIndex) {
  if (!IsValid(nItemIndex))
    return;

  if (IsMultipleSel()) {
    m_aSelItems.Add(nItemIndex);
    SelectItems();
  } else {
    SetSingleSelect(nItemIndex);
  }
}
Exemplo n.º 12
0
void CFX_ListCtrl::OnMouseDown(const CFX_PointF& point,
                               bool bShift,
                               bool bCtrl) {
  int32_t nHitIndex = GetItemIndex(point);

  if (IsMultipleSel()) {
    if (bCtrl) {
      if (IsItemSelected(nHitIndex)) {
        m_aSelItems.Sub(nHitIndex);
        SelectItems();
        m_bCtrlSel = false;
      } else {
        m_aSelItems.Add(nHitIndex);
        SelectItems();
        m_bCtrlSel = true;
      }

      m_nFootIndex = nHitIndex;
    } else if (bShift) {
      m_aSelItems.DeselectAll();
      m_aSelItems.Add(m_nFootIndex, nHitIndex);
      SelectItems();
    } else {
      m_aSelItems.DeselectAll();
      m_aSelItems.Add(nHitIndex);
      SelectItems();

      m_nFootIndex = nHitIndex;
    }

    SetCaret(nHitIndex);
  } else {
    SetSingleSelect(nHitIndex);
  }

  if (!IsItemVisible(nHitIndex))
    ScrollToListItem(nHitIndex);
}
Exemplo n.º 13
0
COptionTreeItem * COptionTree::FocusPrev()
{
	// Declare variables
	COptionTreeItem* otiNext;
	COptionTreeItem* otiChange;

	// Set pointers
	otiChange = m_otiFocus;

	// Get the last visible item
	if (m_otiFocus == NULL)
	{
		otiNext = m_otiVisibleList;
		while (otiNext && otiNext->GetNextVisible())
		{
			otiNext = otiNext->GetNextVisible();
		}
	}
	else
	{
		otiNext = m_otiVisibleList;
		while (otiNext && otiNext->GetNextVisible() != m_otiFocus)
		{
			otiNext = otiNext->GetNextVisible();
		}
	}

	// Set focus items
	if (otiNext)
	{
		SetFocusedItem(otiNext);
	}
	
	// Select items
	if (m_otiFocus != NULL)
	{
		SelectItems(NULL, FALSE);
		m_otiFocus->Select();
	}

	// Send notify to user
	if (otiChange != m_otiFocus)
	{
		SendNotify(OT_NOTIFY_SELCHANGE, m_otiFocus);
	}

	return otiNext;
}
Exemplo n.º 14
0
CEGPropertyGridItem* CEGPropertyGrid::FocusFirst()
{
	CEGPropertyGridItem *pold;

	pold = m_pFocus;

	SetFocusedItem(m_pVisbleList);

	if (m_pFocus)
	{
		SelectItems(NULL, FALSE);
		m_pFocus->Select();
	}

	if (pold!=m_pFocus)
		SendNotify(PTN_SELCHANGE, m_pFocus);

	return m_pFocus;
}
Exemplo n.º 15
0
void PropertyTree::OnLButtonDblClk(UINT, CPoint point)
{
    SendNotify(NM_DBLCLK);

    PropertyTreeItem* pItem;

    if ( (pItem = FindItem(point))!=NULL )
    {
        if ( pItem->IsRootLevel() )
        {
            if (pItem->GetChild() && !SendNotify(PTN_ITEMEXPANDING, pItem))
            {
                pItem->Expand(!pItem->IsExpanded());

                UpdateScrollbar();
                Invalidate();
                UpdateWindow();
                CheckVisibleFocus();
            }

            return;
        }

        PropertyTreeItem* pOldFocus = GetFocusedItem();
        SelectItems(NULL, FALSE);
        SetFocusedItem(pItem);

        pItem->Select();

        Invalidate();

        if ( !pItem->IsRootLevel() && pItem != pOldFocus )
            SendNotify(PTN_SELCHANGE, pItem);
    }

}
Exemplo n.º 16
0
LOCAL void Select_OnKeyDown(HWND hWindow, UINT vk, BOOL fDown, int cRepeat, UINT flags)
/***********************************************************************/
{
int iCaretIndex, iTopItem, nItems;

// get the listbox data pointer
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	{
	FORWARD_WM_KEYDOWN(hWindow, vk, cRepeat, flags, ListBox_CallWindowProc);
	}
else
if (vk == VK_UP)
	{
	iTopItem = ListBox_GetTopIndex(hWindow);
	iCaretIndex = ListBox_GetCaretIndex(hWindow);
	--iCaretIndex;
	if (iCaretIndex < 0)
		return;
	// make sure the new top item is selected
	SelectItems(hWindow, iCaretIndex);
	// scroll the listbox and make sure it gets repainted
	if (iCaretIndex < iTopItem)
		ListBox_SetTopIndex(hWindow, iCaretIndex);
	UpdateWindow(hWindow);
	FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
					hWindow, LBN_SELCHANGE, SendMessage);
	}
else
if (vk == VK_DOWN)
	{
	RECT rect;
	int iItemHeight, iVisible;

	iTopItem = ListBox_GetTopIndex(hWindow);
	iCaretIndex = ListBox_GetCaretIndex(hWindow);
	++iCaretIndex;
	nItems = ListBox_GetCount(hWindow);
	if (iCaretIndex >= nItems)
		return;
	// make sure the new top item is selected
	SelectItems(hWindow, iCaretIndex);

	// get the client area
	GetClientRect(hWindow, &rect);        
  
	// the height of each item   
	iItemHeight = ListBox_GetItemHeight(hWindow, 0);          

	// the number of visible items                  
	iVisible = (rect.bottom - rect.top) / iItemHeight;

	// see if there is anything to scroll
	if (iCaretIndex >= (iTopItem+iVisible))	
		{
		++iTopItem;
		ListBox_SetTopIndex(hWindow, iTopItem);
		}
	UpdateWindow(hWindow);
	FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
					hWindow, LBN_SELCHANGE, SendMessage);
	}
// ignore all other keystrokes
}
Exemplo n.º 17
0
void CTreeCtrlEx::SelectMultiple( HTREEITEM hClickedItem, UINT nFlags, CPoint point )
{
	// Start preparing an NM_TREEVIEW struct to send a notification after selection is done
	NM_TREEVIEW tv;
	memset(&tv.itemOld, 0, sizeof(tv.itemOld));

	CWnd* pWnd = GetParent();

	HTREEITEM hOldItem = GetSelectedItem();

	if ( hOldItem )
	{
		tv.itemOld.hItem = hOldItem;
		tv.itemOld.state = GetItemState( hOldItem, 0xffffffff );
		tv.itemOld.lParam = GetItemData( hOldItem );
		tv.itemOld.mask = TVIF_HANDLE|TVIF_STATE|TVIF_PARAM;
	}

	// Flag signaling that selection process is NOT complete.
	// (Will prohibit TVN_SELCHANGED from being sent to parent)
	m_bSelectionComplete = FALSE;

	// Action depends on whether the user holds down the Shift or Ctrl key
	if ( nFlags & MK_SHIFT )
	{
		// Select from first selected item to the clicked item
		if ( !m_hFirstSelectedItem )
			m_hFirstSelectedItem = GetSelectedItem();

		SelectItems( m_hFirstSelectedItem, hClickedItem );
	}
	else if ( nFlags & MK_CONTROL )
	{
		// Find which item is currently selected
		HTREEITEM hSelectedItem = GetSelectedItem();

		// Is the clicked item already selected ?
		BOOL bIsClickedItemSelected = GetItemState( hClickedItem, TVIS_SELECTED ) & TVIS_SELECTED;
		BOOL bIsSelectedItemSelected = FALSE;
		if ( hSelectedItem )
			bIsSelectedItemSelected = GetItemState( hSelectedItem, TVIS_SELECTED ) & TVIS_SELECTED;

		// Must synthesize a TVN_SELCHANGING notification
		if ( pWnd )
		{
			tv.hdr.hwndFrom = GetSafeHwnd();
			tv.hdr.idFrom = GetWindowLong( GetSafeHwnd(), GWL_ID );
			tv.hdr.code = TVN_SELCHANGING;

			tv.itemNew.hItem = hClickedItem;
			tv.itemNew.state = GetItemState( hClickedItem, 0xffffffff );
			tv.itemNew.lParam = GetItemData( hClickedItem );

			tv.itemOld.hItem = NULL;
			tv.itemOld.mask = 0;

			tv.action = TVC_BYMOUSE;

			tv.ptDrag.x = point.x;
			tv.ptDrag.y = point.y;

			pWnd->SendMessage( WM_NOTIFY, tv.hdr.idFrom, (LPARAM)&tv );
		}

		// If the previously selected item was selected, re-select it
		if ( bIsSelectedItemSelected )
			SetItemState( hSelectedItem, TVIS_SELECTED, TVIS_SELECTED );

		// We want the newly selected item to toggle its selected state,
		// so unselect now if it was already selected before
		if ( bIsClickedItemSelected )
			SetItemState( hClickedItem, 0, TVIS_SELECTED );
		else
		{
			SelectItem(hClickedItem);
			SetItemState( hClickedItem, TVIS_SELECTED, TVIS_SELECTED );
		}

		// If the previously selected item was selected, re-select it
		if ( bIsSelectedItemSelected && hSelectedItem != hClickedItem )
			SetItemState( hSelectedItem, TVIS_SELECTED, TVIS_SELECTED );

		// Store as first selected item (if not already stored)
		if ( m_hFirstSelectedItem==NULL )
			m_hFirstSelectedItem = hClickedItem;
	}
	else
	{
		// Clear selection of all "multiple selected" items first
		ClearSelection();

		// Then select the clicked item
		SelectItem( hClickedItem );
		SetItemState( hClickedItem, TVIS_SELECTED, TVIS_SELECTED );

		// Store as first selected item
		m_hFirstSelectedItem = hClickedItem;
	}

	// Selection process is now complete. Since we have 'eaten' the TVN_SELCHANGED 
	// notification provided by Windows' treectrl, we must now produce one ourselves,
	// so that our parent gets to know about the change of selection.
	m_bSelectionComplete = TRUE;

	if ( pWnd )
	{
		tv.hdr.hwndFrom = GetSafeHwnd();
		tv.hdr.idFrom = GetWindowLong( GetSafeHwnd(), GWL_ID );
		tv.hdr.code = TVN_SELCHANGED;

		tv.itemNew.hItem = m_hClickedItem;
		tv.itemNew.state = GetItemState( m_hClickedItem, 0xffffffff );
		tv.itemNew.lParam = GetItemData( m_hClickedItem );
		tv.itemNew.mask = TVIF_HANDLE|TVIF_STATE|TVIF_PARAM;

		tv.action = TVC_UNKNOWN;

		pWnd->SendMessage( WM_NOTIFY, tv.hdr.idFrom, (LPARAM)&tv );
	}
}
Exemplo n.º 18
0
void CTreeCtrlEx::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags ) 
{
	CWnd* pWnd = GetParent();

	if ( nChar==VK_NEXT || nChar==VK_PRIOR )
	{
		if ( !( GetKeyState( VK_SHIFT )&0x8000 ) )
		{
			// User pressed Pg key without holding 'Shift':
			// Clear multiple selection (if multiple) and let base class do 
			// normal selection work!
			if ( GetSelectedCount()>1 )
				ClearSelection( TRUE );

			CTreeCtrl::OnKeyDown( nChar, nRepCnt, nFlags );
			m_hFirstSelectedItem = GetSelectedItem();
			return;
		}

		// Flag signaling that selection process is NOT complete.
		// (Will prohibit TVN_SELCHANGED from being sent to parent)
		m_bSelectionComplete = FALSE;

		// Let base class select the item
		CTreeCtrl::OnKeyDown( nChar, nRepCnt, nFlags );
		HTREEITEM hSelectedItem = GetSelectedItem();

		// Then select items in between
		SelectItems( m_hFirstSelectedItem, hSelectedItem );

		// Selection process is now complete. Since we have 'eaten' the TVN_SELCHANGED 
		// notification provided by Windows' treectrl, we must now produce one ourselves,
		// so that our parent gets to know about the change of selection.
		m_bSelectionComplete = TRUE;

		if (pWnd)
		{
			NM_TREEVIEW tv;
			memset(&tv.itemOld, 0, sizeof(tv.itemOld));

			tv.hdr.hwndFrom = GetSafeHwnd();
			tv.hdr.idFrom = GetWindowLong(GetSafeHwnd(), GWL_ID);
			tv.hdr.code = TVN_SELCHANGED;

			tv.itemNew.hItem = hSelectedItem;
			tv.itemNew.state = GetItemState(hSelectedItem, 0xffffffff);
			tv.itemNew.lParam = GetItemData(hSelectedItem);
			tv.itemNew.mask = TVIF_HANDLE|TVIF_STATE|TVIF_PARAM;

			tv.action = TVC_UNKNOWN;

			pWnd->SendMessage(WM_NOTIFY, tv.hdr.idFrom, (LPARAM)&tv);
		}
	}
	else if ( nChar==VK_UP || nChar==VK_DOWN )
	{
		// Find which item is currently selected
		HTREEITEM hSelectedItem = GetSelectedItem();

		HTREEITEM hNextItem;
		if ( nChar==VK_UP )
			hNextItem = GetPrevVisibleItem( hSelectedItem );
		else
			hNextItem = GetNextVisibleItem( hSelectedItem );

		if ( !( GetKeyState( VK_SHIFT )&0x8000 ) )
		{
			// User pressed arrow key without holding 'Shift':
			// Clear multiple selection (if multiple) and let base class do 
			// normal selection work!
			if ( GetSelectedCount()>1 )
				ClearSelection( TRUE );

			if ( hNextItem )
				CTreeCtrl::OnKeyDown( nChar, nRepCnt, nFlags );
			m_hFirstSelectedItem = GetSelectedItem();
			return;
		}

		if ( hNextItem )
		{
			// Flag signaling that selection process is NOT complete.
			// (Will prohibit TVN_SELCHANGED from being sent to parent)
			m_bSelectionComplete = FALSE;

			// If the next item is already selected, we assume user is
			// "moving back" in the selection, and thus we should clear 
			// selection on the previous one
			BOOL bSelect = !( GetItemState( hNextItem, TVIS_SELECTED ) & TVIS_SELECTED );

			// Select the next item (this will also deselect the previous one!)
			SelectItem( hNextItem );

			// Now, re-select the previously selected item
			if ( bSelect || ( !( GetItemState( hSelectedItem, TVIS_SELECTED ) & TVIS_SELECTED ) ) )
				SelectItems( m_hFirstSelectedItem, hNextItem );

			// Selection process is now complete. Since we have 'eaten' the TVN_SELCHANGED 
			// notification provided by Windows' treectrl, we must now produce one ourselves,
			// so that our parent gets to know about the change of selection.
			m_bSelectionComplete = TRUE;

			if (pWnd)
			{
				NM_TREEVIEW tv;
				memset(&tv.itemOld, 0, sizeof(tv.itemOld));

				tv.hdr.hwndFrom = GetSafeHwnd();
				tv.hdr.idFrom = GetWindowLong(GetSafeHwnd(), GWL_ID);
				tv.hdr.code = TVN_SELCHANGED;

				tv.itemNew.hItem = hNextItem;
				tv.itemNew.state = GetItemState(hNextItem, 0xffffffff);
				tv.itemNew.lParam = GetItemData(hNextItem);
				tv.itemNew.mask = TVIF_HANDLE|TVIF_STATE|TVIF_PARAM;

				tv.action = TVC_UNKNOWN;

				pWnd->SendMessage(WM_NOTIFY, tv.hdr.idFrom, (LPARAM)&tv);
			}
		}

		// Since the base class' OnKeyDown() isn't called in this case,
		// we must provide our own TVN_KEYDOWN notification to the parent

		CWnd* pWnd = GetParent();
		if ( pWnd )
		{
			NMTVKEYDOWN tvk;

			tvk.hdr.hwndFrom = GetSafeHwnd();
			tvk.hdr.idFrom = GetWindowLong( GetSafeHwnd(), GWL_ID );
			tvk.hdr.code = TVN_KEYDOWN;

			tvk.wVKey = nChar;
			tvk.flags = 0;

			pWnd->SendMessage( WM_NOTIFY, tvk.hdr.idFrom, (LPARAM)&tvk );
		}
	}
	else
		// Behave normally
		CTreeCtrl::OnKeyDown( nChar, nRepCnt, nFlags );
}
Exemplo n.º 19
0
void PropertyTree::OnLButtonDown(UINT flags, CPoint point) 
{
    //
    // hide edit in place
    //
    if ( m_EditInPlace.IsVisible() )
        m_EditInPlace.Cancel();

    SendNotify(NM_CLICK);

    if (!IsWindowEnabled())
        return;

    SetFocus();

    LONG nHit = HitTest(point);

    PropertyTreeItem* pItem;
    CRect rc;

    switch (nHit)
    {
        case HTEXPAND:
            if ( flags != RTCLKITEM && (pItem = FindItem(point))!=NULL)
            {
                if (pItem->GetChild() && !SendNotify(PTN_ITEMEXPANDING, pItem))
                {
                    pItem->Expand(!pItem->IsExpanded());

                    UpdateScrollbar();
                    Invalidate();
                    UpdateWindow();
                    CheckVisibleFocus();
                }
            }
            break;

        default:

            if ((pItem = FindItem(point))!=NULL)
            {
                PropertyTreeItem* pOldFocus = GetFocusedItem();

                if ( pItem->IsRootLevel() )
                    return;

                SelectItems(NULL, FALSE);
                SetFocusedItem(pItem);

                pItem->Select();

                Invalidate();

                if ( flags == RTCLKITEM )
                    m_LastBtn = RTCLKITEM;
                else
                    m_LastBtn = LFCLKITEM;

                // don't send a sel change event for removable devices
                if (pItem!=pOldFocus )
                    SendNotify(PTN_SELCHANGE, pItem);

                if (nHit==HTATTRIBUTE && !pItem->IsRootLevel())
                {
                    if (!SendNotify(PTN_PROPCLICK, pItem))
                        pItem->Activate();
                }
            }
            break;
    }
}
Exemplo n.º 20
0
void CLibraryFolderCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
	UINT nItemFlags = 0;
	HTREEITEM hItem = HitTest( point, &nItemFlags );

	if ( nItemFlags == TVHT_ONITEMBUTTON )
	{
		CTreeCtrl::OnLButtonDown( nFlags, point );
		return;
	}

	if ( ( nFlags & MK_CONTROL ) && m_bMultiSelect )
	{
		if ( hItem )
		{
			UINT nNewState = GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED ?
				0 : TVIS_SELECTED;

			SetItemState( hItem, nNewState,  TVIS_SELECTED );
			m_hFirstSelected = NULL;
			NotifySelectionChanged();
		}
	}
	else if ( ( nFlags & MK_SHIFT ) && m_bMultiSelect )
	{
		hItem = HitTest( point );

		if ( ! m_hFirstSelected ) m_hFirstSelected = GetFirstSelectedItem();

		if ( hItem ) SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED );

		if ( m_hFirstSelected ) SelectItems( m_hFirstSelected, hItem );

		NotifySelectionChanged();
	}
	else
	{
		BOOL bChanged = FALSE;

		BOOL bSelected = hItem && ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED );

		if ( ! bSelected || ( nFlags & MK_RBUTTON ) == 0 )
		{
			if ( m_bFirstClick && hItem != GetRootItem() )
			{
				Select( hItem, TVGN_CARET );
			}

			bChanged = ClearSelection( hItem );
			m_hFirstSelected = NULL;
		}

		if ( hItem )
		{
			if ( ! bSelected )
			{
				SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED );
				bChanged = TRUE;
			}
		}

		if ( bChanged ) NotifySelectionChanged();
	}

	m_bFirstClick = FALSE;

	SetFocus();
}