Пример #1
0
CDrawQuoteTabCtrl::~CDrawQuoteTabCtrl(void)
{
	RemoveTabItem(-1);
	for (int i = 0; i < m_ayButtonItem.GetCount(); i++)
	{
		CDrawQuoteTab* pItem = m_ayButtonItem.GetAt(i);
		delete pItem;
	}
	m_ayButtonItem.RemoveAll();
}
Пример #2
0
// Scans through all MDIChild windows and refreshes window names and 
// current active window. If bAddNewWindows is set to TRUE then if any
// new MDIChild is found it will be added to the tab control
void COXTabWorkspace::UpdateContents(BOOL bAddNewWindows/*=FALSE*/, 
									 BOOL bUpdateWindowsInfo/*=FALSE*/)
{
	ASSERT(m_pTabClientWnd!=NULL);

    // Check MDI windows
    CMDIFrameWnd* pFrameWnd=GetParentFrame();
    if(pFrameWnd==NULL)
	{
		return;
	}

	BOOL bRecalc=m_pTabClientWnd->m_bForceToRecalc;

	// Get pointer to currently active MDIChild
    CWnd* pActiveChildWnd=pFrameWnd->MDIGetActive(NULL);

    CMDIChildWnd* pChildWnd=NULL;
    int nActiveIndex=-1;

	// Start enumerating from currently active MDIChild
    if(pActiveChildWnd!=NULL)
	{
		pChildWnd=(CMDIChildWnd*)pActiveChildWnd->GetWindow(GW_HWNDFIRST);
	}

    // Flag all current tabs as unfound (for debug purposes in order to check
	// the integrity of the framework)
#ifdef _DEBUG
	int nIndex=0;
    for(nIndex=0; nIndex<m_arrTab.GetSize(); nIndex++)
	{
		m_arrTab[nIndex].bFound=FALSE;
	}
#endif

	int nInsertIndex= PtrToInt(m_arrTab.GetSize());

	// Enumerate all child windows
    while(pChildWnd!=NULL)
    {
		// Window text
		CString sWindowText=GetTextForTabItem(pChildWnd);

		// see if can find it
		int nFoundItem=FindTabItem(pChildWnd->GetSafeHwnd());

		if(nFoundItem!=-1)
		{
			if((pChildWnd->GetStyle()&WS_VISIBLE)==WS_VISIBLE)
			{
				if(pChildWnd==pActiveChildWnd)
				{
					// Found currently active MDIChild
					nActiveIndex=nFoundItem;
				}

#ifdef _DEBUG
				m_arrTab[nFoundItem].bFound=TRUE;
#endif

				// Update text if necessary
				if(m_arrTab[nFoundItem].sText!=sWindowText)
				{
					m_arrTab[nFoundItem].sText=sWindowText;

					//replace "&" characters for doubles "&&"
					int nFind=sWindowText.Find(TEXT('&'));
					while (nFind != -1)
					{
						if (nFind<sWindowText.GetLength())
						{
//							if (sWindowText.GetAt(nFind+1)!=TEXT('&'))
							sWindowText.Insert(nFind+1,TEXT('&'));
							nFind=sWindowText.Find(TEXT('&'),nFind+2);
						}
						else
							nFind=-1;
					}


					TC_ITEM tci;
					tci.mask=TCIF_TEXT;
					tci.pszText=(LPTSTR)(LPCTSTR)sWindowText;
					SetItem(nFoundItem,&tci);

					bRecalc=TRUE;
				}

				if(bUpdateWindowsInfo)
				{
					TC_ITEM tci;
					tci.mask=TCIF_IMAGE;
					GetItem(nFoundItem,&tci);
					// Update icon if necessary
					HICON hIcon=GetWindowIcon(pChildWnd->GetSafeHwnd());
					int nImageIndex=(hIcon==NULL ? -1 : AddTabItemIcon(hIcon));
					if(nImageIndex!=tci.iImage)
					{
						tci.iImage=nImageIndex;
						SetItem(nFoundItem,&tci);
					}
				}
			}
			else
			{
				nInsertIndex--;
				if(nActiveIndex!=-1 && nActiveIndex>nFoundItem)
				{
					nActiveIndex--;
				}
				RemoveTabItem(pChildWnd,FALSE);
				bRecalc=TRUE;
			}
		}
		else if(bAddNewWindows)
		{
			if(nActiveIndex!=-1 && nActiveIndex>=nInsertIndex)
			{
				nActiveIndex++;
			}
			// add item
			InsertTabItem(nInsertIndex,pChildWnd,FALSE);
			bRecalc=TRUE;
		}

		// Get next MDIChild
		pChildWnd=(CMDIChildWnd*)pChildWnd->GetWindow(GW_HWNDNEXT);
    }

#ifdef _DEBUG
    for(nIndex=0; nIndex<m_arrTab.GetSize(); nIndex++)
	{
		ASSERT(m_arrTab[nIndex].bFound);
	}
#endif

	// Set the active item
    if(nActiveIndex>=0 && GetCurSel()!=nActiveIndex)
	{
		SetCurSel(nActiveIndex);
		bRecalc=TRUE;
	}

	if(bRecalc)
	{
		// Update the size and position of the tab control and MDIClient window
		if(::IsWindow(GetParentFrame()->GetSafeHwnd()))
		{
			GetParentFrame()->RecalcLayout();
		}
		m_pTabClientWnd->m_bForceToRecalc=FALSE;
	}
}
Пример #3
0
BOOL CDrawQuoteTabCtrl::ChangeTabGroup( CString strGroup /*= _T("")*/, BOOL bForce /*= FALSE*/ )
{
	if (strGroup.IsEmpty())
	{
		strGroup = GetDefaultTabGroupName();
	}
	if (m_strCurGroupName == strGroup && !bForce)
	{
		return FALSE;
	}	
	m_strCurGroupName = strGroup;
	m_nCurItem = -1;

	PageInfo pageInfo;
	CTabItemArray ayTabItem;
	LONG nCount = m_iTab->GetTabList(strGroup, ayTabItem);
	if (nCount <= 0)
	{
		return FALSE;
	}

	RemoveTabItem(-1);
	int nItemID = m_iTab->GetDefaultTabItemID();
	int nDefault(0);

	CArray<StockType> ayBlockMarket;
	TabItem* pItem = NULL;
	for (int i = 0, j = 0; i < nCount; i++)
	{
		pItem = ayTabItem.GetAt(i);

		ayBlockMarket.RemoveAll();
		m_pDataSource->HSDataSourceEx_GetSystemMarketInfo((unsigned short*)pItem->m_sMarket, MARKETTYPE_COUNT, ayBlockMarket);
		if (ayBlockMarket.GetCount() != 0)
		{
			// 如果服务器当面配置了名称 以服务器那边的名称为主
			strncpy(pItem->m_szName, ayBlockMarket.GetAt(0).m_stTypeName.m_szName, min(strlen(pItem->m_szName), strlen(ayBlockMarket.GetAt(0).m_stTypeName.m_szName)));
			j++;
		}

		if (pItem->m_ID == nItemID)
			nDefault = j - 1;
		
		pageInfo.m_lPageType = pItem->m_lPageType;
		pageInfo.m_lInPageTag = pItem->m_lPageTag;
		for (int i = 0; i < MARKETTYPE_COUNT; i++)
		{
			pageInfo.m_sMarket[i] = pItem->m_sMarket[i];
		}
		memcpy(pageInfo.m_szBlock,pItem->m_szBlock,BLOCK_NAME_LENGTH);
		AddTabItem(pItem->m_szName, pItem->m_ID, pItem->m_lMenuMask, &pageInfo, pItem->m_szColGroupName);
	}
	if (strGroup == GetDefaultTabGroupName())
	{
		ChangeCurItem(nDefault);
	}
	else
		ChangeCurItem(0);
//	m_nLeftOffset = 0;
//	Invalidate(FALSE);
	return TRUE;
}