void CLibraryFolderCtrl::Update(DWORD nUpdateCookie)
{
	CPtrList pAlready;

	for ( HTREEITEM hItem = GetChildItem( m_hRoot ) ; hItem ; )
	{
		HTREEITEM hNext = GetNextSiblingItem( hItem );

		CLibraryFolder* pFolder = (CLibraryFolder*)GetItemData( hItem );

		if ( LibraryFolders.CheckFolder( pFolder ) )
		{
			Update( pFolder, hItem, NULL, nUpdateCookie, FALSE );
			pAlready.AddTail( pFolder );
		}
		else
		{
			DeleteItem( hItem );
		}

		hItem = hNext;
	}

	for ( POSITION pos = LibraryFolders.GetFolderIterator() ; pos ; )
	{
		CLibraryFolder* pFolder = LibraryFolders.GetNextFolder( pos );

		if ( pAlready.Find( pFolder ) == NULL )
		{
			Update( pFolder, NULL, m_hRoot, nUpdateCookie, FALSE );
		}
	}
}
Ejemplo n.º 2
0
BOOL CInfCreature::GetAffects(CPtrList &list)
{
	if (m_plAffects.GetCount() < 1)
		return(TRUE);

	INF_AFF *pAff, *pNew;
	POSITION pos = m_plAffects.GetHeadPosition();
	while(pos)
	{
		pAff = (INF_AFF*)m_plAffects.GetNext(pos);

		// Don't return the affects that are already handled in special cases.
		if (pAff->dwAffectType == AFF_TYPE_PROF ||	
			 (pAff->dwAffectType == AFF_TYPE_SPELL && !strnicmp(pAff->chResRef3,"SPCL812",7))
			)
			continue;

		pNew = new INF_AFF;
		if (!pNew)
			return(FALSE);

		memcpy(pNew,pAff,sizeof(INF_AFF));

		list.AddTail(pNew);
	}

	TRACE("CInfCreautre::GetAffects() - %d affects found.\n",list.GetCount());
	return(TRUE);
}
Ejemplo n.º 3
0
void* CZipArchive::myalloc(void* opaque, UINT items, UINT size)
{
	void* p = new char[size * items];
	if (opaque)
	{
		CPtrList* list  = (CPtrList*) opaque;
		list->AddTail(p);
	}
	return p;
}
Ejemplo n.º 4
0
void CDlgFreeTrainList::OnNew() 
{
  static WORD InFeederUnitID = 0;
  static WORD OutFeederUnitID = 0;
  static float AverCurrent = 300;
  static float AverAngle = 30;
  static float CurrentChangeRate = (float)0.1;
  static WORD InContinuedSeconds = 30;
  static WORD ChangeContinuedSeconds = 5;
  static WORD OutContinuedSeconds = 30;
  static CString InCurrentChangeRateList;
  static CString OutCurrentChangeRateList;

  CDlgFreeTrain dlg;
  struct TagFreeTrainStruct *pFreeTrain = new TagFreeTrainStruct;
  pFreeTrain->InFeederUnitID = InFeederUnitID;
  pFreeTrain->OutFeederUnitID = OutFeederUnitID;
  pFreeTrain->AverCurrent = AverCurrent;
  pFreeTrain->AverAngle = AverAngle;
  pFreeTrain->CurrentChangeRate = CurrentChangeRate;
  pFreeTrain->InContinuedSeconds = InContinuedSeconds;
  pFreeTrain->ChangeContinuedSeconds = ChangeContinuedSeconds;
  pFreeTrain->OutContinuedSeconds = OutContinuedSeconds;
  strcpy(pFreeTrain->InCurrentChangeRateList,InCurrentChangeRateList.GetBuffer(0));
  strcpy(pFreeTrain->OutCurrentChangeRateList,OutCurrentChangeRateList.GetBuffer(0));
  pFreeTrain->StartupDelaySecond = g_StartupDelaySecond;
  dlg.m_pFreeTrain = pFreeTrain;
  if(dlg.DoModal()==IDOK)
  {
    InFeederUnitID = pFreeTrain->InFeederUnitID;
    OutFeederUnitID = pFreeTrain->OutFeederUnitID;
    AverCurrent = pFreeTrain->AverCurrent;
    AverAngle = pFreeTrain->AverAngle;
    CurrentChangeRate = pFreeTrain->CurrentChangeRate;

    InContinuedSeconds = pFreeTrain->InContinuedSeconds;
    ChangeContinuedSeconds = pFreeTrain->ChangeContinuedSeconds;
    OutContinuedSeconds = pFreeTrain->OutContinuedSeconds;
    InCurrentChangeRateList = pFreeTrain->InCurrentChangeRateList;
    OutCurrentChangeRateList = pFreeTrain->OutCurrentChangeRateList;
    g_StartupDelaySecond = pFreeTrain->StartupDelaySecond;

    pFreeTrain->InBeginTime = CTime::GetCurrentTime() + CTimeSpan(0,0,0,pFreeTrain->StartupDelaySecond);;
    pFreeTrain->InFinishTime = pFreeTrain->InBeginTime+CTimeSpan(0,0,0,pFreeTrain->InContinuedSeconds);
    pFreeTrain->ChangeBeginTime = pFreeTrain->InFinishTime;
    pFreeTrain->ChangeFinishTime = pFreeTrain->ChangeBeginTime+CTimeSpan(0,0,0,pFreeTrain->ChangeContinuedSeconds);
    pFreeTrain->OutBeginTime = pFreeTrain->ChangeFinishTime;
    pFreeTrain->OutFinishTime = pFreeTrain->OutBeginTime+CTimeSpan(0,0,0,pFreeTrain->OutContinuedSeconds);

    g_FreeTrainManageList.AddTail(pFreeTrain);
  
	  UpdateList();
    ::SelectListLastItem(m_ctlList);
  }
}
void CXTPMarkupEventHandlerMap::Add(CXTPMarkupRoutedEvent* pEvent, CXTPMarkupDelegate* pDelegate)
{
	CPtrList* pHandlers;
	if (!m_mapHandlers.Lookup(pEvent, pHandlers))
	{
		pHandlers  = new CPtrList();
		m_mapHandlers.SetAt(pEvent, pHandlers);
	}

	pHandlers->AddTail(pDelegate);
}
Ejemplo n.º 6
0
void CPisaList::CopyAllPaiToIntPtrList(CPtrList& to)
{
	for(POSITION pos = m_PisaList.GetHeadPosition(); pos != NULL; )
	{
		Node* nd=(Node*)m_PisaList.GetNext(pos);
		if(!nd)continue;
		int *pp=new int;
		*pp=nd->mPisa.m_iPs;
		to.AddTail(pp);

	}
}
Ejemplo n.º 7
0
BOOL CDlgFreeTrainList::LoadFreeTrainManageListFile()
{
  CString FileName = g_ProjectFilePath + "FeedTrain.lst";
  CFile file;
	if(!file.Open(FileName, CFile::modeRead))
  {
    ::AfxMessageBox(FileName + " 文件读取失败");
    return FALSE;
  }
  else
  {
    CArchive ar(&file,CArchive::load);

    g_FreeTrainManageList.RemoveAll();

    CString title = "FreeTrainList 1.0";
    ar>>title;

    WORD Count = g_FreeTrainManageList.GetCount();
    ar>>Count;
    
    for(int no=0;no<Count;no++)
    {
      struct TagFreeTrainStruct *pFreeTrain = new TagFreeTrainStruct;
      g_FreeTrainManageList.AddTail(pFreeTrain);
      ar>>pFreeTrain->InFeederUnitID;
      ar>>pFreeTrain->OutFeederUnitID;
      ar>>pFreeTrain->AverCurrent;
      ar>>pFreeTrain->AverAngle;
      ar>>pFreeTrain->CurrentChangeRate;
      ar>>pFreeTrain->InContinuedSeconds;
      ar>>pFreeTrain->ChangeContinuedSeconds;
      ar>>pFreeTrain->OutContinuedSeconds;
      ar>>pFreeTrain->StartupDelaySecond;
      CString InCurrentChangeRateList;
      CString OutCurrentChangeRateList;
      ar>>InCurrentChangeRateList;
      ar>>OutCurrentChangeRateList;
      strcpy(pFreeTrain->InCurrentChangeRateList,InCurrentChangeRateList.GetBuffer(0));
      strcpy(pFreeTrain->OutCurrentChangeRateList,OutCurrentChangeRateList.GetBuffer(0));
      ar>>g_SetCheck[no];
    }

    ar.Flush();
    ar.Close();
    file.Close();
  }	

  return TRUE;
}
Ejemplo n.º 8
0
// 그룹핑을 해제시키는 함수
void Group::DisGrouping(CPtrList& listObj, CPtrList& listObj2)
{
	//노드 데이터 부분의 그룹 해제
	POSITION posNode = this->NodeData.GetHeadPosition();
	while (posNode) //노드 데이터 리스트 순회
	{
		Figure* pObj = (Figure*)this->NodeData.GetNext(posNode);
		pObj->SetGrouped(FALSE); //그룹이 아님을 표시
		pObj->setSelected(TRUE);
		listObj.AddTail(pObj); //선택 리스트에 넣음
		listObj2.AddTail(pObj); //선택 리스트에 넣음
	}
	this->NodeData.RemoveAll();

	//차일드 부분의 그룹 해제
	POSITION posChild = this->Child.GetHeadPosition();
	while (posChild) //차일드 리스트 순회
	{
		Group* pObj = (Group*)this->Child.GetNext(posChild);
		pObj->SetGrouped(FALSE); //그룹이 아님을 표시
		listObj.AddTail(pObj); //선택 리스트에 넣음
		listObj2.AddTail(pObj); //선택 리스트에 넣음
	}
}
Ejemplo n.º 9
0
void CDlgFreeTrainList::OnClon() 
{
  if(m_ctlList.GetSelectedCount()!=1)
    return;

  POSITION pos = m_ctlList.GetFirstSelectedItemPosition();
  int item = m_ctlList.GetNextSelectedItem(pos);
  struct TagFreeTrainStruct *pFreeTrain = (TagFreeTrainStruct *)g_FreeTrainManageList.GetAt(g_FreeTrainManageList.FindIndex(item));
  struct TagFreeTrainStruct *pNewFreeTrain = new TagFreeTrainStruct;
  memcpy(pNewFreeTrain,pFreeTrain,sizeof(TagFreeTrainStruct));
  g_FreeTrainManageList.AddTail(pNewFreeTrain);

	UpdateList();
  ::SelectListLastItem(m_ctlList);
}
Ejemplo n.º 10
0
void CWindowManager::Close()
{
	CSingleLock pLock( &theApp.m_pSection, TRUE );
	CPtrList pClose;
	
	for ( POSITION pos = GetIterator() ; pos ; )
	{
		pClose.AddTail( GetNext( pos ) );
	}
	
	for ( pos = pClose.GetHeadPosition() ; pos ; )
	{
		CChildWnd* pChild = (CChildWnd*)pClose.GetNext( pos );
		pChild->DestroyWindow();
	}
}
Ejemplo n.º 11
0
CDuiWkeView::CDuiWkeView(HWND hWnd, CDuiObject* pDuiObject)
	: CControlBase(hWnd, pDuiObject)
{
	m_bTabStop = TRUE;	// 可以响应tab键
	m_OldWndProc = ::DefWindowProc;
	m_bCreated = false;
	m_bCreating = false;
	m_bDelayCreate = false;
	m_bTransparent = false;
	m_pWebView = NULL;
	m_strUrl = _T("");
	m_strHtml = _T("");

	CDuiWkeView::WkeInit();
	g_duiWkeViews.AddTail(this);
}
Ejemplo n.º 12
0
int CPisaList::GetSelectedCount(CPtrList& pl)
{
	int ret=0;
	for(POSITION pos = m_PisaList.GetHeadPosition(); pos != NULL; )
	{
		Node* nd=(Node*)m_PisaList.GetNext(pos);
		if(!nd)continue;
		if(nd->IsSelect)
		{
			int * pi=new int;
			*pi=nd->mPisa.m_iPs ;
			pl.AddTail (pi);
			ret++;
		}
	}
	return ret;
}
Ejemplo n.º 13
0
STDMETHODIMP
CDirect2DRM::Tick(DWORD nElapsedTime)
{
	CPtrList			listTicked;
	LPD2DRMIMAGEPRIVATE pd2di;
	
	// NOTE: This code is NOT critical sectioned. This is because only images which
	// have textures will be on the ticked list and textures are ONLY released (and 
	// therefore their images removed from the ticked list) via the ReleaseTextures() 
	// method. The ReleaseTextures() method MUST be called from the same thread as 
	// this method.
	// REVIEW: The CS now added ALMOST removes the need for textures to be released in the
	// rendering thread. However it is still possible for the texture to be accessed
	// inside the image Tick after it has been destroyed.

	// Work through list (safely inside CS) plucking off images and AddRef'ing them
	// (need to AddRef 'cause could get a TextureDestroyCallback while we're in the
	// image Tick). Cannot do image Tick inside CS since can deadlock with DelTicked
	// which will be called from TextureDestroyCallback (inside D3D CS).
	EnterCriticalSection(&m_CSTickedList);

	for (POSITION pos = m_listTicked.GetHeadPosition(); pos;)
	{
		pd2di = (LPD2DRMIMAGEPRIVATE) m_listTicked.GetNext(pos);

		if (pd2di)
			pd2di->AddRef();

		listTicked.AddTail(pd2di);
	}
	LeaveCriticalSection(&m_CSTickedList);

	// Now Tick the AddRef'd images from this separate list.
	for (pos = listTicked.GetHeadPosition(); pos;)
	{
		pd2di = (LPD2DRMIMAGEPRIVATE) listTicked.GetNext(pos);
		if (pd2di)
			pd2di->Tick(nElapsedTime);
		MMRELEASE(pd2di);
	}

	return S_OK;
}
Ejemplo n.º 14
0
BOOL CInfGame::GetGlobals(CPtrList &list)
{
	if (m_plGlobals.GetCount() < 1)
		return(TRUE);

	INF_GAME_GLOBAL *pGlobal, *pNew;
	POSITION pos = m_plGlobals.GetHeadPosition();
	while(pos)
	{
		pGlobal = (INF_GAME_GLOBAL*)m_plGlobals.GetNext(pos);

		pNew = new INF_GAME_GLOBAL;
		if (!pNew)
			return(FALSE);

		memcpy(pNew,pGlobal,sizeof(INF_GAME_GLOBAL));

		list.AddTail(pNew);
	}

	return(TRUE);
}
Ejemplo n.º 15
0
bool CORDBList::ReadDBInfo()
{
CDBInfo			*db;
CStdioFile		listfile, infofile;
CFileStatus		fstatus;
CFileException	e;
CPtrList		plist;
char			data[1025];
char			*tmp;


	if (infofile.Open(m_ordbinfo, CFile::modeRead)) {
		while (1) {
			memset(data, 0x00, 1024);
			TRY {
				if (infofile.ReadString(data, 1024) == NULL) break;
				data[strlen(data)-1] = NULL;

				db = new CDBInfo();
				tmp = strtok(data, " ");	// db name
				if (tmp) {
					db->m_dbname.Format("%s", tmp);
				}
				tmp = strtok(NULL, " "); // permanent
				if (tmp) {
					if (!strcmp(tmp, "1")) db->m_permanent = true;
					else				  db->m_permanent = false;
				} 
				plist.AddTail(db);
			}
			CATCH_ALL(e)
			{
				break;
			}
			END_CATCH_ALL
		}
		infofile.Close();
	} 

	if (listfile.Open(m_ordblist, CFile::modeRead)) {
		listfile.GetStatus(fstatus);
		m_LastTime = fstatus.m_mtime;
	} else {
		return false;
	}

	while (1) {
		memset(data, 0x00, 1024);
		TRY {
			if (listfile.ReadString(data, 1024) == NULL) break;
			data[strlen(data)-1] = NULL;

			db = new CDBInfo();
			tmp = strtok(data, " ");	// db name
			if (tmp) {
				db->m_dbname.Format("%s", tmp);
			}
			tmp = strtok(NULL, " "); // db path
			if (tmp) {
				db->m_dbpath.Format("%s", tmp);
			}
			tmp = strtok(NULL, " "); // host
			if (tmp) {
				db->m_host.Format("%s", tmp);
			}
			tmp = strtok(NULL, " "); // log path
			if (tmp) {
				db->m_logpath.Format("%s", tmp);
			}
			int cnt = (int) plist.GetCount();
			if (cnt > 0) {
				for (int i = 0; i < cnt; i++) {
					CDBInfo *p = (CDBInfo *)plist.GetAt(plist.FindIndex(i));
					if (db->m_dbname == p->m_dbname) {
						db->m_permanent = p->m_permanent;
						break;
					}
				}
			}
			m_List.AddTail(db);
		}
		CATCH_ALL(e)
		{
			break;
		}
		END_CATCH_ALL
	}

	listfile.Close();

	while (!plist.IsEmpty()) {
		CDBInfo *p = (CDBInfo *)plist.RemoveHead();
		delete p;
	}

	return true;
}
Ejemplo n.º 16
0
/*-----------------------------------------------------------------
【函数介绍】:  此线程用于检测监听套接字事件。
【入口参数】:  lparam:无类型指针,可以通过此参数,向线程中传入需要用到的资源。
			   在这里我们将CTCPServer_CE类实例指针传进来
【出口参数】:  (无)
【返回  值】:  返回值没有特别的意义,在此我们将返回值设为0。
------------------------------------------------------------------*/
DWORD CTCPServer_CE::SocketThreadFunc(PVOID lparam)
{
	CTCPServer_CE *pSocket;
	//得到CTCPServer_CE实例指针
	pSocket = (CTCPServer_CE*)lparam;
	//定义读事件集合
	fd_set fdRead;
	int ret;
	TIMEVAL	aTime;
	aTime.tv_sec = 1;
	aTime.tv_usec = 1;
	while (TRUE)
	{
        //收到退出事件,结束线程
		if (WaitForSingleObject(pSocket->m_exitThreadEvent,0) == WAIT_OBJECT_0)
		{
			break;
		}
		
		FD_ZERO(&fdRead);
		FD_SET(pSocket->m_ServerSocket,&fdRead);
		
		//监听事件
		ret = select(0,&fdRead,NULL,NULL,&aTime);
		
		if (ret == SOCKET_ERROR)
		{
			//触发错误事件
			int iErrorCode = WSAGetLastError();
			//触发服务器socket的错误事件
			if (pSocket->OnServerError)
			{
				pSocket->OnServerError(pSocket->m_pOwner,pSocket,iErrorCode);
			}
			//关闭服务器套接字 
			closesocket(pSocket->m_ServerSocket);
			break;
		}
		
		if (ret > 0)
		{
			//判断是否读事件
			if (FD_ISSET(pSocket->m_ServerSocket,&fdRead))
			{
				//如果调用了Listen,则表示触发了OnAccept事件
				
				SOCKADDR_IN clientAddr;
				CTCPCustom_CE * pClientSocket = new CTCPCustom_CE();
				int namelen = sizeof(clientAddr);
				//等待,创建与客户端连接的套接字
				pClientSocket->m_socket = accept(pSocket->m_ServerSocket, (struct sockaddr *)&clientAddr, &namelen);
				//接收到客户端连接
				if (pClientSocket->m_socket)
				{
					pClientSocket->m_RemoteHost = inet_ntoa(clientAddr.sin_addr);
					pClientSocket->m_RemotePort = ntohs(clientAddr.sin_port);
					
					//触发与客户端建立连接事件
					if (pSocket->OnClientConnect)
					{
						pSocket->OnClientConnect(pSocket->m_pOwner,pClientSocket);
					}
					//打开pClientSocket服务线程
					pClientSocket->Open(pSocket);
					//添加到客户端连接队列中
					m_ListClientSocket.AddTail(pClientSocket);
				}
				else
				{
					//失败,释放内存
					delete pClientSocket;
					pClientSocket = NULL;
				}	
			}
		}
	}
	//
	TRACE(L"服务器端线程退出\n");
	return 0;
}
Ejemplo n.º 17
0
void CDlgTimedMessageBox::GetWindowHandles(void)
{
	HWND		hWnd;
	CWnd		*pWnd;
	CString		title;
	CPtrList	allButtons;

	//
	// Handle of the messageBox
	//
	if( !m_hMsgBox )
	{
		hWnd = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
		while( (hWnd!=NULL) && (m_hMsgBox==NULL) )
		{
			pWnd = CWnd::FromHandle(hWnd);
			pWnd->GetWindowText(title);

			if( ::AfxIsDescendant(m_hParent, hWnd) && ::IsWindowVisible(hWnd) && (m_Title.CompareNoCase(title)==0) )
			{
				m_hMsgBox = hWnd;
				break;
			}
			
			hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
		}
	}

	//
	// Handle of the static text
	// TODO only if text-replace is needed
	//
	if( m_hMsgBox && !m_hStaticText )
	{
		// not sure if this will work always
		// under Win2000 it did
		//m_hStaticText = ::GetDlgItem(m_hMsgBox, 0xFFFF);

		// not sure, so lets find it dynamically!

		char		className[_MAX_PATH];
		CString		classNameOk("STATIC");
		LONG		id;

		hWnd = ::GetWindow(m_hMsgBox, GW_CHILD);
		while( (hWnd!=NULL) && (m_hStaticText==NULL) )
		{
			id = ::GetWindowLong(hWnd, GWL_ID);
			
			// small ids only for buttons
			if( id > IDHELP )
			{
				if( ::GetClassName(hWnd, className, _MAX_PATH) )
				{

					// looking only for a static 
					if( classNameOk.CompareNoCase(className) == 0 )
					{
						// not check the text
						pWnd = CWnd::FromHandle(hWnd);
						pWnd->GetWindowText(title);
						
						if( m_CurrentMessage.CompareNoCase(title) == 0 )
						{
							m_hStaticText = hWnd;
							break;
						}

					}
				}
			}
			else
			{
				allButtons.AddTail(hWnd);
			}

			hWnd = ::GetWindow(hWnd, GW_HWNDNEXT);
		}

	}

	//
	// Handle of the default button
	//
	if( m_hMsgBox && !m_hDefaultButton )
	{
		m_hDefaultButton = ::GetDlgItem(m_hMsgBox, m_DefaultReturn);
		
		// Problem: (reported from Keith Brown)
		// if generated with MB_OK the button has NOT IDOK, but IDCANCEL !!
		// then lets take the first button we find !
		// (with and IDCANCEL this works, because it is the only button
		// if this problem encounters also with 2 buttons, I have no chance 
		// to find out which one is the better one!)
		while( allButtons.GetCount()>0 && !m_hDefaultButton )
		{
			m_hDefaultButton = (HWND) allButtons.GetHead();
			allButtons.RemoveHead();
			
			if( m_hDefaultButton )
				m_DefaultReturn = ::GetWindowLong(m_hDefaultButton, GWL_ID);
		}
	}
}
Ejemplo n.º 18
0
void CLibraryFolderCtrl::Update(CLibraryFolder* pFolder, HTREEITEM hFolder, HTREEITEM hParent, DWORD nUpdateCookie, BOOL bRecurse)
{
	if ( ! hFolder )
	{
		DWORD dwStyle = INDEXTOOVERLAYMASK( pFolder->IsShared() ? 0 : SHI_O_LOCKED );

		if ( pFolder->m_sPath.CompareNoCase( Settings.Downloads.CompletePath ) == 0 ) dwStyle |= TVIS_BOLD;

		if ( m_bMultiSelect && GetFirstSelectedItem() == NULL ) dwStyle |= TVIS_SELECTED;
		if ( pFolder->m_bExpanded ) dwStyle |= TVIS_EXPANDED;

		CString strName = pFolder->m_sName;

		if ( pFolder->m_pParent == NULL )
		{
			CString strDrive;
			if ( pFolder->m_sPath.Find( _T(":\\") ) == 1 || pFolder->m_sPath.GetLength() == 2 )
				strDrive.Format( _T(" (%c:)"), pFolder->m_sPath[0] );
			else
				strDrive = _T(" (Net)");

			strName += strDrive;
			dwStyle |= TVIS_EXPANDED;
		}

		hFolder = InsertItem( TVIF_PARAM|TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_STATE,
			strName, SHI_FOLDER_CLOSED, SHI_FOLDER_CLOSED, dwStyle,
			TVIS_EXPANDED|TVIS_SELECTED|TVIS_OVERLAYMASK, (LPARAM)pFolder, hParent, TVI_SORT );
	}
	else
	{
		DWORD dwMask = TVIS_OVERLAYMASK | TVIS_BOLD;
		DWORD dwStyle = INDEXTOOVERLAYMASK( pFolder->IsShared() ? 0 : SHI_O_LOCKED );

		if ( pFolder->m_sPath.CompareNoCase( Settings.Downloads.CompletePath ) == 0 ) dwStyle |= TVIS_BOLD;

		DWORD dwExisting = GetItemState( hFolder, dwMask ) & dwMask;

		if ( dwExisting != dwStyle ) SetItemState( hFolder, dwStyle, dwMask );
	}

	if ( nUpdateCookie )
	{
		if ( bRecurse || ( GetItemState( hFolder, TVIS_SELECTED ) & TVIS_SELECTED ) )
		{
			pFolder->m_nSelectCookie = nUpdateCookie;
			bRecurse |= ( GetItemState( hFolder, TVIS_EXPANDED ) & TVIS_EXPANDED ) == 0;
		}
	}

	CPtrList pAlready;

	for ( HTREEITEM hItem = GetChildItem( hFolder ) ; hItem ; )
	{
		HTREEITEM hNext = GetNextSiblingItem( hItem );

		CLibraryFolder* pChild = (CLibraryFolder*)GetItemData( hItem );

		if ( pFolder->CheckFolder( pChild ) )
		{
			Update( pChild, hItem, NULL, nUpdateCookie, bRecurse );
			pAlready.AddTail( pChild );
		}
		else
		{
			DeleteItem( hItem );
		}

		hItem = hNext;
	}

	for ( POSITION pos = pFolder->GetFolderIterator() ; pos ; )
	{
		CLibraryFolder* pChild = pFolder->GetNextFolder( pos );

		if ( pAlready.Find( pChild ) == NULL )
		{
			Update( pChild, NULL, hFolder, nUpdateCookie, bRecurse );
		}
	}

	int nOldImage1, nOldImage2;
	GetItemImage( hFolder, nOldImage1, nOldImage2 );

	int nImage = ItemHasChildren( hFolder ) && ( GetItemState( hFolder, TVIS_EXPANDED ) & TVIS_EXPANDED );
	nImage = nImage ? SHI_FOLDER_OPEN : SHI_FOLDER_CLOSED;
	if ( nOldImage1 != nImage ) SetItemImage( hFolder, nImage, nImage );
}
Ejemplo n.º 19
0
BOOL 	CWedApp::SaveAllModified()

{
	// Save reopen information:
	CString	buf;
	CPtrList il;
	int		row, col;

    // Save list of buffers
	if(!comline)
    	{
		int count = 0;
		POSITION Pos = pDocTemplate->GetFirstDocPosition();
		// Make a list, current edited buffer as last
		for(;;)
			{
			if(!Pos)
				break;
			CWedDoc* doc = (CWedDoc*)pDocTemplate->GetNextDoc(Pos);
			POSITION pos = doc->GetFirstViewPosition();
			CView *cv = doc->GetNextView(pos); 	ASSERT_VALID(cv);
			if(cv != currentedit)
				il.AddTail(cv);
			}

	if(currentedit)
		il.AddTail(currentedit);

	POSITION pos = il.GetHeadPosition();
	for(;;)
		{
		if(!pos)
			break;
		CView *cv = (CView*)il.GetNext(pos);
		if(!cv)
			break;
		ASSERT_VALID(cv);

		CWedDoc* doc = (CWedDoc*)cv->GetDocument();
		if(!doc)
			break;
		ASSERT_VALID(doc);

		CString fline =doc->strlist.GetLine(0);

		// If it is a new doc
 		if(doc->strlist.GetCount() == 1 &&
			fline.GetLength() == 0)
			{
			//P2N("New doc: %d\r\n",  doc);
			}
		else
			{
			CString file = doc->GetPathName();
			row = ((CWedView*)cv)->row; col = ((CWedView*)cv)->col;
			buf.Format("%d", count + 1);

			WriteProfileString(strSection,  strStringItem + buf, file);
			WriteProfileInt(strSection,  strStringItem + buf + "row", row);
			WriteProfileInt(strSection,  strStringItem + buf + "col", col);
			count++;
			}
		}
	WriteProfileInt(strSection, strIntItem, count);
	}

	// Serialize holdings
	message ("Saving holdings");
	SaveHoldings();

	// Serialize macros
	message ("Saving macros");
	SaveMacros();

	// Save config information:
	CTime t = CTime::GetCurrentTime();
	WriteProfileInt(strConfig, "strLastUsage", (int)t.GetTime());
	WriteProfileInt(strConfig, "strUsage", use);

	// Save main frame window placement
	WINDOWPLACEMENT wp;
	pMainFrame->GetWindowPlacement(&wp);
	WriteProfileInt(strConfig, "WindowState",  wp.showCmd);
	// Save file informaion

	// Save current window focus:

	// Save font info
    LOGFONT lf; ff.GetObject(sizeof(LOGFONT), &lf);
	WriteProfileString(strConfig,  strFontName, lf.lfFaceName);
	WriteProfileInt(strConfig,  strFontSize, lf.lfHeight);
	WriteProfileInt(strConfig,  strFontWeight, lf.lfWeight);
	WriteProfileInt(strConfig,  strFontItalic, lf.lfItalic);

	// Save color info
	WriteProfileInt(strConfig,  strColorBg, 	bgcol);
	WriteProfileInt(strConfig,  strColorFg, 	fgcol);
	WriteProfileInt(strConfig,  strColorSel , 	selcol );
    WriteProfileInt(strConfig,  strColorCSel, 	cselcol);
    WriteProfileInt(strConfig,  strColorAdd , 	cadd   );
    WriteProfileInt(strConfig,  strColorDel , 	cdel   );
    WriteProfileInt(strConfig,  strColorChg , 	cchg   );
    WriteProfileInt(strConfig,  strColorComm, 	comm   );
    WriteProfileInt(strConfig,  strColorSrc , 	srcc   );
    WriteProfileInt(strConfig,  strColorLong , 	clng   );

	// Save backwrap
	WriteProfileInt(strConfig,  strBackWrap , backwrap);

	// Save tab2space
	WriteProfileInt(strConfig,  strTab2Space, Tab2Space);

	// Save tabstop
	WriteProfileInt(strConfig,  strTabStop, tabstop);




	return CWinApp::SaveAllModified();
}
Ejemplo n.º 20
0
void CDlgPowerMonitor::OnTimer(UINT nIDEvent) 
{
  if(IsWindowVisible())
  {
    CSingleLock sLock(&g_PowerMutex);
    sLock.Lock();

    CPtrList FeedList;
    {
      POSITION pos = g_1B35FeedList.GetHeadPosition();
      while(pos)
      {
        struct TagUnitStruct *pUnit = (TagUnitStruct *)g_1B35FeedList.GetNext(pos);
        FeedList.AddTail(pUnit);
      }
    }
    {
      POSITION pos = g_2B35FeedList.GetHeadPosition();
      while(pos)
      {
        struct TagUnitStruct *pUnit = (TagUnitStruct *)g_2B35FeedList.GetNext(pos);
        FeedList.AddTail(pUnit);
      }
    }

    {
      WORD FeedCount = 0;
      POSITION pos = FeedList.GetHeadPosition();
      while(pos)
      {
        struct TagUnitStruct *pUnit = (TagUnitStruct *)FeedList.GetNext(pos);
        if(pUnit->UnitType==4)//线路保护
          FeedCount++;
      }

      while(m_ctlFeedList.GetItemCount()<FeedCount)
      {
        ::AddListItem(m_ctlFeedList,0,0,"");
      }
      while(m_ctlFeedList.GetItemCount()>FeedCount)
      {
        m_ctlFeedList.DeleteItem(0);
      }

      {
        int item=0;
        POSITION pos = FeedList.GetHeadPosition();
        while(pos)
        {
          struct TagUnitStruct *pUnit = (TagUnitStruct *)FeedList.GetNext(pos);
          if(pUnit->UnitType==4)//线路保护
          {
            ::SetItemText(m_ctlFeedList,item,0,pUnit->UnitName);
            ::SetItemText(m_ctlFeedList,item,1,::GetFormatText("%0.1f",pUnit->VarGroup[0].Var[8].Value));
            item++;
          }
        }
      }
    }
    {
      WORD PowerCount = g_FreeTransmissionList.GetCount();
      while(m_ctlTransmissionList.GetItemCount()<PowerCount)
      {
        ::AddListItem(m_ctlTransmissionList,0,0,"");
      }
      while(m_ctlTransmissionList.GetItemCount()>PowerCount)
      {
        m_ctlTransmissionList.DeleteItem(0);
      }

	    int item = 0;

      POSITION pos = g_FreeTransmissionList.GetHeadPosition();
      while(pos)
      {
        TagFreeTransmissionStruct *pTransmission = (TagFreeTransmissionStruct *)g_FreeTransmissionList.GetNext(pos);
   
        CString msg;
        CTime ct = CTime::GetCurrentTime();
        if(ct<pTransmission->BeginTime)
          msg.Format("传动等待 %d(秒)",(pTransmission->BeginTime-ct).GetTotalSeconds());
        else if(ct>pTransmission->FinishTime)
          msg.Format("传动完成 %d(秒)",(ct-pTransmission->FinishTime).GetTotalSeconds());
        else
          msg.Format("传动中.. %d(秒)",(pTransmission->FinishTime-ct).GetTotalSeconds());
        ::SetItemText(m_ctlTransmissionList,item,0,msg);

        ::SetItemText(m_ctlTransmissionList,item,1,g_Unit[pTransmission->FeederUnitID].UnitName);
        ::SetItemText(m_ctlTransmissionList,item,2,::GetFormatText("%d",pTransmission->ContinuedSeconds));
        ::SetItemText(m_ctlTransmissionList,item,3,::GetFormatText("%0.0f",pTransmission->AverCurrent));
        ::SetItemText(m_ctlTransmissionList,item,4,::GetFormatText("%0.0f",pTransmission->AverAngle));
        ::SetItemText(m_ctlTransmissionList,item,5,::GetFormatText("%d",pTransmission->StartupDelaySecond));

        item++;
      }
    }
  }

  CDialog::OnTimer(nIDEvent);
}