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
int CMonitor::GetDualPosition(CPoint point)
{
	CRect rc(0, 0, 0, 0);
	CRect rcWork;

	HMONITOR	hMonitor;
	CDWordArray arrHMonitor;

	::EnumDisplayMonitors(NULL, NULL, EnumMonitorProc, (LPARAM)&arrHMonitor);
	int nMonitorCount = arrHMonitor.GetSize();

	CArray<CRect, CRect &>	arrRect;
	for(int i = 0; i < nMonitorCount; i++)
	{
		MONITORINFO mi;

		memset(&mi, 0x00, sizeof(MONITORINFO));
		mi.cbSize	= sizeof(MONITORINFO);
		hMonitor	= (HMONITOR)arrHMonitor[i];

		::GetMonitorInfo(hMonitor, &mi);

		rcWork = mi.rcWork;

		if( rcWork.left <= point.x && point.x <= rcWork.right &&
			rcWork.top  <= point.y && point.y <= rcWork.bottom )
		{
			return i;
		}
	}

	return -1;
}
Beispiel #3
0
CRect CMonitor::GetMonitorRect(int index)
{
	int			nMonitorCount;
	CRect		rcWork;
	HMONITOR	hMonitor;
	CDWordArray arrHMonitor;

	::EnumDisplayMonitors(NULL, NULL, EnumMonitorProc, (LPARAM)&arrHMonitor);
	nMonitorCount = arrHMonitor.GetSize();

	if( index < 0 || nMonitorCount <= index )
	{
		// 범위에 없는 경우는 무조건 기본 영역
		SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, 0);

		return rcWork;
	}

	MONITORINFO mi;

	memset(&mi, 0x00, sizeof(MONITORINFO));
	mi.cbSize	= sizeof(MONITORINFO);
	hMonitor	= (HMONITOR)arrHMonitor[index];

	::GetMonitorInfo(hMonitor, &mi);

	rcWork = mi.rcWork;

	return rcWork;
}
BOOL SetRegistryDWordArray(HKEY root, const CString & var, CDWordArray & data)
    {
     CString path;
     
     path.LoadString(IDS_PROGRAM_ROOT);
     CString name;
     makePath(path, var, name);

     HKEY key;
     LONG result = makeKey(root,
     			        path,
			        &key);
     if(result != ERROR_SUCCESS)
	{ /* save it */
	 ::SetLastError((DWORD)result);
	 return FALSE;
	} /* save it */
     
     result = ::RegSetValueEx(key, name, 0, REG_BINARY, (LPBYTE)&(data[0]), 
     				data.GetSize() * sizeof(DWORD));
     ::RegCloseKey(key);
     if(result != ERROR_SUCCESS)
	::SetLastError((DWORD)result);
     
     return result == ERROR_SUCCESS;

    }
void CTDCTaskListCtrl::SetSelectedTasks(const CDWordArray& aTaskIDs, DWORD dwFocusedTaskID)
{
	DeselectAll();

	int nID = aTaskIDs.GetSize();

	if (nID)
	{
		CTLSHoldResync hr(*this);
				
		while (nID--)
		{
			DWORD dwTaskID = aTaskIDs[nID];
			int nItem = FindTaskItem(dwTaskID);
			
			if (nItem != -1)
			{
				BOOL bAnchor = (dwTaskID == dwFocusedTaskID);
				DWORD dwState = LVIS_SELECTED;
				
				if (bAnchor)
				{
					dwState |= LVIS_FOCUSED;

					m_lcTasks.SetSelectionMark(nItem);
					m_lcColumns.SetSelectionMark(nItem);
				}
				
				m_lcTasks.SetItemState(nItem, dwState, (LVIS_SELECTED | LVIS_FOCUSED));
				m_lcColumns.SetItemState(nItem, dwState, (LVIS_SELECTED | LVIS_FOCUSED));
			}
		}

	}
}
Beispiel #6
0
void CRRECRuler::SetTabStops( const CDWordArray& arr )
/* ============================================================
	Function :		CRRECRuler::SetTabStops
	Description :	Sets the tab stops in the internal tab stop 
					array, in device pixels
	Access :		Public
					
	Return :		void
	Parameters :	const CDWordArray& arr	-	The array to 
												copy from
					
	Usage :			Call to set the tab stops of the ruler.

   ============================================================*/
{

	m_tabs.RemoveAll();
	int max = arr.GetSize();
	for ( int t = 0 ; t < max ; t++ )
	{
		m_tabs.Add( arr[ t ] );
	}

	if (GetSafeHwnd())
	{
		Invalidate(FALSE);
		UpdateWindow();
	}
}
BOOL CBCGPRegistry::Read(LPCTSTR pszKey, LPPOINT& lpPoint)
{
	ASSERT(m_hKey);

	BOOL	bSucess = FALSE;
	BYTE*	pData = NULL;
	UINT	uDataSize;

	Read (pszKey, &pData, &uDataSize);

	try
	{
		if (pData != NULL && m_Info.lMessage == ERROR_SUCCESS && m_Info.dwType == REG_BINARY)
		{
			CMemFile file (pData, uDataSize);
			CArchive ar (&file, CArchive::load);

			ar.m_bForceFlat = FALSE;
			ASSERT(ar.IsLoading());

			CDWordArray dwcArray;
			ASSERT(dwcArray.IsSerializable());
			dwcArray.Serialize(ar);
			ar.Close();

			if (dwcArray.GetSize() == 2)
			{
				lpPoint->x = dwcArray.GetAt(0);
				lpPoint->y = dwcArray.GetAt(1);

				bSucess = TRUE;
			}
		}
	}
	catch (CMemoryException* pEx)
	{
		pEx->Delete ();
		TRACE(_T("Memory exception in CBCGPRegistry::Read ()!\n"));
	}
	catch (CArchiveException* pEx)
	{
		pEx->Delete ();
		TRACE(_T("CArchiveException exception in CBCGPRegistry::Read ()!\n"));
	}

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

	if (pData != NULL)
	{
		delete [] pData;
		pData = NULL;
	}

	return bSucess;
}
Beispiel #8
0
int	CMonitor::GetMonitorCount()
{
	int			nMonitorCount = 1;
	CDWordArray arrHMonitor;

	::EnumDisplayMonitors(NULL, NULL, EnumMonitorProc, (LPARAM)&arrHMonitor);
	nMonitorCount = arrHMonitor.GetSize();

	return nMonitorCount;
}
void COXCustomizeInstanceManagerPage::PopulateInstancesList()
{
	int nInstanceRunningCount=m_instanceManager.GetNumberOfInstances();
	CString sInstanceRunningCount;
	sInstanceRunningCount.Format(_T("%d"),nInstanceRunningCount);
	m_staticInstanceCount.SetWindowText(sInstanceRunningCount);

	int nSelectedItem=-1;
#if _MFC_VER > 0x0421
	POSITION pos=m_listInstances.GetFirstSelectedItemPosition();
#else
	ASSERT(::IsWindow(m_listInstances.m_hWnd));
	POSITION pos = (POSITION) (1+m_listInstances.GetNextItem(-1, LVIS_SELECTED)); 
#endif
	if(pos!=NULL)
	{
#if _MFC_VER > 0x0421
		int nSelectedItem=m_listInstances.GetNextSelectedItem(pos);
#else
		ASSERT(::IsWindow(m_listInstances.m_hWnd));
		int nSelectedItem = (int)pos-1;
		POSITION npos = (POSITION) (1+m_listInstances.GetNextItem(nSelectedItem, LVIS_SELECTED));
#endif
		ASSERT(pos==NULL);
		ASSERT(nSelectedItem!=-1);
	}

	m_listInstances.DeleteAllItems();
	// populate list of all running instances
	CDWordArray arrInstances;
	VERIFY(m_instanceManager.GetInstanceCollection(arrInstances));
	ASSERT(arrInstances.GetSize()==nInstanceRunningCount);
	DWORD dwCurrentPID=m_instanceManager.GetCurrentInstanceID();
	for(int nIndex=0; nIndex<nInstanceRunningCount; nIndex++)
	{
		CString sItem;
		sItem.Format(IDS_OX_CSTMZEINSTANCEINSTANCEF,nIndex+1);//"Instance %d"
		VERIFY(m_listInstances.InsertItem(nIndex,sItem)==nIndex);
		CString sPID;
		sPID.Format(_T("%d"),arrInstances[nIndex]);
		m_listInstances.SetItemText(nIndex,1,sPID);
		VERIFY(sItem.LoadString(IDS_OX_CSTMZEINSTANCECURRENT));//"Current"
		if(arrInstances[nIndex]==dwCurrentPID)
			m_listInstances.SetItemText(nIndex,2,sItem);
		m_listInstances.SetItemData(nIndex,(LPARAM)arrInstances[nIndex]);
	}

	if(nSelectedItem>=0 && nSelectedItem<m_listInstances.GetItemCount())
	{
		m_listInstances.SetItemState(nSelectedItem,LVIS_SELECTED|LVIS_FOCUSED,
			LVIS_SELECTED|LVIS_FOCUSED);
	}
}
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();
}
BOOL CTDCTaskListCtrl::SelectTasks(const CDWordArray& aTaskIDs, BOOL bTrue)
{
	ASSERT(aTaskIDs.GetSize());

	if (!aTaskIDs.GetSize())
		return FALSE;

	if (!bTrue)
	{
		SetSelectedTasks(aTaskIDs, aTaskIDs[0]);
	}
	else
	{
		CDWordArray aTrueTaskIDs;
		
		aTrueTaskIDs.Copy(aTrueTaskIDs);
		m_data.GetTrueTaskIDs(aTrueTaskIDs);
		
		SetSelectedTasks(aTrueTaskIDs, aTrueTaskIDs[0]);
	}

	return TRUE;
}
Beispiel #12
0
void CCalendarDlg::OnCalendarClearSelected() 
{
	CDWordArray dwaSelection;
	m_pCalendarCtrl->GetSelectedItems(dwaSelection);
	for(int i=0; i<dwaSelection.GetSize(); i++)
	{
		CalendarDataItem* p = NULL;
		if(g_CalendarData.Lookup((void*)dwaSelection[i], (void*&)p))
		{
			p->bMarked = false;
			p->csLines.RemoveAll();
		}		
	}
	m_pCalendarCtrl->UpdateCells();
}
Beispiel #13
0
void CCalendarDlg::OnCalendarMarkSelected() 
{
	CDWordArray dwaSelection;
	m_pCalendarCtrl->GetSelectedItems(dwaSelection);
	for(int i=0; i<dwaSelection.GetSize(); i++)
	{
		CalendarDataItem* p = NULL;
		if(!g_CalendarData.Lookup((void*)dwaSelection[i], (void*&)p))
		{
			p = new CalendarDataItem;
			g_CalendarData.SetAt((void*)dwaSelection[i], (void*)p);
		}
		p->bMarked = true;
	}
	m_pCalendarCtrl->UpdateCells();
}
Beispiel #14
0
void CCLLKDlg::StartNewGame(void)
{
	CTime t=CTime::GetCurrentTime();
	tGameTime=t;
	strTiShi1="系统时间:"+t.Format("%H:%M:%S");
	m_StatusBar.SetText(strTiShi1,2,0);
	strTiShi2.Format(" 该局时间:00:00:00");
	m_StatusBar.SetText(strTiShi2,1,0);
	strTiShi3.Format("当前游戏:%d行%d列%d种方块",m_nRow-2,m_nCol-2,m_Kind);
	m_StatusBar.SetText(strTiShi3,0,0);

	delete[] m_map;
	m_map=new int[m_nCol*m_nRow];
	for (int iNum=0;iNum<(m_nCol*m_nRow);iNum++)
	{
		m_map[iNum]=BLANK_STATE;
	}
	srand(time(NULL));
	CDWordArray tmpMap;

	for (int i=0;i<(m_nRow-2)*(m_nCol-2)/2;i++)
	{
		int x=rand()%m_Kind;
		tmpMap.Add(x);
		tmpMap.Add(x);

	}

	for (int i=1;i<(m_nCol-1);i++)
	{
		for (int j=1;j<(m_nRow-1);j++)
		{
			INT_PTR nIndex=(int(rand()*0.1+rand()*0.01+rand()))%tmpMap.GetSize();
			m_map[i+j*m_nCol]=tmpMap.GetAt(nIndex);
			tmpMap.RemoveAt(nIndex);

		}
	}
	Invalidate(false);
}
Beispiel #15
0
void CCalendarDlg::OnCalendarAddEntryToSelected() 
{
	// TODO: Add your command handler code here
	CCalendarInputDlg dlg;
	if(dlg.DoModal() == IDOK && !dlg.m_Text.IsEmpty())
	{
		CDWordArray dwaSelection;
		m_pCalendarCtrl->GetSelectedItems(dwaSelection);
		for(int i=0; i<dwaSelection.GetSize(); i++)
		{
			CalendarDataItem* p = NULL;
			if(!g_CalendarData.Lookup((void*)dwaSelection[i], (void*&)p))
			{
				p = new CalendarDataItem;
				p->bMarked = false;
				g_CalendarData.SetAt((void*)dwaSelection[i], (void*)p);
			}
			p->csLines.Add(dlg.m_Text);
		}
		m_pCalendarCtrl->UpdateCells();
	}	
}
Beispiel #16
0
// When starting a mouse-key select, the anchor point, and all contiguous 
// selections that are not in the path of the current item can remain 
// selected.  All other selections are tossed, like Exploder does.
void CMultiSelTreeCtrl::DoKeyedDeselect( BOOL scrollingDown )
{
	CDWordArray keepSet;
	HTREEITEM currentItem= m_AnchorItem;
	
	// Record the contiguous selection's we're keeping
	keepSet.Add( (DWORD) m_AnchorItem );
	while(1)
	{
		if( scrollingDown )
			currentItem= GetPrevSiblingItem( currentItem);
		else
			currentItem= GetNextSiblingItem( currentItem);

		if( currentItem == NULL || !IsSelected( currentItem ) )
			break;

		keepSet.Add( (DWORD) currentItem );
	}

	// Unselect everything
	//
	int i;
	for( i= m_SelectionSet.GetSize()-1; i >= 0; i-- )
	{
		currentItem= (HTREEITEM) m_SelectionSet.GetAt(i);	
		// Undo any display atts
		SetItemState(currentItem, 0, TVIS_CUT | TVIS_BOLD | TVIS_SELECTED);
	}

	// Then select everything in the keepset
	//
	m_SelectionSet.RemoveAll();
	for( i= keepSet.GetSize()-1; i>=0; i-- )
		SetSelectState( (HTREEITEM) keepSet.GetAt(i), TRUE );

	m_PendingKeyedDeselect= FALSE;
	ShowNbrSelected();
}
Beispiel #17
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;
}
Beispiel #18
0
void CSynBCGPEditView::GetUndoActions( CStringList& lstActions ) const
{
	CDWordArray dwaUAT;
	m_pEdit->GetUndoActions(dwaUAT);

	lstActions.RemoveAll();

	int nIndex = (int)dwaUAT.GetSize();
	if ( nIndex != 0)
	{
		CString strAction;

		while (nIndex--)
		{
			strAction.Empty();

			switch (dwaUAT.GetAt(nIndex) & UAT_REASON) 
			{
			case g_dwUATUndefined:
				strAction.LoadString(IDS_STRING_UAT_UNDEF);
				break;

			case g_dwUATTyping:
				strAction.LoadString(IDS_STRING_UAT_TYPE);
				break;

			case g_dwUATCut:
				strAction.LoadString(IDS_STRING_UAT_CUT);
				break;

			case g_dwUATPaste:
				strAction.LoadString(IDS_STRING_UAT_PASTE);
				break;

			case g_dwUATDelete:
				strAction.LoadString(IDS_STRING_UAT_DEL);
				break;

			case g_dwUATBackspace:
				strAction.LoadString(IDS_STRING_UAT_BACK);
				break;

			case g_dwUATDragDrop:
				strAction.LoadString(IDS_STRING_UAT_DRAG);
				break;

			case g_dwUATEnter:
				strAction.LoadString(IDS_STRING_UAT_ENTER);
				break;

			case g_dwUATIndent:
				strAction.LoadString(IDS_STRING_UAT_INDENT);
				break;		

			case g_dwUATUnindent:
				strAction.LoadString(IDS_STRING_UAT_UNINDENT);
				break;

			case g_dwUATTab:
				strAction.LoadString(IDS_STRING_UAT_TAB);
				break;		

			case g_dwUATReplace:
				strAction.LoadString(IDS_STRING_UAT_REP);
				break;
			case g_dwUATComment:
				strAction.LoadString(IDS_STRING_UAT_COMM);
				break;
			case g_dwUATUncomment:
				strAction.LoadString(IDS_STRING_UAT_UNCOMM);
				break;
			case g_dwUATFormatter:
				strAction.LoadString(IDS_STRING_UAT_TIDY);
				break;
			default:
				strAction.LoadString(IDS_STRING_UAT_UNDEF);
			}			

			if (strAction.IsEmpty())
			{
				ASSERT(FALSE);
				strAction = _T("<?>");
			}

			lstActions.AddHead(strAction);
		}
	}
}
Beispiel #19
0
void AFXAPI AfxDumpStack(DWORD dwTarget /* = AFX_STACK_DUMP_TARGET_DEFAULT */)
{
	CTraceClipboardData clipboardData(dwTarget);

	clipboardData.SendOut("=== begin AfxDumpStack output ===\r\n");

	CDWordArray adwAddress;
	HANDLE hProcess = ::GetCurrentProcess();
	if (SymInitialize(hProcess, NULL, FALSE))
	{
		// force undecorated names to get params
		DWORD dw = SymGetOptions();
		dw &= ~SYMOPT_UNDNAME;
		SymSetOptions(dw);

		HANDLE hThread = ::GetCurrentThread();
		CONTEXT threadContext;

		threadContext.ContextFlags = CONTEXT_FULL;

		if (::GetThreadContext(hThread, &threadContext))
		{
			STACKFRAME stackFrame;
			memset(&stackFrame, 0, sizeof(stackFrame));
			stackFrame.AddrPC.Mode = AddrModeFlat;

			DWORD dwMachType;

#if defined(_M_IX86)
			dwMachType                  = IMAGE_FILE_MACHINE_I386;

			// program counter, stack pointer, and frame pointer
			stackFrame.AddrPC.Offset    = threadContext.Eip;
			stackFrame.AddrStack.Offset = threadContext.Esp;
			stackFrame.AddrStack.Mode   = AddrModeFlat;
			stackFrame.AddrFrame.Offset = threadContext.Ebp;
			stackFrame.AddrFrame.Mode   = AddrModeFlat;
#elif defined(_M_MRX000)
			// only program counter
			dwMachType                  = IMAGE_FILE_MACHINE_R4000;
			stackFrame.AddrPC. Offset    = treadContext.Fir;
#elif defined(_M_ALPHA)
			// only program counter
			dwMachType                  = IMAGE_FILE_MACHINE_ALPHA;
			stackFrame.AddrPC.Offset    = (unsigned long) threadContext.Fir;
#elif defined(_M_PPC)
			// only program counter
			dwMachType                  = IMAGE_FILE_MACHINE_POWERPC;
			stackFrame.AddrPC.Offset    = threadContext.Iar;
#elif
#error("Unknown Target Machine");
#endif

			adwAddress.SetSize(0, 16);

			int nFrame;
			for (nFrame = 0; nFrame < 1024; nFrame++)
			{
				if (!StackWalk(dwMachType, hProcess, hProcess,
					&stackFrame, &threadContext, NULL,
					FunctionTableAccess, GetModuleBase, NULL))
				{
					break;
				}

				adwAddress.SetAtGrow(nFrame, stackFrame.AddrPC.Offset);
			}
		}
	}
	else
	{
		DWORD dw = GetLastError();
		char sz[100];
		wsprintfA(sz,
			"AfxDumpStack Error: IMAGEHLP.DLL wasn't found. "
			"GetLastError() returned 0x%8.8X\r\n", dw);
		clipboardData.SendOut(sz);
	}

	// dump it out now
	int nAddress;
	int cAddresses = adwAddress.GetSize();
	for (nAddress = 0; nAddress < cAddresses; nAddress++)
	{
		SYMBOL_INFO info;
		DWORD dwAddress = adwAddress[nAddress];

		char sz[20];
		wsprintfA(sz, "%8.8X: ", dwAddress);
		clipboardData.SendOut(sz);

		if (ResolveSymbol(hProcess, dwAddress, info))
		{
			clipboardData.SendOut(info.szModule);
			clipboardData.SendOut(info.szSymbol);
		}
		else
			clipboardData.SendOut("symbol not found");
		clipboardData.SendOut("\r\n");
	}

	clipboardData.SendOut("=== end AfxDumpStack() output ===\r\n");
}