bool CAcceleratorManager::Write()
{
	CDWordArray AccelsDatasArray;
	CDWordArray CmdDatasArray;

	int         iCount = 0;
	CCmdAccelOb*pCmdAccel;
	CAccelsOb*  pAccel;
	DWORD       dwAccelData;

	WORD     wKey;
	POSITION pos = m_mapAccelTable.GetStartPosition();
	while (pos != NULL)
	{
		m_mapAccelTable.GetNextAssoc(pos, wKey, pCmdAccel);
		CmdDatasArray.RemoveAll();

		POSITION pos = pCmdAccel->m_Accels.GetHeadPosition();
		while (pos != NULL)
		{
			pAccel = pCmdAccel->m_Accels.GetNext(pos);
			//      if (!pAccel->m_bLocked) {
			dwAccelData = pAccel->GetData();
			CmdDatasArray.Add(dwAccelData);
			//      }
		}

		if (CmdDatasArray.GetSize() > 0)
		{
			CmdDatasArray.InsertAt(0, MAKELONG(pCmdAccel->m_wIDCommand, CmdDatasArray.GetSize()));

			AccelsDatasArray.Append(CmdDatasArray);
			iCount++;
		}
	}
	//  AccelsDatasArray.InsertAt(0, MAKELONG(65535, iCount));

	int    count = AccelsDatasArray.GetSize();
	DWORD *data  = (DWORD *)malloc(count * sizeof(DWORD));
	ASSERT(data != NULL);

	for (int index = 0; index < count; index++)
		data[index] = AccelsDatasArray[index];

	regSetBinaryValue("keyboard", (char *)data, count*sizeof(DWORD));

	AccelsDatasArray.RemoveAll();
	CmdDatasArray.RemoveAll();

	free(data);

	return true;
}
Beispiel #2
0
BOOL CWindowGroups::ArrangeWindows(CWnd *pParentWindow)
{
	int i;
	RECT rect = { 0, 0, 0, 0 };

	const DWORD dwYStep = static_cast<DWORD>(NewGUI_Scale(WG_Y_STEP, pParentWindow));

	CDWordArray aPos;
	aPos.RemoveAll();

	const DWORD dwXOffset = static_cast<DWORD>(NewGUI_Scale(WG_OFFSET_LEFT, pParentWindow));
	const DWORD dwYOffset = static_cast<DWORD>(NewGUI_Scale(WG_OFFSET_TOP, pParentWindow));
	for(i = 0; i < m_aWindows.GetSize(); i++) aPos.Add(dwYOffset);

	for(i = 0; i < m_aWindows.GetSize(); i++)
	{
		if((m_aFlags.GetAt(i) & WGF_REPOSITION) == 0) continue;

		CWnd *p = (CWnd *)m_aWindows.GetAt(i);

		if(p != NULL)
		{
			p->GetWindowRect(&rect);
			rect.right = rect.right - rect.left; // Coords to sizes
			rect.bottom = rect.bottom - rect.top;
		}
		rect.top = (LONG)aPos.GetAt((int)m_aGroupIDs.GetAt(i));
		rect.left = dwXOffset;

		if(p != NULL)
			p->MoveWindow(rect.left, rect.top, rect.right, rect.bottom, TRUE);

		aPos.SetAt((int)m_aGroupIDs.GetAt(i), (DWORD)rect.top + dwYStep);
	}

	aPos.RemoveAll();
	return TRUE;
}
BOOL CRegistry::Read(LPCTSTR pszKey, LPPOINT& lpPoint)
{
	ASSERT(m_hKey);
	const int iMaxChars = 20;
	CDWordArray dwcArray;
	DWORD dwType;
	DWORD dwData = iMaxChars;
	BYTE* byData = (BYTE*)::calloc(iMaxChars, sizeof(TCHAR));
	ASSERT(byData);

	LONG lReturn = RegQueryValueEx(m_hKey, pszKey, NULL, &dwType,
		byData, &dwData);

	if(lReturn == ERROR_SUCCESS && dwType == REG_BINARY)
	{
		ASSERT(dwData < iMaxChars);
		CMemFile file(byData, dwData);
		CArchive ar(&file, CArchive::load);
		ar.m_bForceFlat = FALSE;
		ASSERT(ar.IsLoading());
		ASSERT(dwcArray.IsSerializable());
		dwcArray.RemoveAll();
		dwcArray.SetSize(5);
		dwcArray.Serialize(ar);
		ar.Close();
		file.Close();
		lpPoint->x = dwcArray.GetAt(0);
		lpPoint->y = dwcArray.GetAt(1);
	}

	m_Info.lMessage = lReturn;
	m_Info.dwType = REG_POINT;
	m_Info.dwSize = sizeof(POINT);

	if(byData)
	{
		free(byData);
		byData = NULL;
	}

	if(lReturn == ERROR_SUCCESS)
		return TRUE;

	return FALSE;
}
int CTDCTaskListCtrl::GetSelectedTaskIDs(CDWordArray& aTaskIDs, DWORD& dwFocusedTaskID) const
{
	aTaskIDs.RemoveAll();
	aTaskIDs.SetSize(m_lcTasks.GetSelectedCount());
	
	int nCount = 0;
	POSITION pos = m_lcTasks.GetFirstSelectedItemPosition();
	
	while (pos)
	{
		int nItem = m_lcTasks.GetNextSelectedItem(pos);
		
		aTaskIDs[nCount] = m_lcTasks.GetItemData(nItem);
		nCount++;
	}
	
	dwFocusedTaskID = GetFocusedListTaskID();
	ASSERT((!aTaskIDs.GetSize() && (dwFocusedTaskID == 0)) || (Misc::FindT(aTaskIDs, dwFocusedTaskID) >= 0));
	
	return aTaskIDs.GetSize();
}
Beispiel #5
0
void CHexEdit :: GetNumbers ( CDWordArray & cArray )
{
    // Get the array into shape.
    cArray.RemoveAll ( ) ;

    CString strRaw ;
    GetWindowText ( strRaw ) ;

    TCHAR * szBuff = (TCHAR*)new TCHAR[ strRaw.GetLength ( ) +
                                        1 * sizeof ( TCHAR )   ] ;

    _tcscpy ( szBuff , (LPCTSTR)strRaw ) ;

    // Use good ol' strtok to do the deed.
    TCHAR * pCurr = _tcstok ( szBuff , k_DELIMS ) ;
    while ( NULL != pCurr )
    {

        // Try and convert it to an value.  I'm taking the easy way out.
        DWORD dwAddr ;
        int iRet = _stscanf ( pCurr       ,
                              _T ( "%x" ) ,
                              &dwAddr       ) ;

        if ( 1 != iRet )
        {
            CString sMsg ;
            sMsg.FormatMessage ( IDS_LOADADDRBADCONVERSION ,
                                 pCurr                      ) ;
            AfxMessageBox ( sMsg ) ;
        }
        else
        {
            cArray.Add (  dwAddr ) ;
        }

        pCurr = _tcstok ( NULL , k_DELIMS ) ;
    }
    delete [] szBuff ;
}
BOOL CBCGPRegistry::Read (LPCTSTR pszKey, CDWordArray& dwcArray)
{
	dwcArray.RemoveAll ();
	dwcArray.SetSize (0);
	return Read (pszKey, (CObject&) dwcArray);
}
bool CHistogram::CalcHistogram()
{
	int i=0, j=0, k=0;
	int nIndex=0, nPtCnt=0, nGroupIndex=0;
	int nColIndex=0, nRowCount=0, nDataType=0;
	double fTmp=0;
	CDWordArray arrCol;
	CMapManager dataMap;
	CDoubleMatrix dataMatrix;
	CIntVector vIndex;
	CDoubleVector v;
	CTString szTemp("");
	CTString szFldNameX("");
	CTString szFldNameY("");

	if (m_tVarY.iCount > 0)
	{
		for (i=0; i<m_tVarY.iCount; i++)
		{
			nGroupIndex = m_tVarY.pValue[i];
			szFldNameY = m_pDataInterface->GetFieldName(nGroupIndex); 
			for (j=0; j<m_tVarX.iCount; j++)
			{
				nColIndex = m_tVarX.pValue[j];
				arrCol.Add(nGroupIndex);
				arrCol.Add(nColIndex);
				szFldNameX = m_pDataInterface->GetFieldName(nColIndex); 
				nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,dataMap);
				if (nRowCount < 1)
				{
					szTemp.Format("%s中的有效数据太少(分组变量=%s,数据变量=%s),无法绘图,请检查,Line=%d,File=%s",m_szChartName.GetData(),szFldNameY.GetData(),szFldNameX.GetData(),__LINE__,__FILE__);
					m_szErrMsg += szTemp;
					arrCol.RemoveAll();
					dataMap.Clear();
					dataMatrix.destroy();
					continue;
				}
				//有效数据
				v.create(nRowCount);
				CDoubleVector v1 = dataMatrix(0);
				CDoubleVector v2 = dataMatrix(1);
				v1.Sort(vIndex);
				fTmp = v1(0);
				nIndex = 0;
				for (k=0; k<nRowCount; k++)
				{
					if (fTmp == v1(k))
					{
						v(nIndex) = v2(vIndex(k)-1);
						nIndex ++;
						continue;
					}
					szTemp = GetLabel(dataMap,0,nGroupIndex,fTmp);
					szTemp = "\n" + szTemp;
					//直方图
					v.resize(nIndex);
					CalcHistogram(v,szFldNameX+szTemp);
					v.destroy();
					v.create(nRowCount);
					fTmp = v1(k);
					nIndex =0;
					v(nIndex) = v2(vIndex(k)-1);
				}
				//最后
				szTemp = GetLabel(dataMap,0,nGroupIndex,fTmp);
				szTemp = "\n" + szTemp;
				//直方图
				v.resize(nIndex);
				CalcHistogram(v,szFldNameX+szTemp);
				v.destroy();
				v.create(nRowCount);
				//释放内存
				vIndex.destroy();
				dataMap.Clear();
				arrCol.RemoveAll();
				dataMatrix.destroy();
			}
		}
	}
	else
	{
		for (i=0; i<m_tVarX.iCount; i++)
		{
			nColIndex = m_tVarX.pValue[i];
			arrCol.Add(nColIndex);
			szFldNameX = m_pDataInterface->GetFieldName(nColIndex); 
			nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,0);
			if (nRowCount < 1)
			{
				szTemp.Format("%s中的有效数据太少(%s),无法绘图,请检查,Line=%d,File=%s",m_szChartName.GetData(),szFldNameX.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				arrCol.RemoveAll();
				dataMatrix.destroy();
				continue;
			}
			//有效数据
			v = dataMatrix(0);
			//直方图
			CalcHistogram(v,szFldNameX);
			//释放内存
			arrCol.RemoveAll();
			dataMatrix.destroy();
		}
	}
	return true;
}
Beispiel #8
0
bool CBox::CalcBox2()
{
	int i=0, nCount=0;
	int nDataType = 0, nColIndex=0, nRowCount=0;
	CDWordArray arrCol;
	CDoubleMatrix dataMatrix;
	CTString szTemp("");
	CTString szFldName("");
	bool bHasBox=false;
	CTStringArray arrFldName;
	
	if (m_tVarX.iCount < 1)
	{
		m_szErrMsg.Format("盒状图中的数据不完整,至少需要一个变量,请检查!Line=%d,File=%s",__LINE__,__FILE__);
		return false;
	}
	m_szErrMsg.Empty();
	//数据处理
	TDataPointStrArr *pDPFB = NULL;
	CTChartBoxplot *pBox = new CTChartBoxplot;
	if (m_bSplit) //分开
	{
		for (i=0; i<m_tVarX.iCount; i++)
		{
			nColIndex = m_tVarX.pValue[i];
			nDataType = m_pDataInterface->GetFieldType(nColIndex);
			szFldName = m_pDataInterface->GetFieldName(nColIndex);
			if (nDataType != fInt && nDataType != fDouble && 
				nDataType != fBoolean && nDataType != fCurrency)
			{
				szTemp.Format("盒状图中的X轴参数(%s)不是数字型,无法绘图,请检查!Line=%d,File=%s",szFldName.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				continue;
			}
			arrCol.RemoveAll();
			dataMatrix.destroy();
			arrCol.Add(nColIndex);
			nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,0);
			if (nRowCount < 1)
			{
				szTemp.Format("盒状图中的X轴变量(%s)有效数据太少,无法绘图,请检查!Line=%d,File=%s",szFldName.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				continue;
			}
			//计算盒状图
			CIntVector vecInd;
			CDoubleVector w;
			CDoubleVector v = dataMatrix(0);
			pBox->SetParam(false,false,false);
			pBox->CalcPercent(v,w,vecInd);
			pBox->CalcBoxPlot(v,(void **)&pDPFB,nCount);
			pDPFB->strName += SEP_RISER + szFldName;
			pBox->SetBoxplot(pDPFB,1,StrArr);
			delete pDPFB;
			bHasBox = true;
		}
	}
	else
	{
		for (i=0; i<m_tVarX.iCount; i++)
		{
			nColIndex = m_tVarX.pValue[i];
			nDataType = m_pDataInterface->GetFieldType(nColIndex);
			szFldName = m_pDataInterface->GetFieldName(nColIndex);
			if (nDataType != fInt && nDataType != fDouble && 
				nDataType != fBoolean && nDataType != fCurrency)
			{
				szTemp.Format("盒状图中的X轴参数(%s)不是数字型,无法绘图,请检查!Line=%d,File=%s\n",szFldName.GetData(),__LINE__,__FILE__);
				m_szErrMsg += szTemp;
				continue;
			}
			arrCol.Add(nColIndex);
			arrFldName.Add(szFldName);
		}
		if (arrCol.GetSize() < 1)
		{
			m_szErrMsg.Format("盒状图中的X轴参数均为非数字型,无法绘图,请检查!Line=%d,File=%s\n",__LINE__,__FILE__);
			return false;
		}
		//读数据
		nRowCount = m_pDataInterface->GetColsData(arrCol,dataMatrix,0);
		if (nRowCount < 1)
		{
			m_szErrMsg.Format("盒状图中的X轴变量有效数据太少,无法绘图,请检查!Line=%d,File=%s\n",__LINE__,__FILE__);
			return false;
		}
		for (i=0; i<arrCol.GetSize(); i++)
		{
			//计算盒状图
			CIntVector vecInd;
			CDoubleVector w;
			CDoubleVector v = dataMatrix(i);
			pBox->SetParam(false,false,false);
			pBox->CalcPercent(v,w,vecInd);
			pBox->CalcBoxPlot(v,(void **)&pDPFB,nCount);
			pDPFB->strName += SEP_RISER + arrFldName.GetAt(i);
			pBox->SetBoxplot(pDPFB,1,StrArr);
			delete pDPFB;
			bHasBox = true;
		}
	}
	if (m_szErrMsg.GetLength() > 0)
	{
		CRsltElementText *pText = new CRsltElementText(MSG_TITLE_STR);
		CTString szMsg = GetLastErrMsg();
		pText->AddString(szMsg);
		m_pResult->Add(pText);
	}
	//Add
	if (bHasBox)
	{
		CRsltElementChart *pChart = new CRsltElementChart("盒状图",pBox);
		pBox->SetXAxilLabel("组项");
		m_pResult->SetName("盒状图"); 
		m_pResult->Add(pChart); 
	}
	else
	{
		delete pBox;
		pBox = NULL;
	}
	return true;
}