Exemplo n.º 1
0
// Remove item from the tab control that corresponds to specified MDIChild
BOOL COXTabWorkspace::RemoveTabItem(const CWnd* pChildWnd, BOOL bRedraw/*=TRUE*/)
{
	ASSERT(pChildWnd!=NULL);
	ASSERT(::IsWindow(pChildWnd->GetSafeHwnd()));
	ASSERT((pChildWnd->GetExStyle()&WS_EX_MDICHILD)!=0);

	// Find the item
	int nTabItem=FindTabItem(pChildWnd);

	if(nTabItem==-1)
		return FALSE;

	// Delete the item
	DeleteItem(nTabItem);
	// Remove entry from the internal array of created items
	m_arrTab.RemoveAt(nTabItem);

	// Update the size and position of the tab control and MDIClient window
	if(bRedraw)
	{
		if(::IsWindow(GetParentFrame()->GetSafeHwnd()))
			GetParentFrame()->RecalcLayout();
	}

	return TRUE;
}
Exemplo n.º 2
0
BOOL CDrawQuoteTabCtrl::ChangeCurItem( CString strName, BOOL bNotify /*= TRUE*/, short nMarkType /*= 0*/ )
{
	int nIndex = FindTabItem(strName);
	if (nIndex < 0)		// 若在所有分组内都没有找到指定标签,则单独添加
	{
		//单独添加
		PageInfo pageinfo;
		pageinfo.m_lPageType = PriceAnalisys1;
		if (nMarkType > 0)
		{
			pageinfo.m_lInPageTag = PT_LIST|PT_TYPE;
			pageinfo.AddMarketType(nMarkType);
			if (nMarkType == 0x1201)
			{// 如果是深圳A股 还要加上中小盘股、创业板
				pageinfo.AddMarketType(0x1206);  // 中小盘股
				pageinfo.AddMarketType(0x120d);  // 创业板
			}
		} 
		else
		{
			pageinfo.m_lInPageTag = PT_LIST|PT_BLOCK;
			strncpy(pageinfo.m_szBlock,strName.GetString(),BLOCK_NAME_LENGTH);
		}
		AddTabItem(strName,0,0,&pageinfo);
		//CWinnerApplication::FormatLog(INFO_LOG_LEVEL,QuoteReportLoggerName,"行情报价标签-未发现%s标签,新建标签页,市场类别(0为板块):%d",strName,nMarkType);

		return ChangeCurItem(strName);
	}
	return ChangeCurItem(nIndex, bNotify);
}
Exemplo n.º 3
0
LONG CDrawQuoteTabCtrl::AddTabItem( CString strName, UINT nID, long lMenuMask /*= 0*/, PageInfo* pageInfo /*= NULL*/, CString strGroupName /*= _T("")*/ )
{
	if (strName.IsEmpty() || !pageInfo)
	{
		return -1;
	}

	// 若当前已有此项,则直接返回当前项
	int nIndex = FindTabItem(strName);
	if (nIndex >= 0)
	{
		return nIndex;
	}

	CDrawQuoteTab* pNewItemData = new CDrawQuoteTab;
	pNewItemData->m_strName = strName;
	pNewItemData->m_nID = nID;
	pNewItemData->m_lMenuMask = lMenuMask;
	pNewItemData->m_strColGroupName = strGroupName;
	pNewItemData->m_PageInfo = pageInfo;
	if (lMenuMask & TabUsrDefine)
	{
		pNewItemData->m_lMenuID = m_iTab->GetUserDefMenuID(nID);
	}
	else
	{
		pNewItemData->m_lMenuID = lMenuMask;
	}

	int nCount = 0;
	if (lMenuMask != 0)
	{// 加入导航页
		m_ayGuideItem.Add(pNewItemData);
		nCount = m_ayGuideItem.GetCount();
	} 
	else
	{// 加入标签页
		m_ayItem.Add(pNewItemData);
		nCount = m_ayItem.GetCount();
	}
	return nCount;
}
Exemplo n.º 4
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;
	}
}
Exemplo n.º 5
0
int CDrawQuoteTabCtrl::EnSureVisible( CString strName )
{
	int nIndex = FindTabItem(strName);
	return EnSureVisible(nIndex);
}