Пример #1
0
void SeriesListCtrl::OnDeleteSeries()
{
	POSITION pos=GetFirstSelectedItemPosition(); bool upd=false; void *x;
	if(pos)
	{
		CArray<int,const int&> ToDel; int i; CString temp; 
		while(pos) ToDel.Add(GetItemData(GetNextSelectedItem(pos)));
		qsort(ToDel.GetData(),ToDel.GetSize(),sizeof(int),compfunc);

		for(i=0;i<ToDel.GetSize();i++)
		{
			int n=ToDel[i];			
			temp.Format("Series %s contains %d points. Remove it?",Items[n].Name,Items[n].Size);
			if(AfxMessageBox(temp,MB_YESNO)==IDNO) ToDel[i]=-1;		
		}
		
		if((x=Series->GainAcsess(WRITE))!=0)
		{
			upd=true;
			SeriesProtector Protector(x); TSeriesArray& Series(Protector);
			{
				for(i=0;i<ToDel.GetSize();i++)
					if(ToDel[i]>=0) Series.DeleteItem(ToDel[i]);
			}
		}
		if(upd) UpdateSeriesList();
	}		
}
Пример #2
0
void CTemplateParserApp::AddMissingFile(CString csFile)
{
   // unfortunately doesn't work: as FileExists() doesn't work

   char szFileName[MAX_PATH*2];
   strcpy (szFileName, (LPCTSTR)csFile);

   CArray<CString, CString> nonExistant;

   char *szSuffix = strrchr(szFileName, '\\');
   while(NULL != szSuffix && !FileExists(szFileName))
   {
      // there must be at least one \ remaining in szFile (i.e. c:\)

      CString csNono(szFileName);
      // TODO: Wie geht denn das hier mit der Speicherverwaltung??
      // Diese Variable ist doch nur auf dem Stack.
      nonExistant.Add(csNono);

      szSuffix[0] = '\0';

      szSuffix = strrchr(szFileName, '\\');
   }

   if (nonExistant.GetSize() > 0)
   {
      for (int i=nonExistant.GetSize()-1; i>=0; --i)
      {
         m_writtenFiles.Add(nonExistant[i]);
         // it is important that them are added in reverse order 
         // so that created directories are before the contained files
      }
   }
}
Пример #3
0
void CDirstatDoc::OnViewShowunknown()
{
	CArray<CItem *, CItem *> drives;
	GetDriveItems(drives);

	if (m_showUnknown)
	{
		for (int i=0; i < drives.GetSize(); i++)
		{
			CItem *unknown= drives[i]->FindUnknownItem();
			ASSERT(unknown != NULL);
		
			if (GetSelection() == unknown)
				SetSelection(unknown->GetParent());

			if (GetZoomItem() == unknown)
				m_zoomItem= unknown->GetParent();

			drives[i]->RemoveUnknownItem();
		}
		m_showUnknown= false;
	}
	else
	{
		for (int i=0; i < drives.GetSize(); i++)
			drives[i]->CreateUnknownItem();
		m_showUnknown= true;
	}

	if (drives.GetSize() > 0)
        SetWorkingItem(GetRootItem());

	UpdateAllViews(NULL);
}
Пример #4
0
void CSkyODL::OnDrawFace( Gdiplus::Graphics& gcDrawer, float fScale )
{
	CBaseODL::OnDrawFace(gcDrawer, fScale);
	
	Gdiplus::Pen Dot( m_clDotColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
	CArray<Gdiplus::Point> st;
	CArray<BYTE> stBytes;

	for (auto& curItem : m_arrTopPoint)
	{
		Gdiplus::Point pt;
		pt.X = static_cast<INT>(curItem.X());
		pt.Y = static_cast<INT>(-curItem.Z());
		st.Add(pt);
	}

	if(st.GetSize()<=0)
	{
		return;
	}
	Gdiplus::Pen pen( m_clPenColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
	pen.SetDashStyle(Gdiplus::DashStyleSolid);

	Gdiplus::HatchBrush brush( Gdiplus::HatchStyle(Gdiplus::HatchStyle::HatchStyleCross ), m_clPenColor, Gdiplus::Color(0,255,255,255) );
	//画皮肤
	gcDrawer.FillPolygon(&brush, st.GetData(), st.GetSize(), Gdiplus::FillMode::FillModeAlternate);

	gcDrawer.DrawLines(&pen, st.GetData(), st.GetSize());

}
Пример #5
0
void CUIDesignerView::OnRemoveUI()
{
	CArray<CControlUI*,CControlUI*> arrSelected;

	m_MultiTracker.GetSelected(arrSelected);
	//remove form
	for (int i=0; i<arrSelected.GetSize(); i++)
	{
		CControlUI* pControl = arrSelected[i];
		if(pControl == m_LayoutManager.GetForm())
		{
			arrSelected.RemoveAt(i);
			break;;
		}
	}

	m_UICommandHistory.Begin(arrSelected, actionDelete);
	for(int i=0; i<arrSelected.GetSize(); i++)
	{
		CControlUI* pControl = arrSelected[i];
		CControlUI* pParent=pControl->GetParent();
		HTREEITEM hDelete=(HTREEITEM)(((ExtendedAttributes*)pControl->GetTag())->hItem);
		g_pClassView->RemoveUITreeItem(hDelete);
		RemoveUI(pControl);
		if(pParent)
			pParent->NeedUpdate();
	}
	m_UICommandHistory.End();

	g_pPropertiesWnd->HideAllProperties(TRUE,TRUE);
	m_MultiTracker.RemoveAll();
}
Пример #6
0
int get_port_num()
{
	USES_CONVERSION;
	int com_num = 0;
	int m_nSerialPortNum(0);// 串口计数 
	CString          strSerialList[256];  // 临时定义 256 个字符串组 
	CArray<SSerInfo, SSerInfo&> asi;
	EnumSerialPorts(asi,TRUE);// TRUE 时枚举当前可以打开的串口, FALSE 枚举所有串口	

	m_nSerialPortNum = asi.GetSize();
	for (int i = 0; i<asi.GetSize(); i++)
	{
		CString str = asi[i].strFriendlyName;
		string com_port_str = W2A(str);
		if (!strncmp(com_port_str.c_str(), "USB Serial", 10))
		{
			CString str1 = str;
			int npos_head = str1.Find(L"COM");  //not find return -1 else return 0
			if (npos_head > -1)
			{
				npos_head = npos_head + 3;
			}
			int npos_end = str1.Find(')');
			if (npos_end > -1)
			{
			}
			CString str2 = str1.Mid(npos_head, npos_end - npos_head);
			com_num = atoi(W2A(str2));
			break;
		}	
	}
	return com_num;	
}
Пример #7
0
void CPageStream::GetPages(CArray<CPage *, CPage *> &pages, int fromMsec, int toMsec, int offset, int &firstPos, int &lastPos)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());

   if (m_pageArray.GetSize() <= 0)
      return;

   bool isFirst = true;
   for (int i = 0; i < m_pageArray.GetSize(); ++i)
   {
      CPage *page = m_pageArray[i];
      if (page &&
         ((page->GetEnd() + offset > fromMsec && page->GetEnd() + offset <= toMsec) ||
         (page->GetBegin() + offset >= fromMsec && page->GetBegin() + offset < toMsec) ||
         (page->GetBegin() + offset < fromMsec && page->GetEnd() + offset > toMsec)))
      {
         CPage *newPage = page->Copy(true);
         if (newPage)
         {
            newPage->SetBegin(newPage->GetBegin() + offset);
            newPage->SetEnd(newPage->GetEnd() + offset);
           
            pages.Add(newPage);
            if (isFirst)
               firstPos = pages.GetSize() - 1;
            isFirst = false;
         }
      }
   }

   // at least one page is inserted
   if (!isFirst)
      lastPos = pages.GetSize() - 1;
}
Пример #8
0
void CSortingListControl::LoadPersistentAttributes()
{
	CArray<int, int> arr;
	arr.SetSize(GetHeaderCtrl()->GetItemCount());

	GetColumnOrderArray(arr.GetData(), arr.GetSize());	
	CPersistence::GetColumnOrder(m_name, arr);
	SetColumnOrderArray(arr.GetSize(), arr.GetData());

	for (int i=0; i < arr.GetSize(); i++)
		arr[i]= GetColumnWidth(i);
	CPersistence::GetColumnWidths(m_name, arr);
	for (i=0; i < arr.GetSize(); i++)
	{
		// To avoid "insane" settings we set the column width to
		// maximal twice the default width.
		int maxWidth= GetColumnWidth(i) * 2;
		int w= min(arr[i], maxWidth);
		SetColumnWidth(i, w);
	}

	// Not so good: CPersistence::GetSorting(m_name, GetHeaderCtrl()->GetItemCount(), m_sorting.column1, m_sorting.ascending1, m_sorting.column2, m_sorting.ascending2);
	// We refrain from saving the sorting because it is too likely, that
	// users start up with insane settings and don't get it.
}
Пример #9
0
void CDirstatDoc::OnViewShowfreespace()
{
	CArray<CItem *, CItem *> drives;
	GetDriveItems(drives);

	if (m_showFreeSpace)
	{
		for (int i=0; i < drives.GetSize(); i++)
		{
			CItem *free= drives[i]->FindFreeSpaceItem();
			ASSERT(free != NULL);
		
			if (GetSelection() == free)
				SetSelection(free->GetParent());

			if (GetZoomItem() == free)
				m_zoomItem= free->GetParent();

			drives[i]->RemoveFreeSpaceItem();
		}
		m_showFreeSpace= false;
	}
	else
	{
		for (int i=0; i < drives.GetSize(); i++)
			drives[i]->CreateFreeSpaceItem();
		m_showFreeSpace= true;
	}

	if (drives.GetSize() > 0)
        SetWorkingItem(GetRootItem());

	UpdateAllViews(NULL);
}
Пример #10
0
CString ConvertReceivedDataToString(CByteArray & data)
   {
     // data is UTF-8 encoded
    CArray<WCHAR, WCHAR> wc;
     // First, compute the amount of space required.  n will include the
     // space for the terminal NUL character
    INT_PTR n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), NULL, 0);
    if(n == 0)
       { /* failed */
        DWORD err = ::GetLastError();
        TRACE(_T("%s: MultiByteToWideChar (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
        return CString(_T(""));
       } /* failed */
    else
       { /* success */
        wc.SetSize(n);
        n = ::MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)data.GetData(), (int)data.GetSize(), (LPWSTR)wc.GetData(), (int)n);
        if(n == 0)
           { /* failed */
            DWORD err = ::GetLastError();
            TRACE(_T("%s: MultiByteToWideChar (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
            return CString(_T(""));
           } /* failed */
       } /* success */     

     // Data is now in Unicode
     // If we are a Unicode app we are done
     // If we are an ANSI app, convert it back to ANSI

#ifdef _UNICODE
     // If this is a Unicode app we are done
    return CString(wc.GetData(), (int)wc.GetSize());
#else // ANSI
    // Invert back to ANSI
    CString s;
    n = ::WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wc.GetData(), (int)wc.GetSize(), NULL, 0, NULL, NULL);
    if(n == 0)
       { /* failed */
        DWORD err = ::GetLastError();
        TRACE(_T("%s: WideCharToMultiByte (1) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
        return CString("");
       } /* failed */
    else
       { /* success */
        LPSTR p = s.GetBuffer((int)n);
        n = ::WideCharToMultiByte(CP_ACP, 0, wc.GetData(), (int)wc.GetSize(), p, (int)n, NULL, NULL);
        if(n == 0)
           { /* conversion failed */
            DWORD err = ::GetLastError();
            TRACE(_T("%s: WideCharToMultiByte (2) returned error %d\n"), AfxGetApp()->m_pszAppName, err);
            s.ReleaseBuffer();
            return CString("");
           } /* conversion failed */
        s.ReleaseBuffer();
        return s;
       } /* success */
#endif
   } // ConvertReceivedDataToString
Пример #11
0
void CStaticDlg::OnReadScoreFile(CString pszFileName, int mode){

	CStdioFile file; 
	CFileException e;
	CFileStatus status;
	
	if(mode != -1)
		pszFileName.Format(pszFileName+("_%d"), mode);

	if(CFile::GetStatus(pszFileName, status)){//파일이 존재하는 경우 읽어오기만함
		if(!(file.Open(pszFileName, CFile::modeRead | CFile::shareDenyNone, &e))) { 
			TRACE( _T("Can't open file %s, error = %u\n"), pszFileName, e.m_cause );
			return;
		} 
	}else{//파일이 존재하지 않는다면 생성한다
		if(!(file.Open(pszFileName, CFile::modeCreate | CFile::modeRead | CFile::shareDenyNone, &e))) { 
			TRACE( _T("Can't open file %s, error = %u\n"), pszFileName, e.m_cause );
			return;
		} 
	}

	CString _buf;
	CArray<Record, Record> array;
	Record record;
	while (file.ReadString(_buf)){
		CString name, time, strHour, strMinute, strSecond, strTimeset;
		name = _T("5");
		int hour = _ttoi(name);
		AfxExtractSubString(name, _buf, 0, ',');
		AfxExtractSubString(time, _buf, 1, ',');
		AfxExtractSubString(strHour, time, 0, ':');
		AfxExtractSubString(strMinute, time, 1, ':');
		AfxExtractSubString(strSecond, time, 2, ':');
		AfxExtractSubString(strTimeset, time, 3, ':');
		
		record = Record(name, _ttoi(strHour), _ttoi(strMinute), _ttoi(strSecond), _ttoi(strTimeset));
		array.Add(record);
	}

	QSortCArray( array, CompareRecord );
	int printSize = array.GetSize() < 5 ? array.GetSize() : 5;
	for(int i=0; i< printSize; i++ )
    {
		CString strTemp;
		strTemp.Format(_T("%d. %s (%d:%d:%d:%d) \n"), i+1,  array[i].name,array[i].hour, array[i].minute, array[i].second, array[i].timeset );
		if(mode == -1){
			m_strRankList += strTemp;
		}else{
			m_strPractice += strTemp;
		}
    }

	UpdateData(FALSE);
	
	file.Close();
}
Пример #12
0
// 将OpenCV图像显示到控件上
void	CJudgeDlg::DrawPicture2HDC()
{
	m_matImage = LoadFOVImage2Color(m_pDocument->GetDirectory(), m_nFOVIndex);
	if ( !m_matImage.empty() )
	{
		CArray<CvRect, CvRect>* pRect;
		CvRect cvRect;
		CvPoint pt1, pt2;
		int i;
		//pRect = m_pDocument->GetTargetInfoInFOV(m_nWorkPosition, m_nFOVIndex);
		//for ( i = 0; i < pRect->GetSize(); i++ )
		//{				
		//	cvRect = pRect->GetAt(i);
		//	pt1.x = cvRect.x;
		//	pt1.y = cvRect.y;
		//	pt2.x = cvRect.x + cvRect.width;
		//	pt2.y = cvRect.y + cvRect.height;
		//	cvRectangle(m_pcvImage, pt1, pt2, CV_RGB(255,0,0), 2, 8,0);
		//}
				
		pRect = m_pDocument->GetSimpleTargetInfoInFOV(m_nFOVIndex);
		for ( i = 0; i < pRect->GetSize(); i++ )
		{				
			cvRect = pRect->GetAt(i);
			pt1.x = cvRect.x;
			pt1.y = cvRect.y;
			pt2.x = cvRect.x + cvRect.width;
			pt2.y = cvRect.y + cvRect.height;
			cv::rectangle(m_matImage, pt1, pt2, CV_RGB(255,0,0), 2, 8,0);
		}
		pRect = m_pDocument->GetOverlapTargetInfoInFOV( m_nFOVIndex);
		for ( i = 0; i < pRect->GetSize(); i++ )
		{				
			cvRect = pRect->GetAt(i);
			pt1.x = cvRect.x;
			pt1.y = cvRect.y;
			pt2.x = cvRect.x + cvRect.width;
			pt2.y = cvRect.y + cvRect.height;
			cv::rectangle(m_matImage, pt1, pt2, CV_RGB(0,255,0), 2, 8,0);
		}

		UINT ID = IDC_FOV_IMAGE;
		
		CDC *pDC = this->GetDlgItem(ID)->GetDC();
		HDC hDC = pDC->GetSafeHdc();

		CRect	rect;
		this->GetDlgItem(ID)->GetClientRect(&rect);
		
		CMyBitmap bmp;
		bmp.CopyFromMat(m_matImage);
		bmp.Draw(hDC,rect,1,0,0);

		ReleaseDC(pDC);	
	}	
}
Пример #13
0
void CStockManager::MakeShortName(StockUserInfo *pStock)
{
	// 低位是汉字长度,高位是拼音长度
	short nPyjc = 0;

	CString StockName = pStock->GetName(TRUE);
	StockInfoEx *pStockEx = GetStockInfoEx(&pStock->m_ciStockCode);
	memcpy(&pStock->m_cShortPyjc[12], &pStockEx, sizeof(StockInfoEx *));

	int i = 0;
	int bufsz = 0;
	CArray<CStringArray*,CStringArray*> ay;
	CStringArray* pItem;
	char *s = StockName.GetBuffer(StockName.GetLength());

	while(i < StockName.GetLength())
	{
		pItem = GetPyjcByHZ(s,i);
		ay.Add(pItem);
		bufsz += pItem->GetSize();
		if(pItem->GetSize() > 1)
			bufsz++;
	}

	StockName.ReleaseBuffer();

	if(ay.GetSize())
	{
		int j = 0;
		pStockEx->pPyjcArray = new CString;
		LPSTR pBuffer = pStockEx->pPyjcArray->GetBufferSetLength(bufsz + 1);
		for(i = 0; i < ay.GetSize(); i++)
		{
			pItem = ay.GetAt(i);
			if(pItem->GetSize() > 1)
			{
				pBuffer[j++] = (char)pItem->GetSize();

				for(int k = 0; k < pItem->GetSize(); k++)
					pBuffer[j++] = pItem->GetAt(k).GetAt(0);
			}
			else if(pItem->GetSize())
			{
				char c = pItem->GetAt(0).GetAt(0);
				pBuffer[j++] = pItem->GetAt(0).GetAt(0);
			}
		}

		pStockEx->pPyjcArray->ReleaseBuffer(j);
	}

	_delArrayObj(ay);
}
Пример #14
0
u32 CHookFunction_i::GetExportFunctionInfo(CArray<EXPORT_FUN_INFO, EXPORT_FUN_INFO&>& InfoArray, 
                                           const char* pszDllFile)
{
    if(!pszDllFile)
    {
        return 0;
    }
	  
    PLOADED_IMAGE pImage = ::ImageLoad((char*)pszDllFile, NULL);
    if(!pImage)
    {
        return 0;
    }
	
    DWORD dwBase = (DWORD)pImage->MappedAddress;
    PIMAGE_SECTION_HEADER pSections    = (PIMAGE_SECTION_HEADER)((DWORD)pImage->FileHeader + sizeof(IMAGE_NT_HEADERS));
    PIMAGE_EXPORT_DIRECTORY pExportDir = (PIMAGE_EXPORT_DIRECTORY)(RVA2RawAdr(pSections, pImage->FileHeader->OptionalHeader.DataDirectory[0].VirtualAddress) + dwBase);
	
    InfoArray.RemoveAll();
	  
    EXPORT_FUN_INFO info;
	
    DWORD* pFunOffsetAdr = (DWORD*)(RVA2RawAdr(pSections, pExportDir->AddressOfFunctions) + dwBase);
    for(DWORD i = 0; i < pExportDir->NumberOfFunctions; i++)
    {
        info.dwOffset = 0;
        info.strFunName = "";
        info.dwOrdinal = 0;
        
        info.dwOffset = *(pFunOffsetAdr + i);
        info.dwOrdinal =  i + 1;
        InfoArray.Add(info);
    }
	
    DWORD* pFunNamesAdr       = (DWORD*)(RVA2RawAdr(pSections, pExportDir->AddressOfNames) + dwBase);
    WORD* pFunNamesOrdinalAdr = (WORD*)(RVA2RawAdr(pSections, pExportDir->AddressOfNameOrdinals) + dwBase);
	  
    char* pName = NULL;
    for(i = 0; i < pExportDir->NumberOfNames; i++)
    {
        pName = (char*)(RVA2RawAdr(pSections, *(pFunNamesAdr+i)) + dwBase);
        int idx = *(pFunNamesOrdinalAdr+i);
        if(idx < InfoArray.GetSize())
        {
          EXPORT_FUN_INFO& tmpInfo = InfoArray.ElementAt(idx);
          tmpInfo.strFunName = pName;
        }
    }
	  
    ImageUnload(pImage);
    
    return InfoArray.GetSize();
}
Пример #15
0
void CAbstractVstEditor::UpdateInputMenu()
{
     CMenu* pInfoMenu = m_pMenu->GetSubMenu(2);
    pInfoMenu->DeleteMenu(0, MF_BYPOSITION);

    CModDoc* pModDoc = m_pVstPlugin->GetModDoc();
    module_renderer* pSndFile = pModDoc->GetSoundFile();

    if (m_pInputMenu->m_hMenu)        {
            m_pInputMenu->DestroyMenu();
    }
    if (!m_pInputMenu->m_hMenu) {
            m_pInputMenu->CreatePopupMenu();
    }

    CString name;

    CArray<CVstPlugin*, CVstPlugin*> inputPlugs;
    m_pVstPlugin->GetInputPlugList(inputPlugs);
    for (int nPlug=0; nPlug<inputPlugs.GetSize(); nPlug++) {
            name.Format("FX%02d: %s", inputPlugs[nPlug]->m_nSlot+1, inputPlugs[nPlug]->m_pMixStruct->Info.szName);
            m_pInputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT+inputPlugs[nPlug]->m_nSlot, name);
    }

    CArray<UINT, UINT> inputChannels;
    m_pVstPlugin->GetInputChannelList(inputChannels);
    for (int nChn=0; nChn<inputChannels.GetSize(); nChn++) {
            if (nChn==0 && inputPlugs.GetSize()) {
                    m_pInputMenu->AppendMenu(MF_SEPARATOR);
            }
            name.Format("Chn%02d: %s", inputChannels[nChn]+1, pSndFile->ChnSettings[inputChannels[nChn]].szName);
            m_pInputMenu->AppendMenu(MF_STRING, NULL, name);
    }

    CArray<UINT, UINT> inputInstruments;
    m_pVstPlugin->GetInputInstrumentList(inputInstruments);
    bool checked;
    for (int nIns=0; nIns<inputInstruments.GetSize(); nIns++) {
            checked=false;
            if (nIns==0 && (inputPlugs.GetSize() || inputChannels.GetSize())) {
                    m_pInputMenu->AppendMenu(MF_SEPARATOR);
            }
            name.Format("Ins%02d: %s", inputInstruments[nIns], (LPCTSTR)pSndFile->GetInstrumentName(inputInstruments[nIns]));
            if (inputInstruments[nIns] == (UINT)m_nInstrument)        checked=true;
            m_pInputMenu->AppendMenu(MF_STRING|(checked?MF_CHECKED:0), ID_SELECTINST+inputInstruments[nIns], name);
    }

    if ((inputPlugs.GetSize() == 0) &&
            (inputChannels.GetSize() == 0) &&
            (inputInstruments.GetSize() == 0)) {
            m_pInputMenu->AppendMenu(MF_STRING|MF_GRAYED, NULL, "None");
    }

    pInfoMenu->InsertMenu(0, MF_BYPOSITION|MF_POPUP, (UINT)m_pInputMenu->m_hMenu, "I&nputs");
}
Пример #16
0
void CSortingListControl::SavePersistentAttributes()
{
	CArray<int, int> arr;
	arr.SetSize(GetHeaderCtrl()->GetItemCount());

	GetColumnOrderArray(arr.GetData(), arr.GetSize());	
	CPersistence::SetColumnOrder(m_name, arr);

	for (int i=0; i < arr.GetSize(); i++)
		arr[i]= GetColumnWidth(i);
	CPersistence::SetColumnWidths(m_name, arr);

	// Not so good: CPersistence::SetSorting(m_name, m_sorting.column1, m_sorting.ascending1, m_sorting.column2, m_sorting.ascending2);
}
Пример #17
0
void MPCStatusBar::RemovePane(int nPaneID)
{
 SetRedraw(FALSE);
 CWnd * pwnd = NULL;
  int i;
 for( i = 0; i < m_aPans.GetSize(); i++ )
 {
  if( m_aPans[i]->m_nPaneID == nPaneID )
  {
   if( m_aPans[i]->m_bAutodelete )
    pwnd = m_aPans[i]->m_hWnd;
   delete m_aPans[i];
   m_aPans.RemoveAt(i);
   break;
  }
 }
 if( pwnd )
 {
  pwnd->DestroyWindow();
  delete pwnd;
 }

 CArray<MPCStatusBarPane,MPCStatusBarPane> arPanes;
 MPCStatusBarPane statusPane;
 i = 0;
 while( GetStatusPane(i,statusPane) )
 {
  if( statusPane.nID != (UINT)nPaneID )
   arPanes.Add( statusPane );
  i++;
 }
 // Now remove the indicator
 UINT * pIndicators = new UINT[arPanes.GetSize()];
 for(i=0;i<arPanes.GetSize();i++)
  pIndicators[i]=arPanes[i].nID;
 SetIndicators(pIndicators,arPanes.GetSize());

 // Replace infos of indicators ..
 for(i = 0; i < arPanes.GetSize(); i++ )
 {
  SetPaneInfo(i,arPanes[i].nID,arPanes[i].nStyle,arPanes[i].cxText);
  SetPaneText(i,arPanes[i].strText);
 }
 delete pIndicators;
 SetRedraw(TRUE);
 PositionControls();
 Invalidate(TRUE);

}
BOOL CDialogInvProcess::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CArray<int,int>	arIds;
	CStringArray	arTickers;

	// Raw Materials
	CSQLInvProcess::Get(1, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listRaw.AddString(arTickers[i]);
		m_listRaw.SetItemData(nInd, arIds[i]);
	}

	// WIP
	arIds.RemoveAll();
	arTickers.RemoveAll();
	CSQLInvProcess::Get(2, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listWIP.AddString(arTickers[i]);
		m_listWIP.SetItemData(nInd, arIds[i]);
	}

	// QC
	arIds.RemoveAll();
	arTickers.RemoveAll();
	CSQLInvProcess::Get(3, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listQC.AddString(arTickers[i]);
		m_listQC.SetItemData(nInd, arIds[i]);
	}

	// Portfolio
	arIds.RemoveAll();
	arTickers.RemoveAll();
	CSQLInvProcess::Get(4, arIds, arTickers);
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nInd = m_listPort.AddString(arTickers[i]);
		m_listPort.SetItemData(nInd, arIds[i]);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #19
0
void CRegistry::DeleteKey(HKEY hParent, LPCTSTR pszKey)
{
	HKEY hKey;
	if ( RegOpenKeyEx( hParent, pszKey, 0, KEY_ALL_ACCESS, &hKey ) ) return;

	CArray< CString > pList;

	for ( DWORD nIndex = 0 ; ; nIndex++ )
	{
		DWORD dwName = 64;	// Input parameter in TCHARs
		TCHAR szName[64];

		LRESULT lResult = RegEnumKeyEx( hKey, nIndex, szName, &dwName, NULL, NULL, 0, NULL );
		if ( lResult != ERROR_SUCCESS ) break;

		szName[ dwName ] = 0;
		pList.Add( szName );
		DeleteKey( hKey, szName );
	}

	for ( int nItem = pList.GetSize() - 1 ; nItem >= 0 ; nItem-- )
	{
		RegDeleteKey( hKey, pList.GetAt( nItem ) );
	}

	if ( lstrlen( pszKey ) > 25 )	// Handle likely initial non-recursive value
		RegDeleteKey( HKEY_CURRENT_USER, pszKey );

	RegCloseKey( hKey );
}
Пример #20
0
HRESULT ProfileUtils::SetRecentProfiles(CArray<RegistryProfileInfo *, RegistryProfileInfo *> &arRecentProfiles) {
    HRESULT hr = S_OK; 
    
    int iCustomCount = 0;
    
    LRegistry::DeleteRegistryKey(HKEY_CURRENT_USER, _T("Software\\imc AG\\LECTURNITY\\Publisher\\Profiles\\Recent\\List"));

    for (int i = 0; i < arRecentProfiles.GetSize(); ++i) {
        if (arRecentProfiles[i] != NULL) {
            CString csRegistryEntry;
            arRecentProfiles[i]->CreateRegistryEntry(csRegistryEntry);
            CString csName = arRecentProfiles[i]->GetName();
            if (arRecentProfiles[i]->GetProfileType() == PublishingFormat::TYPE_CUSTOM) {
                CString csCount;
                csCount.Format(_T(" %d"), iCustomCount);
                csName += csCount;
                ++iCustomCount;
            }
            bool bSuccess = LRegistry::WriteStringRegistryEntry(HKEY_CURRENT_USER, 
                                _T("Software\\imc AG\\LECTURNITY\\Publisher\\Profiles\\Recent\\List"), 
                                csName, csRegistryEntry);
        }
    }

    return hr;
}
Пример #21
0
void CInteractionAreaDialog::SetActionText(CMouseAction *pMouseAction, int nEditId)
{	
	CString csText;
	csText.Empty();

	UINT nPageOrMarkId = pMouseAction->GetPageMarkId();
	AreaActionTypeId nActionTypeId = pMouseAction->GetActionId();

	if (nActionTypeId == INTERACTION_JUMP_SPECIFIC_PAGE)
	{
      csText = m_pEditorDoc->project.GetPageTitleForId(nPageOrMarkId);
   }
	else if (nActionTypeId == INTERACTION_JUMP_TARGET_MARK)
	{
		CArray<CStopJumpMark *, CStopJumpMark *> caJumpMarks;
		CMarkStream *pMarkStream = m_pEditorDoc->project.GetMarkStream();
		pMarkStream->GetJumpMarksInRegion(caJumpMarks, 0, m_pEditorDoc->m_displayEndMs);
		for (int i = 0; i < caJumpMarks.GetSize(); ++i)
		{
			if (caJumpMarks[i]->GetId() == nPageOrMarkId)
			{
				csText = caJumpMarks[i]->GetLabel();
				break;
			}
		}
      caJumpMarks.RemoveAll();
	}
	else if (nActionTypeId == INTERACTION_OPEN_URL || nActionTypeId == INTERACTION_OPEN_FILE)
	{
		csText = pMouseAction->GetPath();
	}

	CEdit *pEdit = (CEdit *)GetDlgItem(nEditId);
	pEdit->SetWindowText(csText);
}
Пример #22
0
void CInteractionAreaDialog::CreateSlidePopup(int nAction, int nButtonId, int nEditId)
{
	CRect rcButton;
	CWnd *pWndButton = GetDlgItem(nButtonId);

	pWndButton->GetClientRect(rcButton);
	pWndButton->ClientToScreen(&rcButton);

	m_wndMenu.CreatePopupMenu();

	CArray<CPage *, CPage *> caPages;
	m_pEditorDoc->project.GetPages(caPages, 0, m_pEditorDoc->m_docLengthMs);
	for (int i = 0; i < caPages.GetSize(); ++i)
	{
		CString csPageTitle;
		csPageTitle = caPages[i]->GetTitle();
		m_wndMenu.AppendMenu(MF_STRING, i+1, csPageTitle);
	}
   
	BOOL bRet = m_wndMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RETURNCMD, rcButton.left, rcButton.bottom, this);

	CWnd *pEdit = GetDlgItem(nEditId);
	// if bRet is zero the menu was cancelled 
	// or an error occured
	if (bRet != 0)
	{
		CString csItem;
		m_wndMenu.GetMenuString(bRet, csItem, MF_BYCOMMAND);
		pEdit->SetWindowText(csItem);
		m_nMarkOrPageId[nAction] = caPages[bRet-1]->GetJumpId();
	}

	caPages.RemoveAll();
	m_wndMenu.DestroyMenu();
}
//***********************************************************************************************	
void CBCGPRibbonGalleryCtrl::RecalcLayout()
{
	if (GetSafeHwnd() == NULL)
	{
		return;
	}

	ASSERT_VALID(m_pPanel);

	m_pPanel->m_arElements.RemoveAll ();
	m_PaletteButton.RemoveAll();

	m_PaletteButton.CreateIcons();

	CArray<CBCGPBaseRibbonElement*, CBCGPBaseRibbonElement*> arButtons;
	m_PaletteButton.GetMenuItems (arButtons);

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

		m_pPanel->Add (pButton);
	}

	AdjustLocations();
}
Пример #24
0
// Takes a connected computer to ignore, and a GUID (do)
// Randomly chooses a neighbour from amongst those that are connected, running Gnutella2, hubs, and don't know about the GUID
// Returns a pointer to that randomly selected neighbour
CG2Neighbour* CNeighboursWithG2::GetRandomHub(CG2Neighbour* pExcept, const Hashes::Guid& oGUID)
{
	// Make a new local empty list that will hold pointers to neighbours
	CArray< CG2Neighbour* > pRandom;

	// Loop through each computer we're connected to
	for ( POSITION pos = GetIterator() ; pos ; )
	{
		// Get the neighbour under the current position, and move to the next one in the list
		CNeighbour* pNeighbour = GetNext( pos );

		// If this is a Gnutella2 hub
		if ( pNeighbour->m_nState == nrsConnected   &&	// We've finished the handshake with this computer, and
			 pNeighbour->m_nProtocol == PROTOCOL_G2 &&	// It's running Gnutella2 software, and
			 pNeighbour->m_nNodeType != ntLeaf      &&	// Our connection to it isn't down to a leaf, and
			 pNeighbour != pExcept )					// It's not the one the caller told us to avoid
		{
			// And it doesn't know the given GUID, add it to the random list
			if ( static_cast< CG2Neighbour* >( pNeighbour )->m_pGUIDCache->Lookup( oGUID ) == NULL )
				pRandom.Add( static_cast< CG2Neighbour* >( pNeighbour ) );
		}
	}

	// If we didn't find any neighbours to put in the list, return null
	INT_PTR nSize = pRandom.GetSize();
	if ( ! nSize ) return NULL;

	// Choose a random number between 0 and nSize - 1, use it as an index, and return the neighbour at it
	nSize = GetRandomNum< INT_PTR >( 0, nSize - 1 );
	return pRandom.GetAt( nSize );
}
Пример #25
0
int	CStockManager::GetStocksExrighData(CArray<CodeInfo>* pArInfo, CArray<CurrentExRightData>& ayExrightData)
{
	CDSWriteFile* pWrite = NULL;
	if (m_pDataSource != NULL)
	{
		pWrite = m_pDataSource->GetDSWriterFile();
	}
	if (pWrite == NULL || pArInfo == NULL || pArInfo->GetSize() <= 0)
	{
		return 0;
	}
	CString strCodeCompare = _T("");
	for (int i = 0; i < pArInfo->GetSize(); i ++)
	{
		CodeInfo codeInfo = pArInfo->GetAt(i);
		if(codeInfo.m_cCode[0] != '\0')
		{
			CString strCode = CString(codeInfo.m_cCode, sizeof(codeInfo.m_cCode));
			strCodeCompare += strCode;
			strCodeCompare += _T(";");
		}
	}
	pWrite->ReadStocksExrightData(strCodeCompare, ayExrightData, pArInfo->GetSize());
	return ayExrightData.GetSize();
}
Пример #26
0
void CSiteDir::BuildFromDatabase()
{
	WCHAR sql[256];
	swprintf(sql, L"SELECT id,filename,type,file_size,file_date FROM files WHERE parent_id = %d", m_dbid);
	_variant_t va;
	ADODB::_RecordsetPtr recordset = m_pWebSite->m_siteDataConnection->Execute(sql, &va, ADODB::adCmdText);

	CArray<CSiteDir*,CSiteDir*> dirs;

	while (recordset->EndOfFile == false)
	{
		CSiteItem* pItem;

		BYTE type = recordset->Fields->Item[_bstr_t("type")]->Value.lVal;
		if (type == 1)	// Directory
		{
			CSiteDir* pDir = new CSiteDir;
			pItem = pDir;

			strcpy(pDir->m_wfd.cFileName, _bstr_t(recordset->Fields->Item[_bstr_t("filename")]->Value));

			_makepath(pDir->m_pathName.GetBuffer(512), NULL, m_pathName, pDir->m_wfd.cFileName, NULL);
			pDir->m_pathName.ReleaseBuffer();

			dirs.Add(pDir);
		}
		else if (type == 2)	// File
		{
			CSiteFile* pFile = new CSiteFile;
			pItem = pFile;

			strcpy(pFile->m_wfd.cFileName, _bstr_t(recordset->Fields->Item[_bstr_t("filename")]->Value));
			pFile->m_wfd.nFileSizeLow = recordset->Fields->Item[_bstr_t("file_size")]->Value.lVal;
		}
		else
			ATLASSERT(0);

		if (pItem)
		{
			pItem->m_pWebSite = m_pWebSite;
			pItem->m_dbid = recordset->Fields->Item[_bstr_t("id")]->Value.lVal;
		//	pItem->m_name = pItem->m_wfd.cFileName;	// ??

			// lastWriteDate
			double lastWriteTime = recordset->Fields->Item[_bstr_t("file_date")]->Value;
			SYSTEMTIME systime;
			VariantTimeToSystemTime(lastWriteTime, &systime);
			SystemTimeToFileTime(&systime, &pItem->m_wfd.ftLastWriteTime);

			AddChildTail(pItem);
		}

		recordset->MoveNext();
	}

	for (int i = 0; i < dirs.GetSize(); i++)
	{
		dirs[i]->BuildFromDatabase();	// Recurse
	}
}
BOOL GetSerialComPortNumber_my(vector<CString>& szComm)
{
	CArray<SSerInfo,SSerInfo&> asi;

	// Populate the list of serial ports.
	EnumSerialPorts(asi,FALSE/*include all*/);
	szComm.clear();
	for (int ii=0; ii<asi.GetSize(); ii++) 
	{
		//m_listPorts.AddString(asi[ii].strFriendlyName);
		CString strCom = asi[ii].strFriendlyName;
		int nPos;
		if ((nPos = strCom.Find(_T("COM")))!=-1)
		{
			int startdex = strCom.ReverseFind(_T('('));
			int enddex = strCom.ReverseFind(_T(')'));
			//if (startdex > 0 && enddex == (strCom.GetLength()-1))
			strCom = strCom.Mid(startdex+1, enddex-startdex-1);
		}
		szComm.push_back(strCom);

	}

	return (szComm.size() !=0);
}
void CViewMeetings::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	ResizeParentToFit();	

	// Fill up the companies combo
	int nIndex = m_comboCompany.AddString("- New Idea -");
	m_comboCompany.SetItemData(nIndex, 0);

	CArray<int,int> arIds;
	CStringArray arTickers;
	CSQLCompany::GetCompanyIDAndTickers(arIds, arTickers, theApp.m_Universe.GetDate());
	for(int i=0; i<arIds.GetSize(); i++)
	{
		int nID = arIds[i];
		CString sTicker = arTickers[i];

		nIndex = m_comboCompany.AddString(sTicker);
		m_comboCompany.SetItemData(nIndex, nID);
	}

	Load();

	if(m_ListMeetings.GetCount() > 0)
	{
		m_ListMeetings.SetCurSel(0);
		SetData();
	}
}
Пример #29
0
void CTobCompiler::Reset()
{
	m_line = 0;
	m_err.Empty();
	m_bin.RemoveAll();
	if(m_fsrc) { fclose(m_fsrc); m_fsrc = 0; }
	if(m_fdst) { fclose(m_fdst); m_fdst = 0; }

	POSITION p = m_defbin.GetStartPosition();
	CString str;
	CByteArray* bin;
	while(p)
	{
		m_defbin.GetNextAssoc(p, str, bin);
		delete bin;
	}
	m_defbin.RemoveAll();
	m_defbin.InitHashTable(251);

	m_label.RemoveAll();
	m_label.InitHashTable(251);
	for(int i = m_exp.GetSize() - 1; i >= 0; --i)
		delete m_exp.GetAt(i);
	m_exp.RemoveAll();
	m_change.RemoveAll();
	m_change.InitHashTable(251);
	m_bit_i = 32;
	m_bit_f = 32;
	m_maxc = -1;
	m_maxw = -1;
	m_maxs = -1;
}
Пример #30
0
void CMagneticPic::Paint(CDC* pDC, const CRect& Area, const CArray<CMagneticPic*,CMagneticPic*>& Animation) const
{
  if (m_pPalette)
  {
    pDC->SelectPalette(m_pPalette,FALSE);
    pDC->RealizePalette();
  }

  CDC BitmapDC;
  BitmapDC.CreateCompatibleDC(pDC);

  CBitmap Bitmap;
  Bitmap.CreateCompatibleBitmap(pDC,m_Size.cx,m_Size.cy);
  CBitmap* pOldBitmap = BitmapDC.SelectObject(&Bitmap);

  BitmapDC.FillSolidRect(0,0,m_Size.cx,m_Size.cy,RGB(0x00,0x00,0x00));

  // Draw the main picture into the buffer
  Paint(&BitmapDC);

  // Draw the animation frames
  for (int i = 0; i < Animation.GetSize(); i++)
    Animation[i]->Paint(&BitmapDC);

  // Draw the buffer into the device context
  pDC->StretchBlt(Area.left,Area.top,Area.Width(),Area.Height(),
    &BitmapDC,0,0,m_Size.cx,m_Size.cy,SRCCOPY);
  BitmapDC.SelectObject(pOldBitmap);
}