Esempio n. 1
0
void STabCtrl::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{
    if(nChar==VK_LEFT || nChar==VK_UP)
    {
        if(!SetCurSel(m_nCurrentPage-1))
            SetCurSel(GetItemCount()-1);
    }else if(nChar==VK_RIGHT || nChar==VK_DOWN)
    {
        if(!SetCurSel(m_nCurrentPage+1))
            SetCurSel(0);
    }else if(nChar==VK_HOME)
    {
        SetCurSel(0);
    }else if(nChar==VK_END)
    {
        SetCurSel(GetItemCount()-1);
    }
}
Esempio n. 2
0
BOOL CXTPMDIWndTab::RefreshActiveSel()
{
	// Get the active MDI window, if NULL return FALSE.
	HWND hWndActiveChild = m_pMDIFrameWnd->MDIGetActive()->GetSafeHwnd();
	if (hWndActiveChild == NULL)
	{
		m_hActiveChild = NULL;
		return FALSE;
	}

	// Loop through all of the tabs to find the view that has activated.
	bool bSelectionChanged = false;
	if (POSITION pos = m_arMDIChildern.GetHeadPosition())
	{
		do
		{
			MDICHILD* pMDIChild = m_arMDIChildern.GetNext(pos);
			ASSERT(pMDIChild != NULL);

			// We have found the handle to the active MDI window,
			// lets see if the tab is selected.
			if (pMDIChild && (pMDIChild->hWnd == hWndActiveChild))
			{
				// If the active child pointer does not match, then
				// make sure that the tab is selected then save the pointer.
				bSelectionChanged = hWndActiveChild != m_hActiveChild;
				if (bSelectionChanged)
				{
					SetCurSel(pMDIChild->iItem);
					m_hActiveChild = hWndActiveChild;
				}
			}
		}
		while (pos != NULL && !bSelectionChanged);
	}
	return bSelectionChanged;
}
Esempio n. 3
0
void CSearchBox::OnSelendcancel()
{
	// TODO: Add your control notification handler code here
	if( m_bDoNothing )
		return;

	m_bDoNothing	=	TRUE;
	if( m_hwndLastFocus )
		::SetFocus( m_hwndLastFocus );
	m_hwndLastFocus	=	NULL;
	m_bSegmentEnd	=	TRUE;

	CString	strCommand;
	GetWindowText( strCommand );
	int nSel = SelectString( 0, strCommand );
	ShowDropDown( FALSE );
	SetCurSel( nSel );

	SetCurrentWindowText( );
	m_bDoNothing	=	FALSE;

	if( m_bAutoHide )
		SetWindowPos( NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW );
}
Esempio n. 4
0
void CXTPMDIWndTab::OnMDIActivate(HWND hWnd)
{
	// Loop through all of the tabs to find the view that has activated.
	int iItem;
	for (iItem = 0; iItem < GetItemCount(); ++iItem)
	{
		// Get the item data for this tab.
		TC_ITEM tci;
		tci.mask = TCIF_PARAM;

		if (GetItem(iItem, &tci))
		{
			MDICHILD* pMDIChild = (MDICHILD*)tci.lParam;
			ASSERT(pMDIChild != NULL);

			// If it is the activated window select it and exit loop.
			if (pMDIChild && (hWnd == pMDIChild->hWnd))
			{
				SetCurSel(iItem);
				break;
			}
		}
	}
}
Esempio n. 5
0
BOOL CSchemaCombo::OnClickItem(int nItem, BOOL bDown)
{
	if ( nItem > 0 && GetItemData( nItem ) == 0 )
	{
		if ( bDown )
		{
			int nOldTop = GetTopIndex();
			int nDelta = ( nOldTop != CB_ERR && nItem > nOldTop ) ? ( nItem - nOldTop ) : 0;
			DeleteString( nItem );
			Load( m_sPreDrop, m_nType, CSchema::saMax, FALSE );
			int nCurSel = GetCurSel();
			if ( nCurSel != CB_ERR )
			{
				if ( nCurSel >= nDelta )
				{
					SetTopIndex( nCurSel - nDelta );
				}
				SetCurSel( nCurSel );
			}
		}
		return TRUE;
	}
	return FALSE;
}
//******************************************************************************
void CBCGPRibbonCommandsListBox::FillFromArray (
		const CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*>& arElements, BOOL bDeep,
		BOOL bIgnoreSeparators)
{
	ASSERT_VALID (this);

	ResetContent ();
	m_nTextOffset = 0;

	BOOL bIsRibbonImageScale = globalData.IsRibbonImageScaleEnabled ();
	globalData.EnableRibbonImageScale (FALSE);

	for (int i = 0; i < arElements.GetSize (); i++)
	{
		CBCGPBaseRibbonElement* pElem = arElements [i];
		ASSERT_VALID (pElem);

		if (bIgnoreSeparators && pElem->IsKindOf (RUNTIME_CLASS (CBCGPRibbonSeparator)))
		{
			continue;
		}

		pElem->AddToListBox (this, bDeep);

		int nImageWidth = pElem->GetImageSize (CBCGPBaseRibbonElement::RibbonImageSmall).cx;

		m_nTextOffset = max (m_nTextOffset, nImageWidth + 2);
	}

	if (GetCount () > 0)
	{
		SetCurSel (0);
	}

	globalData.EnableRibbonImageScale (bIsRibbonImageScale);
}
HRESULT CAchievementList::OnInit(XUIMessageInit *pInitData, BOOL& bHandled)
{
	DebugMsg("AchievementList","AchievementList Init");

	AchievementIconPaths.szMissingAchievementIcon = strtowstr(AchievementManager::getInstance().GetAchievementSetting("MISSINGACHIEVEMENTPATH"));

	m_sListState = GameContentManager::getInstance().getGameListSnapshot(false);

	if(m_sListState.CurrentGame == NULL)
		return S_OK;

	wstring szGameID = m_sListState.CurrentGame->ContentRef->getId();

	m_AchievementList.ListSize = AchievementManager::getInstance().GetAchievementCount(szGameID);
	AchievementManager::getInstance().CreateAchievementList(szGameID);

	InsertItems( 0, m_AchievementList.ListSize);

	DebugMsg("AchievementList","%d Items inserted into list", m_AchievementList.ListSize);

	SetCurSel(0);
	
	return S_OK;
}
Esempio n. 8
0
//***************************************************************************************
BOOL CBCGFontComboBox::SelectFont (LPCTSTR lpszName, BYTE nCharSet/* = DEFAULT_CHARSET*/)
{
	ASSERT_VALID (this);
	ASSERT (::IsWindow (m_hWnd));
	ASSERT (lpszName != NULL);

	for (int i = 0; i < GetCount (); i++)
	{
		CBCGFontDesc* pFontDescr = (CBCGFontDesc*) GetItemData (i);
		ASSERT_VALID (pFontDescr);

		if (pFontDescr->m_strName == lpszName)
		{
			if (nCharSet == DEFAULT_CHARSET ||
				nCharSet == pFontDescr->m_nCharSet)
			{
				SetCurSel (i);
				return TRUE;
			}
		}
	}

	return FALSE;
}
Esempio n. 9
0
int STabCtrl::InsertItem( pugi::xml_node xmlNode,int iInsert/*=-1*/,BOOL bLoading/*=FALSE*/ )
{
    if (wcscmp(xmlNode.name(),STabPage::GetClassName()) != 0) return -1;
    STabPage *pChild = (STabPage *)SApplication::getSingleton().CreateWindowByName(STabPage::GetClassName());
    
    InsertChild(pChild);
    pChild->InitFromXml(xmlNode);
    pChild->GetLayout()->SetFitParent(PD_ALL);
    
    if(iInsert==-1) iInsert=m_lstPages.GetCount();
    m_lstPages.InsertAt(iInsert,pChild);

    if(!bLoading )
    {
        CRect rcPage=GetChildrenLayoutRect();
        pChild->Move(&rcPage);
        pChild->SetVisible(FALSE,FALSE);
        if(m_nCurrentPage>=iInsert)  m_nCurrentPage++;
        InvalidateRect(GetTitleRect());
        if(m_nCurrentPage == -1) SetCurSel(iInsert);
    }
    
    return iInsert;
}
Esempio n. 10
0
int CComboBox::SelectString(int nStartAfter, LPCTSTR lpszString)
{
	assert(m_hWnd);
	
	if (m_hWnd)
	{
		int count = GetCount();
		int start = nStartAfter != -1 ? nStartAfter : 0;
		CString rString;
		
		for(int i = start; i < count; i++)
		{
			GetLBText(i, rString);
			
			if (rString == lpszString)
			{
				SetCurSel(i);
				return i;
			}
		}
	}
	
	return CB_ERR;
}
Esempio n. 11
0
CChatItem* CChatSelector::StartSession(CUpDownClient* client, bool show)
{
	if (show)
		m_pParent->m_wndMessage.SetFocus();
	if (GetTabByClient(client) != -1){
		if (show){
			SetCurSel(GetTabByClient(client));
			ShowChat();
		}
		return NULL;
	}

	CChatItem* chatitem = new CChatItem();
	chatitem->client = client;
	chatitem->log = new CHTRichEditCtrl;

	CRect rcChat;
	GetChatSize(rcChat);
	if (GetItemCount() == 0)
		rcChat.top += 19; // add the height of the tab which is not yet there
	// using ES_NOHIDESEL is actually not needed, but it helps to get around a tricky window update problem!
	// If that style is not specified there are troubles with right clicking into the control for the very first time!?
	chatitem->log->Create(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL, rcChat, this, (UINT)-1);
	chatitem->log->ModifyStyleEx(0, WS_EX_STATICEDGE, SWP_FRAMECHANGED);
	chatitem->log->SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(3, 3));
	chatitem->log->SetEventMask(chatitem->log->GetEventMask() | ENM_LINK);
	chatitem->log->SetFont(&theApp.m_fontHyperText);
	chatitem->log->SetProfileSkinKey(_T("Chat"));
	chatitem->log->ApplySkin();
	chatitem->log->EnableSmileys(thePrefs.GetMessageEnableSmileys());

	PARAFORMAT pf = {0};
	pf.cbSize = sizeof pf;
	pf.dwMask = PFM_OFFSET;
	pf.dxOffset = 150;
	chatitem->log->SetParaFormat(pf);

	if (thePrefs.GetIRCAddTimeStamp())
		AddTimeStamp(chatitem);
	chatitem->log->AppendKeyWord(GetResString(IDS_CHAT_START) + client->GetUserName() + _T("\n"), STATUS_MSG_COLOR);
	client->SetChatState(MS_CHATTING);

	CString name;
	if (client->GetUserName() != NULL)
		name = client->GetUserName();
	else
		name.Format(_T("(%s)"), GetResString(IDS_UNKNOWN));
	chatitem->log->SetTitle(name);

	TCITEM newitem;
	newitem.mask = TCIF_PARAM | TCIF_TEXT | TCIF_IMAGE;
	newitem.lParam = (LPARAM)chatitem;
	name.Replace(_T("&"), _T("&&"));
	newitem.pszText = const_cast<LPTSTR>((LPCTSTR)name);
	newitem.iImage = 0;
	int iItemNr = InsertItem(GetItemCount(), &newitem);
	if (show || IsWindowVisible()){
		SetCurSel(iItemNr);
		ShowChat();
	}
	return chatitem;
}
Esempio n. 12
0
int CHistoryCombo::AddString(CString str, INT_PTR pos)
{
    if (str.IsEmpty())
        return -1;

    //truncate list to m_nMaxHistoryItems
    int nNumItems = GetCount();
    for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
    {
        DeleteItem(m_nMaxHistoryItems);
        m_arEntries.RemoveAt(m_nMaxHistoryItems);
    }

    COMBOBOXEXITEM cbei;
    SecureZeroMemory(&cbei, sizeof cbei);
    cbei.mask = CBEIF_TEXT;

    if (pos < 0)
        cbei.iItem = GetCount();
    else
        cbei.iItem = pos;
    if (m_bTrim)
        str.Trim(L" ");
    CString combostring = str;
    combostring.Replace('\r', ' ');
    combostring.Replace('\n', ' ');
    cbei.pszText = const_cast<LPTSTR>(combostring.GetString());

#ifdef HISTORYCOMBO_WITH_SYSIMAGELIST
    if (m_bURLHistory)
    {
        cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(str);
        if ((cbei.iImage == NULL) || (cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex()))
        {
            if (str.Left(5) == L"http:")
                cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(L".html");
            else if (str.Left(6) == L"https:")
                cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(L".html");
            else if (str.Left(5) == L"file:")
                cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
            else if (str.Left(4) == L"svn:")
                cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
            else if (str.Left(8) == L"svn+ssh:")
                cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
        }
        cbei.iSelectedImage = cbei.iImage;
        cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
    }
    if (m_bPathHistory)
    {
        cbei.iImage = SYS_IMAGE_LIST().GetPathIconIndex(str);
        if (cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex())
        {
            cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
        }
        cbei.iSelectedImage = cbei.iImage;
        cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
    }
#endif
    int nRet = InsertItem(&cbei);
    if (nRet >= 0)
        m_arEntries.InsertAt(nRet, str);

    //search the Combo for another string like this
    //and delete it if one is found
    if (m_bTrim)
        str.Trim();
    int nIndex = FindStringExact(0, combostring);
    if (nIndex != -1 && nIndex != nRet)
    {
        DeleteItem(nIndex);
        m_arEntries.RemoveAt(nIndex);
    }

    SetCurSel(nRet);
    return nRet;
}
Esempio n. 13
0
void CDownloads_Bittorrent::set_ActiveTab(int nTab)
{
	SetCurSel (nTab);
	nTab = GetCurSel ();
	ApplyCurTab ();
}
Esempio n. 14
0
// RemoveView contains certain guards to tell whenever attempted remove is not valid
//-----  OnSizeParent()  ------------------------------------------------------
BOOL BCTabBarCtrl::RemoveView(int iItem)
{ 
	ASSERT(::IsWindow(m_hWnd)); 
	
	int iCount = GetItemCount();

	/**** JohnCz ***/
	// if this fires, it is an attempt to remove view that does not exist or the last view
	ASSERT((iCount > iItem) || (iCount > 1) || (iItem > 0));
	
	// return FALSE to continue working
	if((iCount <= iItem) || (iCount < 2))
	{
		return FALSE;
	}
	
	BARTCITEM item;
	item.hdr.mask = TCIF_PARAM;
	VERIFY(GetItem(iItem, (TCITEMHEADER*)&item));

	ASSERT(item.pWnd);
	ASSERT(IsWindow(*item.pWnd));

	int iTabItem = -1;
	CWnd *pNewView = NULL;

	CWnd *pRemoveView = item.pWnd; // just to simplify 

	int iSetCurr = iItem + 1;

	/**** JohnCz ***/
	// this will set active tab either after or if tab does not exist before removed one
	if(AFX_IDW_PANE_FIRST == pRemoveView->GetDlgCtrlID())	//removing active?
	{
		/**** JohnCz ***/
		// to set active tab after removed
		pNewView = GetViewFromItem(iSetCurr); 

		// is it last tab? if so set tab before
		if(NULL == pNewView) 
		{
			iSetCurr = iItem - 1;
			// attempt to set active tab before	removved
			pNewView = GetViewFromItem(iSetCurr); 
		}
	}

	m_mapUsedID.RemoveKey(item.uiID);
	pRemoveView->DestroyWindow();

	/**** JohnCz ***/
	// we just removed active, set new view.
	if(pNewView) 
	{
		pNewView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
		pNewView->ShowWindow(SW_SHOW);
		SetCurSel(iSetCurr);
		m_pParentFrame->RecalcLayout();
		pNewView->SetFocus();
	}

	return (BOOL)::SendMessage(m_hWnd, TCM_DELETEITEM, iItem, 0L); 
}
//***********************************************************************************************	
void CBCGPRecentFilesListBox::FillList(LPCTSTR lpszSelectedPath/* = NULL*/)
{
	ASSERT(GetSafeHwnd() != NULL);

	ResetContent();
	ResetPins();
	
	m_lstCaptionIndexes.RemoveAll();

	m_nHighlightedItem = -1;
	m_bIsPinHighlighted = FALSE;

	int cyIcon = 32;

	if (globalData.GetRibbonImageScale () != 1.)
	{
		cyIcon = (int) (.5 + globalData.GetRibbonImageScale () * cyIcon);
	}

	int nItemHeight = max(cyIcon + 4, globalData.GetTextHeight () * 5 / 2);
	
	SetItemHeight(-1, nItemHeight);

	for (int i = 0; i < m_arIcons.GetSize(); i++)
	{
		HICON hIcon = m_arIcons[i];
		if (hIcon != NULL)
		{
			::DestroyIcon(hIcon);
		}
	}

	m_arIcons.RemoveAll();

	BOOL bHasPinnedItems = FALSE;

	// Add "pinned" items first
	if (g_pWorkspace != NULL)
	{
		const CStringArray& ar = g_pWorkspace->GetPinnedPaths(!m_bFoldersMode);

		for (int i = 0; i < (int)ar.GetSize(); i++)
		{
			int nIndex = AddItem(ar[i], 0, TRUE);
			if (nIndex >= 0 && lpszSelectedPath != NULL && ar[i] == lpszSelectedPath)
			{
				SetCurSel(nIndex);
			}

			if (nIndex >= 0)
			{
				bHasPinnedItems = TRUE;
			}
		}
	}

	if (bHasPinnedItems)
	{
		AddSeparator();
		m_arIcons.Add(NULL);
	}

	// Add MRU files:
	CRecentFileList* pMRUFiles = 
		((CBCGPApp*) AfxGetApp ())->m_pRecentFileList;

	if (pMRUFiles != NULL)
	{
		for (int i = 0; i < pMRUFiles->GetSize (); i++)
		{
			CString strPath = (*pMRUFiles)[i];

			int nIndex = AddItem(strPath, (ID_FILE_MRU_FILE1 + i));
			if (nIndex >= 0 && lpszSelectedPath != NULL && strPath == lpszSelectedPath)
			{
				SetCurSel(nIndex);
			}
		}
	}

	int nLastIndex = GetCount() - 1;
	if (nLastIndex >= 0 && IsSeparatorItem(nLastIndex))
	{
		DeleteString(nLastIndex);
	}
}
Esempio n. 16
0
void CUIComboBox::Event(TEventUI& event)
{
	if( !CUIControl::Activate() ) return;

	if( event.Type == UIEVENT_SETCURSOR )
	{
		if( ::PtInRect(&m_rcItem, event.ptMouse) && IsEnabled() ) {
			::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
			return;
		}
	}

   if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
   {
      m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED;
	  Invalidate();

	  if( m_pManager != NULL ) m_pManager->SendNotify(this, UI_NOTIFY_CLICK);

	  Activate();
   }
   if( event.Type == UIEVENT_MOUSEMOVE )
   {
      if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
         if( ::PtInRect(&m_rcButton, event.ptMouse) ) m_uButtonState |= UISTATE_PUSHED;
         else m_uButtonState &= ~UISTATE_PUSHED;
         Invalidate();
      }

	  if (m_pWindow != NULL)
	  {
		  m_uButtonState |= UISTATE_PUSHED;
		  Invalidate();	 
	  }
   }
   if( event.Type == UIEVENT_BUTTONUP )
   {
      if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
         m_uButtonState &= ~(UISTATE_PUSHED | UISTATE_CAPTURED);
         Invalidate();
      }
   }
   if( event.Type == UIEVENT_KEYDOWN )
   {
      switch( event.chKey ) {
      case VK_F4:
         Activate();
         return;
      case VK_UP:
         SetCurSel(FindSelectable(m_iCurSel - 1, false));
         return;
      case VK_DOWN:
         SetCurSel(FindSelectable(m_iCurSel + 1, true));
         return;
      }
   }
   if( event.Type == UIEVENT_SCROLLWHEEL )
   {
      bool bDownward = LOWORD(event.wParam) == SB_LINEDOWN;
      //SetCurSel(FindSelectable(m_iCurSel + (bDownward ? 1 : -1), bDownward));
      return;
   }

   if( event.Type == UIEVENT_MOUSEENTER)
   {
	   m_uButtonState |= UISTATE_HOT;
	   Invalidate();
   }
   if( event.Type == UIEVENT_MOUSELEAVE)
   {
	   m_uButtonState &= ~UISTATE_HOT;
	   Invalidate();
   }
   CUIControl::Event(event);
}
Esempio n. 17
0
int CHistoryCombo::AddString(CString str, INT_PTR pos,BOOL isSel)
{
	if (str.IsEmpty())
		return -1;

	if (pos < 0)
		pos = GetCount();

	if (m_bTrim)
		str.Trim(_T(" "));
	CString combostring = str;
	combostring.Replace('\r', ' ');
	combostring.Replace('\n', ' ');
	if (m_bTrim)
		combostring.Trim();

	//search the Combo for another string like this
	//and do not insert if found
	int nIndex = m_bCaseSensitive ? FindStringExactCaseSensitive(-1, combostring) : FindStringExact(-1, combostring);
	if (nIndex != -1)
	{
		if (nIndex > pos)
		{
			DeleteItem(nIndex);
			m_arEntries.RemoveAt(nIndex);
		}
		else
		{
			if(isSel)
				SetCurSel(nIndex);
			return nIndex;
		}
	}

	//truncate list to m_nMaxHistoryItems
	int nNumItems = GetCount();
	for (int n = m_nMaxHistoryItems; n < nNumItems; n++)
	{
		DeleteItem(m_nMaxHistoryItems);
		m_arEntries.RemoveAt(m_nMaxHistoryItems);
	}

	COMBOBOXEXITEM cbei;
	SecureZeroMemory(&cbei, sizeof cbei);
	cbei.mask = CBEIF_TEXT;
	cbei.iItem = pos;

	cbei.pszText = const_cast<LPTSTR>(combostring.GetString());

#ifdef HISTORYCOMBO_WITH_SYSIMAGELIST
	if (m_bURLHistory)
	{
		cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(str);
		if (cbei.iImage == 0 || cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex())
		{
			if (str.Left(5) == _T("http:"))
				cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(_T(".html"));
			else if (str.Left(6) == _T("https:"))
				cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(_T(".html"));
			else if (str.Left(5) == _T("file:"))
				cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
			else if (str.Left(4) == _T("git:"))
				cbei.iImage = m_nGitIconIndex;
			else if (str.Left(4) == _T("ssh:"))
				cbei.iImage = m_nGitIconIndex;
			else
				cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
		}
		cbei.iSelectedImage = cbei.iImage;
		cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
	}
	if (m_bPathHistory)
	{
		cbei.iImage = SYS_IMAGE_LIST().GetFileIconIndex(str);
		if (cbei.iImage == SYS_IMAGE_LIST().GetDefaultIconIndex())
		{
			cbei.iImage = SYS_IMAGE_LIST().GetDirIconIndex();
		}
		cbei.iSelectedImage = cbei.iImage;
		cbei.mask |= CBEIF_IMAGE | CBEIF_SELECTEDIMAGE;
	}
#endif

	int nRet = InsertItem(&cbei);
	if (nRet >= 0)
		m_arEntries.InsertAt(nRet, str);

	if(isSel)
		SetCurSel(nRet);
	return nRet;
}
void CXTPPropertyGridInplaceList::Create(CXTPPropertyGridItem* pItem, CRect rect)
{
	ASSERT(pItem && pItem->GetGrid());
	if (!pItem)
		return;

	CRect rcValue(rect);
	rcValue.left = pItem->GetGrid()->GetDividerPos() + 1;

	CWnd* pParent = (CWnd*)pItem->GetGrid();
	m_pItem = pItem;

	DestroyWindow();

	if (!m_hWnd)
	{
		CListBox::CreateEx(WS_EX_TOOLWINDOW | (pParent->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""),
			LBS_NOTIFY | WS_CHILD | WS_VSCROLL | WS_BORDER | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS, CRect(0, 0, 0, 0), pParent, 0);
		SetOwner(pParent);


		if (m_bShowShadow && XTPSystemVersion()->IsWinXPOrGreater())
			SetClassLongPtr(m_hWnd, GCL_STYLE, GetClassLongPtr(m_hWnd, GCL_STYLE) | 0x00020000);
	}
	SetFont(pParent->GetFont());

	ResetContent();

	CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints();


	int dx = rect.right - rcValue.left;

	CWindowDC dc(pParent);
	CXTPFontDC font(&dc, pParent->GetFont());
	int nHeight = dc.GetTextExtent(_T(" "), 1).cy + 3;

	for (int i = 0; i < pList->GetCount(); i++)
	{
		CXTPPropertyGridItemConstraint* pConstraint = pList->GetConstraintAt(i);

		CString str = pConstraint->m_strConstraint;
		int nIndex = AddString(str);
		SetItemDataPtr(nIndex, pConstraint);

		CSize sz = pItem->OnMergeItemConstraint(&dc, pConstraint);

		dx = max(dx, sz.cx);
		nHeight = max(nHeight, sz.cy);

		if (pItem->GetValue() == str)
			SetCurSel(nIndex);
	}

	SetItemHeight(0, nHeight);

	rect.top = rect.bottom;
	rect.bottom += nHeight * __min(pItem->GetDropDownItemCount(), GetCount()) + 2;
	rect.left = rect.right - __min(dx, rect.Width() - XTP_PGI_EXPAND_BORDER);

	pParent->ClientToScreen(&rect);

	CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
	if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
	{
		rect.OffsetRect(0, - rect.Height() - rcValue.Height() - 1);
	}
	if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0);
	if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0);


	SetFocus();


	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0);
	ModifyStyle(WS_CHILD, WS_POPUP);
	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pParent->m_hWnd);

	SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);

	CXTPMouseMonitor::SetupHook(this);
}
void CXTPReportInplaceList::Create(XTP_REPORTRECORDITEM_ARGS* pItemArgs, CXTPReportRecordItemConstraints* pConstaints)
{
	SetItemArgs(pItemArgs);

	CRect rect(pItemArgs->rcItem);

	if (!m_hWnd)
	{
		CListBox::CreateEx(WS_EX_TOOLWINDOW | (pControl->GetExStyle() & WS_EX_LAYOUTRTL), _T("LISTBOX"), _T(""), LBS_NOTIFY | WS_CHILD | WS_BORDER | WS_VSCROLL, CRect(0, 0, 0, 0), pControl, 0);
		SetOwner(pControl);
	}

	SetFont(pControl->GetPaintManager()->GetTextFont());
	ResetContent();

	int dx = rect.right - rect.left + 1;

	CWindowDC dc(pControl);
	CXTPFontDC font(&dc, GetFont());
	int nThumbLength = GetSystemMetrics(SM_CXHTHUMB);

	CString strCaption = pItem->GetCaption(pColumn);
	DWORD dwData = pItem->GetSelectedConstraintData(pItemArgs);

	for (int i = 0; i < pConstaints->GetCount(); i++)
	{
		CXTPReportRecordItemConstraint* pConstaint = pConstaints->GetAt(i);
		CString str = pConstaint->m_strConstraint;
		int nIndex = AddString(str);
		SetItemDataPtr(nIndex, pConstaint);

		dx = max(dx, dc.GetTextExtent(str).cx + nThumbLength);

		if ((dwData == (DWORD)-1 && strCaption == str) || (dwData == pConstaint->m_dwData))
			SetCurSel(nIndex);
	}

	int nHeight = GetItemHeight(0);
	rect.top = rect.bottom;
	//rect.bottom += nHeight * min(10, GetCount()) + 2;
	rect.bottom += nHeight * min(m_Items2Show, GetCount()) + 2;
	rect.left = rect.right - dx;

	pControl->ClientToScreen(&rect);

	CRect rcWork = XTPMultiMonitor()->GetWorkArea(rect);
	if (rect.bottom > rcWork.bottom && rect.top > rcWork.CenterPoint().y)
		rect.OffsetRect(0, - rect.Height() - pItemArgs->rcItem.Height());

	if (rect.left < rcWork.left) rect.OffsetRect(rcWork.left - rect.left, 0);
	if (rect.right > rcWork.right) rect.OffsetRect(rcWork.right - rect.right, 0);

	SetFocus();

	if (!m_hWnd) // Can be destroyed after focus set
		return;

	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, 0);
	ModifyStyle(WS_CHILD, WS_POPUP);
	SetWindowLongPtr(m_hWnd, GWLP_HWNDPARENT, (LONG_PTR)pControl->m_hWnd);

	SetWindowPos(&CWnd::wndTopMost, rect.left, rect.top, rect.Width(), rect.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);

	CXTPMouseMonitor::SetupHook(this);
}
Esempio n. 20
0
//*****************************************************************************
//
// Function Name: RGridCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
//
// Description:   Message handler for WM_KEYDOWN.
//
// Returns:		   None
//
// Exceptions:	   None
//
//*****************************************************************************
void RGridCtrlBase::OnKeyDown(UINT nChar, UINT, UINT) 
{
	int nCurSel = GetCurSel() ;

	int nRowOffset = 0 ;
	int nColOffset = 0 ;

	int nCurRow = nCurSel / m_nNumCols ;
	int nCurCol = nCurSel % m_nNumCols ;

	switch (nChar)
	{
	case VK_UP:
		nRowOffset = -1;
		break ;

	case VK_DOWN:
		nRowOffset = 1 ;
		break ;

	case VK_LEFT:
		nColOffset = -1 ;
		break ;

	case VK_RIGHT:
		nColOffset = 1 ;
		break ;

	case VK_PRIOR:
		nRowOffset = -m_cxVisibleRows ;
		break ;

	case VK_HOME:
		nRowOffset = -nCurRow ;
		nColOffset = -nCurCol ;
		break ;

	case VK_NEXT:
		nRowOffset = m_cxVisibleRows ;
		break ;

	case VK_END:
		nRowOffset = GetCount() / m_nNumCols - nCurRow ;
		nColOffset = GetCount() % m_nNumCols - nCurCol ;
		break ;

	default:

		// See if we're suppose to send it off to the parent
		if (GetStyle() & LBS_WANTKEYBOARDINPUT)
		{
			VKeyToItem( nChar, GetCurSel() ) ;
		}

		return ;
	}

	if (nCurSel < 0)
	{
		//
		// If there was no previously selected item, default
		// to the first item in the list.
		//

		nCurRow = nCurCol = 0 ;
		nRowOffset = nColOffset = 0 ;
	}
	else
	{
		//
		// Determine the new row and column, making sure to
		// keep them within bounds
		//

		nCurRow += nRowOffset ;
		nCurRow = max( 0, min( nCurRow, GetCount() / m_nNumCols ) ) ;
		
		nCurCol += nColOffset ;
		nCurCol = max( 0, min( nCurCol, m_nNumCols - 1 ) ) ;

		if (nCurRow == GetCount() / m_nNumCols)
		{
			nCurCol = min( nCurCol, GetCount() % m_nNumCols - 1 ) ;
		}
	}

	int nNewSel = nCurRow * m_nNumCols + nCurCol ;

	if (nNewSel != nCurSel)
	{

		if (nCurRow < m_nTopCellRow || nCurRow >= m_nTopCellRow + m_cxVisibleRows ||
			 nCurCol < m_nTopCellCol || nCurCol >= m_nTopCellCol + m_cxVisibleCols)
		{
			SetTopIndex( max( 0, GetTopIndex() + (nNewSel - nCurSel) )) ;
		}

		SetCurSel( nNewSel ) ;

		if (GetStyle() & LBS_NOTIFY)
		{
			GetParent()->PostMessage(WM_COMMAND,
				MAKEWPARAM( GetDlgCtrlID(), LBN_SELCHANGE ), 
				(LPARAM) GetSafeHwnd()) ;
		}
	}
}
Esempio n. 21
0
LONG CAdvComboBox::OnSetCurSel( WPARAM wIndex, LPARAM /*lParam*/ )
{
	int nIndex = (int)wIndex;
	return SetCurSel( nIndex );
}
Esempio n. 22
0
void CLineCombo::SetItemIndex(int index)
{
	if (index<GetCount() && (index>-1))
		SetCurSel(index);
}
Esempio n. 23
0
void	CpMyTabCtrl::ChangeTab(int tabNumber)
{
	SetCurSel(tabNumber);
	ActivateTabDialogs();
}
Esempio n. 24
0
void CUIComboBox::Init()
{
   if( m_iCurSel < 0 ) SetCurSel(0);
}
//-----------------------------------------------------------------------------
// Purpose: Automatically selects the first matching combo box item when the
//			edit control's text changes.
//-----------------------------------------------------------------------------
void CAutoSelComboBox::OnUpdateText(void)
{
	int nCurSel = GetCurSel();
	int nNewSel = nCurSel;

	DWORD dwEditSel = GetEditSel();
	int nEditStart = LOWORD(dwEditSel);
	int nEditEnd = HIWORD(dwEditSel);

	char szTypedText[MAX_PATH];
	GetWindowText(szTypedText, sizeof(szTypedText));

	//
	// Select the first match in the list if what they typed is different from
	// the current selection. This won't do anything if they are deleting characters
	// from the end of the text.
	//
	int nTypedLen = strlen(szTypedText);
	int nLastLen = strlen(m_szLastText);

	bool bSearched = false;
	int nIndex = CB_ERR;
	if (strnicmp(szTypedText, m_szLastText, nTypedLen))
	{
		nIndex = FindString(-1, szTypedText);
		bSearched = true;
	}
	else if (nTypedLen < nLastLen)
	{
		// They deleted characters, try to match the shorter string exactly.
		nIndex = FindStringExact(-1, szTypedText);
		bSearched = true;
	}

	if (bSearched)
	{
		if (nCurSel != nIndex)
		{
			SetCurSel(nIndex);
			nNewSel = nIndex;
		}

		if (nIndex != CB_ERR)
		{
			// Found a match.
			if ((nEditEnd == -1) || (nEditEnd == (int)strlen(szTypedText)))
			{
				SetEditSel(strlen(szTypedText), -1);
			}
			else
			{
				SetEditSel(nEditStart, nEditEnd);
			}
		}
		else
		{
			// No match found.
			SetWindowText(szTypedText);
			SetEditSel(nEditStart, nEditEnd);
		}
	}

	strcpy(m_szLastText, szTypedText);

	if (nNewSel != m_nLastSel)
	{
		GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CBN_SELCHANGE), (LPARAM)m_hWnd);
		m_nLastSel = nNewSel;
	}
}
Esempio n. 26
0
void CCheckListBox::OnKillFocus(CWnd* pNewWnd)
{
	m_nFocus = GetCurSel();
	SetCurSel(-1);
}
Esempio n. 27
0
LRESULT RGridCtrlBase::OnLbSetCurSel( UINT wParam, LONG )
{
	return SetCurSel(wParam);
}
Esempio n. 28
0
// Sets bLBDown member to true, and sets current selection
void CCJOutlookBar::OnLButtonDown(UINT nFlags, CPoint point) 
{
    m_bLBDown = true;
    SetCurSel(GetCurSel());
	CListBox::OnLButtonDown(nFlags, point);
}
Esempio n. 29
0
void CPropTreeItemCombo::OnRefresh() {
	LONG idx = FindCBData( m_lComboData );
	if( idx != CB_ERR ) {
		SetCurSel( idx );
	}
}
Esempio n. 30
0
void CMDITabs::Update()
{
  SetRedraw(false);

  HWND active = ::GetTopWindow(m_mdiClient); // get active view window (actually the frame of the view)

  typedef std::vector<HWND> TWndVec;
  typedef TWndVec::iterator TWndIter;

  TWndVec vChild; // put all child windows in a list (actually a vector)
  for (HWND child = active; child; child = ::GetNextWindow(child, GW_HWNDNEXT))
  {
    vChild.push_back(child);
  }

  TCITEM item;
  char text[256];
  item.pszText = text;

  int i;
  for (i = GetItemCount(); i--;)  // for each tab
  {
    item.mask = TCIF_PARAM;
    GetItem(i, &item);

    TWndIter it = std::find(vChild.begin(), vChild.end(), HWND(item.lParam));
    if (it == vChild.end()) // associatete view does no longer exist, so delete the tab
    {
      DeleteItem(i);
      if (m_bImages) RemoveImage(i);
    }
    else // update the tab's text, image and selection state
    {
      item.mask = TCIF_TEXT;
      ::GetWindowText(*it, text, 256);
      if (m_bImages) m_images.Replace(i, (HICON)::GetClassLongPtr(*it, GCLP_HICON));
      SetItem(i, &item);
      if (*it == active) SetCurSel(i); // associated view is active => make it the current selection
      vChild.erase(it);                // remove view from list
    }
  }

  // all remaining views in vChild have to be added as new tabs
  i = GetItemCount();
  for (TWndIter it = vChild.begin(), end = vChild.end(); it != end; ++it)
  {
    item.mask = TCIF_TEXT|TCIF_PARAM|TCIF_IMAGE;
    ::GetWindowText(*it, text, 256);
	// a bug in wine makes us want to add some extra, spurious tabs.
	// Since there's no text on these extra tabs, we can use this as
	// a discriminator to root them out.
	if(strlen(text)>1)
	{
		if (m_bImages) m_images.Add((HICON)::GetClassLongPtr(*it, GCLP_HICON));
		item.iImage = i;
		item.lParam = LPARAM(*it);
		InsertItem(i, &item);
		if (*it == active) SetCurSel(i);
		++i;
	}
  }

  // this removes the control when there are no tabs and shows it when there is at least one tab
  bool bShow = GetItemCount() >= m_minViews;
  if ((!bShow && IsWindowVisible()) || (bShow && !IsWindowVisible())) 
  {
    static_cast<CMDIFrameWnd*>(FromHandlePermanent(::GetParent(m_mdiClient)))->RecalcLayout();
  }

  RedrawWindow(NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_ERASE);
  SetRedraw(true);
}