コード例 #1
0
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine, int nCmdShow)
{
	ASSERT(hPrevInstance == NULL);

	int nReturnCode = -1;
	__try
	{
	CWinThread* pThread = AfxGetThread();
	CWinApp* pApp = AfxGetApp();

	// AFX internal initialization
	if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
		goto InitFailure;

	// App global initializations (rare)
	if (pApp != NULL && !pApp->InitApplication())
		goto InitFailure;

	// Perform specific initializations
	if (!pThread->InitInstance())
	{
		if (pThread->m_pMainWnd != NULL)
		{
			TRACE(traceAppMsg, 0, "Warning: Destroying non-NULL m_pMainWnd\n");
			pThread->m_pMainWnd->DestroyWindow();
		}
		nReturnCode = pThread->ExitInstance();
		goto InitFailure;
	}
	nReturnCode = pThread->Run();

InitFailure:
#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}
	AfxLockTempMaps();
	AfxUnlockTempMaps(-1);
#else
	;
#endif
	}
	__except(RecordExceptionInfo(GetExceptionInformation()))
	{
	}

	// must call AfxWinTerm after handling exception or we'll crash
	// again trying to destroy the tooltip window

	AfxWinTerm();

	return nReturnCode;
}
コード例 #2
0
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine, int nCmdShow)
{
	ASSERT(hPrevInstance == NULL);

	int nReturnCode = -1;
	CWinThread* pThread = AfxGetThread();
	CWinApp* pApp = AfxGetApp();

	// AFX internal initialization
	bool InitSuccess = AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
    // App global initializations (rare)
	if (pApp != NULL)
      InitSuccess = InitSuccess && pApp->InitApplication();

	// Perform specific initializations
	InitSuccess = InitSuccess && pThread->InitInstance();

    // Run the BCI2000 core module.
    if( InitSuccess )
    {
      CoreModuleMFC coreModule;
      nReturnCode = ( coreModule.Run( __argc, __argv ) ? 0 : -1 );
    }
    else
    {
		if (pThread->m_pMainWnd != NULL)
		{
			TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
			pThread->m_pMainWnd->DestroyWindow();
		}
	}
    pThread->ExitInstance();

#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE1("Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}
	AfxLockTempMaps();
	AfxUnlockTempMaps(-1);
#endif

	AfxWinTerm();
	return nReturnCode;
}
コード例 #3
0
BOOL DoExit()
{
#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE(traceAppMsg, 0, "Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}
	AfxLockTempMaps();
	AfxUnlockTempMaps(-1);
#endif

	AfxWinTerm();
	return TRUE;
}
コード例 #4
0
ファイル: trckrect.cpp プロジェクト: rickerliang/OpenNT
BOOL CRectTracker::TrackHandle(int nHandle, CWnd* pWnd, CPoint point,
	CWnd* pWndClipTo)
{
	ASSERT(nHandle >= 0);
	ASSERT(nHandle <= 8);   // handle 8 is inside the rect

	// don't handle if capture already set
	if (::GetCapture() != NULL)
		return FALSE;

	ASSERT(!m_bFinalErase);

	// save original width & height in pixels
	int nWidth = m_rect.Width();
	int nHeight = m_rect.Height();

	// set capture to the window which received this message
	pWnd->SetCapture();
	ASSERT(pWnd == CWnd::GetCapture());
	pWnd->UpdateWindow();
	if (pWndClipTo != NULL)
		pWndClipTo->UpdateWindow();
	CRect rectSave = m_rect;

	// find out what x/y coords we are supposed to modify
	int *px, *py;
	int xDiff, yDiff;
	GetModifyPointers(nHandle, &px, &py, &xDiff, &yDiff);
	xDiff = point.x - xDiff;
	yDiff = point.y - yDiff;

	// get DC for drawing
	CDC* pDrawDC;
	if (pWndClipTo != NULL)
	{
		// clip to arbitrary window by using adjusted Window DC
		pDrawDC = pWndClipTo->GetDCEx(NULL, DCX_CACHE);
	}
	else
	{
		// otherwise, just use normal DC
		pDrawDC = pWnd->GetDC();
	}
	ASSERT_VALID(pDrawDC);

	CRect rectOld;
	BOOL bMoved = FALSE;

	AfxLockTempMaps();  // protect maps while looping

	// get messages until capture lost or cancelled/accepted
	for (;;)
	{
		MSG msg;
		VERIFY(::GetMessage(&msg, NULL, 0, 0));

		if (CWnd::GetCapture() != pWnd)
			break;

		switch (msg.message)
		{
		// handle movement/accept messages
		case WM_LBUTTONUP:
		case WM_MOUSEMOVE:
			rectOld = m_rect;
			// handle resize cases (and part of move)
			if (px != NULL)
				*px = (int)(short)LOWORD(msg.lParam) - xDiff;
			if (py != NULL)
				*py = (int)(short)HIWORD(msg.lParam) - yDiff;

			// handle move case
			if (nHandle == hitMiddle)
			{
				m_rect.right = m_rect.left + nWidth;
				m_rect.bottom = m_rect.top + nHeight;
			}
			// allow caller to adjust the rectangle if necessary
			AdjustRect(nHandle, &m_rect);

			// only redraw and callback if the rect actually changed!
			m_bFinalErase = (msg.message == WM_LBUTTONUP);
			if (!rectOld.EqualRect(&m_rect) || m_bFinalErase)
			{
				if (bMoved)
				{
					m_bErase = TRUE;
					DrawTrackerRect(&rectOld, pWndClipTo, pDrawDC, pWnd);
				}
				OnChangedRect(rectOld);
				if (msg.message != WM_LBUTTONUP)
					bMoved = TRUE;
			}
			if (m_bFinalErase)
				goto ExitLoop;

			if (!rectOld.EqualRect(&m_rect))
			{
				m_bErase = FALSE;
				DrawTrackerRect(&m_rect, pWndClipTo, pDrawDC, pWnd);
			}
			break;

		// handle cancel messages
		case WM_KEYDOWN:
			if (msg.wParam != VK_ESCAPE)
				break;
		case WM_RBUTTONDOWN:
			if (bMoved)
			{
				m_bErase = m_bFinalErase = TRUE;
				DrawTrackerRect(&m_rect, pWndClipTo, pDrawDC, pWnd);
			}
			m_rect = rectSave;
			goto ExitLoop;

		// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}

ExitLoop:
	if (pWndClipTo != NULL)
		pWndClipTo->ReleaseDC(pDrawDC);
	else
		pWnd->ReleaseDC(pDrawDC);
	ReleaseCapture();

	AfxUnlockTempMaps(FALSE);

	// restore rect in case bMoved is still FALSE
	if (!bMoved)
		m_rect = rectSave;
	m_bFinalErase = FALSE;
	m_bErase = FALSE;

	// return TRUE only if rect has changed
	return !rectSave.EqualRect(&m_rect);
}
コード例 #5
0
ファイル: ctltrack.cpp プロジェクト: rickerliang/OpenNT
void COleControl::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
	if (m_bOpen || m_pRectTracker == NULL ||
		!(m_pRectTracker->m_nStyle & _nResizeStyle) ||
		(nHitTest == HTHSCROLL) || (nHitTest == HTVSCROLL))
	{
		Default();
		return;
	}

	ScreenToClient(&point);

	AfxLockTempMaps();

	// Setup a (semi-)permanent CWnd for the control's parent window
	CRect rectBefore = m_pRectTracker->m_rect;
	CWnd* pWndClip = CWnd::FromHandle(::GetParent(GetOuterWindow()->m_hWnd));

	// Move or resize the tracker.
	BOOL bTrack = m_pRectTracker->Track(this, point, FALSE, pWndClip);

	AfxUnlockTempMaps();

	if (bTrack)
	{
		ASSERT(m_pInPlaceSite);

		CRect rectAfter = m_pRectTracker->m_rect;
		if (rectBefore != rectAfter)
		{
			// If rectangle changed, adjust the tracker's rectangle and move
			// the control.
			m_pRectTracker->m_rect.OffsetRect(-m_pRectTracker->m_rect.left,
				-m_pRectTracker->m_rect.top);
			CWnd* pWndOuter = GetOuterWindow();
			CWnd* pWndParent = pWndOuter->GetParent();
			CRect rectWindow;
			CRect rectParent;
			pWndOuter->GetWindowRect(rectWindow);
			pWndParent->GetClientRect(rectParent);
			pWndParent->ClientToScreen(rectParent);
			UINT nHandleSize = m_pRectTracker->m_nHandleSize - 1;
			rectAfter.OffsetRect(rectWindow.left - rectParent.left +
				nHandleSize, rectWindow.top - rectParent.top + nHandleSize);

			// Update the control's extents.
			SIZEL szlPixels;
			SIZEL szlHimetric;
			szlPixels.cx = (long)rectAfter.Width();
			szlPixels.cy = (long)rectAfter.Height();
			_AfxXformSizeInPixelsToHimetric(NULL, &szlPixels, &szlHimetric);
			if ((m_cxExtent != szlHimetric.cx) ||
				(m_cyExtent != szlHimetric.cy))
			{
				m_cxExtent = szlHimetric.cx;
				m_cyExtent = szlHimetric.cy;
				SetModifiedFlag();
			}

			// Move/resize the control's window.
			m_pInPlaceSite->OnPosRectChange(rectAfter);
		}
	}
}
コード例 #6
0
int AFXAPI AfxWinMain(HINSTANCE hInstance, 
					  HINSTANCE hPrevInstance,	
					  LPTSTR lpCmdLine, 
					  int nCmdShow)
{
	char szLogFileName[_MAX_DIR];
	if (GetRecommandLogFileName(szLogFileName) == false) 
		return FALSE;

	InitLog(MLOGSTYLE_DEBUGSTRING|MLOGSTYLE_FILE, szLogFileName);

	// Wrap WinMain in a structured exception handler (different from C++
	// exception handling) in order to make sure that all access violations
	// and other exceptions are displayed - regardless of when they happen.
	// This should be done for each thread, if at all possible, so that exceptions
	// will be reliably caught, even inside the debugger.
#ifdef SUPPORT_EXCEPTIONHANDLING
	char szDumpFileName[_MAX_DIR]; 
	strcpy(szDumpFileName, szLogFileName);
	strcat(szDumpFileName, ".dmp");
	__try {
#endif
		// The code inside the __try block is the MFC version of AfxWinMain(),
		// copied verbatim from the MFC source code.
		ASSERT(hPrevInstance == NULL);

		int nReturnCode = -1;
		CWinApp* pApp = AfxGetApp();

		// AFX internal initialization
		if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
			goto InitFailure;

		// App global initializations (rare)
		ASSERT_VALID(pApp);
		if (!pApp->InitApplication())
			goto InitFailure;
		ASSERT_VALID(pApp);

		// Perform specific initializations
		if (!pApp->InitInstance())
		{
			if (pApp->m_pMainWnd != NULL)
			{
				TRACE(_T("Warning: Destroying non-NULL m_pMainWnd\n"));
				pApp->m_pMainWnd->DestroyWindow();
			}
			nReturnCode = pApp->ExitInstance();
			goto InitFailure;
		}
		ASSERT_VALID(pApp);

		nReturnCode = pApp->Run();
		ASSERT_VALID(pApp);

InitFailure:
#ifdef _DEBUG
		// Check for missing AfxLockTempMap calls
		if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
		{
			TRACE(_T("Warning: Temp map lock count non-zero (%ld).\n"),
				AfxGetModuleThreadState()->m_nTempMapLock);
		}
		AfxLockTempMaps();
		AfxUnlockTempMaps(-1);
#endif

		AfxWinTerm();
		return nReturnCode;

#ifdef SUPPORT_EXCEPTIONHANDLING
	}
//	__except(MFilterException(GetExceptionInformation())){
	__except(CrashExceptionDump(GetExceptionInformation(), szDumpFileName)){
		
//		char szFileName[_MAX_DIR];
//		GetModuleFileName(NULL, szFileName, _MAX_DIR);
//		WinExec(szFileName, SW_SHOW);	// Launch again
		//MMatchServer::GetInstance()->CheckMemoryTest();
		//MGetServerStatusSingleton()->Dump();
	}
#endif
	return 0;
}
コード例 #7
0
ファイル: PicTracker.cpp プロジェクト: monfort/VecEngine
BOOL CPicTracker::Track(CWnd* pWnd, CPoint point, BOOL bRotate, CSnapper* pSnapper,
	CWnd* pWndClipTo)
{

   BOOL bResizeOrMove = HitTest(point)==hitOnPoint ? TRUE : FALSE; 

	// don't handle if capture already set
	if (::GetCapture() != NULL)
		return FALSE;


	m_rectOrigianl = m_rect;

   AfxLockTempMaps();  // protect maps while looping

	ASSERT(!m_bFinalErase);

	// set capture to the window which received this message
	pWnd->SetCapture();
	ASSERT(pWnd == CWnd::GetCapture());
	pWnd->UpdateWindow();
	if (pWndClipTo != NULL)
		pWndClipTo->UpdateWindow();

   CPoint LastPoint(point);

	// get DC for drawing
	CDC* pDrawDC;
	if (pWndClipTo != NULL)
	{
		// clip to arbitrary window by using adjusted Window DC
		pDrawDC = pWndClipTo->GetDCEx(NULL, DCX_CACHE);
	}
	else
	{
		// otherwise, just use normal DC
		pDrawDC = pWnd->GetDC();
	}
	ASSERT_VALID(pDrawDC);

	CDRectangle rectOld;
	BOOL bMoved = FALSE;

	// get messages until capture lost or cancelled/accepted
	for (;;)
	{
		MSG msg;
		VERIFY(::GetMessage(&msg, NULL, 0, 0));

		if (CWnd::GetCapture() != pWnd)
			break;

      if(msg.message == WM_MOUSEMOVE)
			DispatchMessage(&msg);

		switch (msg.message)
		{
		// handle movement/accept messages
		case WM_LBUTTONUP:
		case WM_MOUSEMOVE:
OnCheange:
         {
   			rectOld = m_rect;
            m_rect = m_rectOrigianl;
			   // handle resize cases (and part of move)
            CPoint p;
            ::GetCursorPos(&p);
            pWnd->ScreenToClient(&p);

            p -= LastPoint;
            //LastPoint = point;
            
			   // handle move case
            if(bRotate)
            {
               LPDPOINT lpPoints = m_rect.GetPoints();
               CPoint pp = p+LastPoint;
               double dAngle = GetPointAng(&pp, &LastPoint);
               double dist = sqrt((double)(p.x*p.x + p.y*p.y));
               if(dist<30)
               {
                  dAngle /= 30;
                  dAngle *= dist;
               }
               if(::GetKeyState(VK_SHIFT) & 0x8000) //if the shift is pressed then snap to the close 45 degrees
               {
                  dAngle = ((int)((dAngle/(RAD90D/2))+0.499))*(RAD90D/2);
               }

               RotatePoints((LPCDPOINT)lpPoints, m_rect.GetNumOfPoints(), dAngle, NULL);
            }
			   else if (!bResizeOrMove)
			   {
               if((::GetKeyState(VK_SHIFT) & 0x8000)!=0)
               {
                  if(ABS(p.x)>ABS(p.y))
                     p.y=0;
                  else
                     p.x=0;
               }
               LPDPOINT lpPoints = m_rect.GetPoints();
               for(int i=0; i<m_rect.GetNumOfPoints();i++)
               {
                  lpPoints[i].x += p.x;
                  lpPoints[i].y += p.y;
               }
               if(pSnapper!=NULL)
                  pSnapper->FixSnapTo((LPCDPOINT)lpPoints,m_rect.GetNumOfPoints());
			   }
            else
            {
               double dAngle1 = m_rect.GetAngle1();
               double dAngle2 = m_rect.GetAngle2()-RAD90D;

               CDPoint center(0,0);
               CDPoint dp(p);
               RotatePoints(&dp, 1, -dAngle1, &center);

               if(CheckRetainProportions() && (m_dWidthDivHeight!=0)) //if the shift is pressed then remain proporions
               {
                  dp.y=dp.x/m_dWidthDivHeight;
               }

               LPDPOINT lpPoints = m_rect.GetPoints();

               center = GetPointsCenter((LPCDPOINT)lpPoints, m_rect.GetNumOfPoints());
               RotatePoints((LPCDPOINT)lpPoints, m_rect.GetNumOfPoints(), -dAngle1, &center);
			   int i;
               for(i=0; i<m_rect.GetNumOfPoints(); i++)
               {
                  CDPoint ppp = lpPoints[i];
                  ppp-=center;
                  if(ppp.x>0)
                     ppp.x += dp.x;
                  else
                     ppp.x -= dp.x;

                  ppp+=center;
                  lpPoints[i] = ppp;
               }
               RotatePoints((LPCDPOINT)lpPoints, m_rect.GetNumOfPoints(), dAngle1-dAngle2, &center);
               for(i=0; i<m_rect.GetNumOfPoints(); i++)
               {
                  CDPoint ppp = lpPoints[i];
                  ppp-=center;

                  if(ppp.y>0)
                     ppp.y += dp.y;
                  else
                     ppp.y -= dp.y;
                  ppp+=center;
                  lpPoints[i] = ppp;
               }
               RotatePoints((LPCDPOINT)lpPoints, m_rect.GetNumOfPoints(), dAngle2, &center);

               if(pSnapper!=NULL)
                  pSnapper->FixSnapTo((LPCDPOINT)lpPoints,m_rect.GetNumOfPoints());
            }


			   // only redraw and callback if the rect actually changed!
			   m_bFinalErase = (msg.message == WM_LBUTTONUP);
			   if (!rectOld.IsEqual(m_rect) || m_bFinalErase)
			   {
				   if (bMoved)
				   {
					   m_bErase = TRUE;
					   DrawTracker(&rectOld, pWndClipTo, pDrawDC, pWnd);
				   }
				   if (msg.message != WM_LBUTTONUP)
					   bMoved = TRUE;
			   }
			   if (m_bFinalErase)
				   goto ExitLoop;

			   if (!rectOld.IsEqual(m_rect))
			   {
				   m_bErase = FALSE;
				   DrawTracker(&m_rect, pWndClipTo, pDrawDC, pWnd);
			   }
         }
			break;

      case WM_KEYUP:
			if (msg.wParam == VK_SHIFT)
            goto OnCheange;
			break;

		// handle cancel messages
		case WM_KEYDOWN:
			if (msg.wParam == VK_SHIFT)
            goto OnCheange;
			if (msg.wParam != VK_ESCAPE)
				break;
		case WM_RBUTTONDOWN:
			if (bMoved)
			{
				m_bErase = m_bFinalErase = TRUE;
				DrawTracker(&m_rect, pWndClipTo, pDrawDC, pWnd);
			}
			m_rect = m_rectOrigianl;
			goto ExitLoop;

		// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}

ExitLoop:
	if (pWndClipTo != NULL)
		pWndClipTo->ReleaseDC(pDrawDC);
	else
		pWnd->ReleaseDC(pDrawDC);
	ReleaseCapture();

	AfxUnlockTempMaps(FALSE);

	// restore rect in case bMoved is still FALSE
	if (!bMoved)
		m_rect = m_rectOrigianl;
	m_bFinalErase = FALSE;
	m_bErase = FALSE;

	// return TRUE only if rect has changed
	return !m_rectOrigianl.IsEqual(m_rect);
}
コード例 #8
0
BOOL CPolylineCreatorTracker::CreatePolyline(CWnd* pWnd, CDPoint point, CSnapper* pSnapper)
{
	// don't handle if capture already set
	if (::GetCapture() != NULL)
		return FALSE;

	AfxLockTempMaps();  // protect maps while looping

	m_bErase = FALSE;
	m_bFinalErase =  FALSE;

   	// set capture to the window which received this message
	pWnd->SetCapture();
	ASSERT(pWnd == CWnd::GetCapture());
	pWnd->UpdateWindow();

   m_Points.AddTail(new CDPOINT(point));
   CPoint LastPoint(point);

	// get DC for drawing
	CDC* pDrawDC;
		// otherwise, just use normal DC
	pDrawDC = pWnd->GetDC();
	ASSERT_VALID(pDrawDC);

	BOOL bMoved = FALSE;

	// get messages until capture lost or cancelled/accepted
	for (;;)
	{
		MSG msg;
		VERIFY(::GetMessage(&msg, NULL, 0, 0));

		if (CWnd::GetCapture() != pWnd)
			break;

      if(msg.message == WM_MOUSEMOVE)
			DispatchMessage(&msg);

		switch (msg.message)
		{
		// handle movement/accept messages
		case WM_MOUSEMOVE:
         {
			   // handle resize cases (and part of move)
            CPoint point;
            ::GetCursorPos(&point);
            pWnd->ScreenToClient(&point);

            if((::GetKeyState(VK_SHIFT) & 0x8000)!=0)
            {
               CDPoint *pLastPoint = (CDPoint*)m_Points.GetTail();
               if(pLastPoint!=NULL)
               {
                  CDPOINT ppp = CDPoint(point)-(*pLastPoint);
                  if(ABS(ppp.x)>ABS(ppp.y))
                     ppp.y=0;
                  else
                     ppp.x=0;
                  point = *pLastPoint+ppp;
               }
            }

            if(pSnapper!=NULL)
               pSnapper->FixSnapTo(&point);

			   if (LastPoint != point)
			   {
				   m_bErase = FALSE;
               DrawTracker(point, pDrawDC, pWnd);
               bMoved = TRUE;
			   }

            LastPoint = point;
         }
			break;

      case WM_LBUTTONDOWN:
         {
			   // handle resize cases (and part of move)
            CPoint point;
            ::GetCursorPos(&point);
            pWnd->ScreenToClient(&point);

            CDPoint dpoint(point);
            if((::GetKeyState(VK_SHIFT) & 0x8000)!=0)
            {
               CDPoint *pLastPoint = (CDPoint*)m_Points.GetTail();
               if(pLastPoint!=NULL)
               {
                  CDPOINT ppp = dpoint-(*pLastPoint);
                  if(ABS(ppp.x)>ABS(ppp.y))
                     ppp.y=0;
                  else
                     ppp.x=0;
                  dpoint = *pLastPoint+ppp;
               }
            }

            if(pSnapper!=NULL)
               pSnapper->FixSnapTo(&dpoint);
            point = dpoint;

			   if (LastPoint != dpoint)
			   {
				   m_bErase = FALSE;
               DrawTracker(point, pDrawDC, pWnd);
			   }

            m_Points.AddTail(new CDPoint(dpoint));

            //the tracker will not erease the last line
            if(m_PointsLast!=NULL)
               delete []m_PointsLast;
            bMoved = FALSE;

            m_PointsLast = NULL;

            LastPoint = point;
         }
         break;
		// handle cancel messages
		case WM_KEYDOWN:
			if (msg.wParam != VK_ESCAPE)
				break;
      case WM_LBUTTONDBLCLK:
      case WM_RBUTTONDOWN:
         {
			   if (bMoved)
			   {
				   m_bErase = m_bFinalErase = TRUE;
               DrawTracker(point, pDrawDC, pWnd);
			   }
            UINT uiCount = GetPointsCount();
            if(uiCount>1)//erace all the line
            {
               LPPOINT lpPoints = new POINT[uiCount];
               LPCDPOINT lpDPoints = new CDPOINT[uiCount];
               GetPoints(lpDPoints);
               for(UINT ui=0; ui<uiCount; ui++)
                  lpPoints[ui] = lpDPoints[ui];
               CLineTracker::DrawDragPolyLine(pDrawDC, lpPoints, 1, NULL, 1, uiCount);
               delete []lpPoints;
               delete []lpDPoints;
            }
         }
			goto ExitLoop;

		// just dispatch rest of the messages
		default:
			DispatchMessage(&msg);
			break;
		}
	}

ExitLoop:
	pWnd->ReleaseDC(pDrawDC);
	ReleaseCapture();

	AfxUnlockTempMaps(FALSE);

	// restore rect in case bMoved is still FALSE
	m_bFinalErase = FALSE;
	m_bErase = FALSE;

   // return TRUE only if rect has changed
	return GetPointsCount()>1;
}
コード例 #9
0
ファイル: Winmain.cpp プロジェクト: SimVascular/OpenCASCADE
int AFXAPI AfxWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
	LPTSTR lpCmdLine, int nCmdShow)
{
#ifdef DISPLAYCONSOLE 

  // Redirection of standard output to console
  int hCrt;  BOOL rep;  FILE *hf;
  _SYSTEM_INFO lps;
  GetSystemInfo(&lps);
  rep = AllocConsole();
  hCrt = _open_osfhandle((intptr_t) GetStdHandle(STD_OUTPUT_HANDLE),_O_TEXT);
  hf = _fdopen( hCrt, "w" );
  *stdout = *hf;
  // stop the buffer on stdout
//  int i = setvbuf( stdout, NULL, _IONBF, 0 );
//  filebuf ff(hCrt);
//  cout = &ff;
  cout<<"This Debug Window is defined in WinMain.cpp and will disappear in release mode"<<endl;

#endif //  DISPLAYCONSOLE  // By Matra

  // create log file for all OCC messages
//  Message::DefaultMessenger()->AddPrinter (new Message_PrinterOStream ("OCCSampleRun.log", Standard_False));

  ASSERT(hPrevInstance == NULL);

  int nReturnCode = -1;
  CWinApp* pApp = AfxGetApp();

// new in 2.0 CAS.CADE uses the standard C++ exception mechanism
/*#ifdef _DEBUG  // By Matra
  // _Function declaratiob here because you can jump to InitFailure
  Standard_ErrorHandler _Function;  
#endif //  _DEBUG  // By Matra
*/
	// AFX internal initialization
	if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
		goto InitFailure;

	// App global initializations (rare)
	ASSERT_VALID(pApp);
	if (!pApp->InitApplication())
		goto InitFailure;
	ASSERT_VALID(pApp);

	// Perform specific initializations
	if (!pApp->InitInstance())
	{
		if (pApp->m_pMainWnd != NULL)
		{
			TRACE0("Warning: Destroying non-NULL m_pMainWnd\n");
			pApp->m_pMainWnd->DestroyWindow();
		}
		nReturnCode = pApp->ExitInstance();
		goto InitFailure;
	}
	ASSERT_VALID(pApp);


#ifdef _DEBUG  // By Matra
Application:

// new in 2.0 CAS.CADE uses the standard C++ exception mechanism

 // if(DoesNotAbort(_Function))
	try
    {
	  nReturnCode = pApp->Run();
    }
//  if(_Function.Catches(STANDARD_TYPE(Standard_Failure)))
	catch(Standard_Failure)
    {
      Standard_SStream ostr;
      ostr<<Standard_Failure::Caught()<<"\n\0";
      CString aMsg = ostr.str().c_str();
      MessageBoxW (NULL, aMsg, L"CasCade Error", MB_ICONERROR);
      goto Application; // restart application loop
    }
#else // _DEBUG  // By Matra
	nReturnCode = pApp->Run();
#endif // _DEBUG  // By Matra


	ASSERT_VALID(pApp);

InitFailure:
#ifdef _DEBUG
	// Check for missing AfxLockTempMap calls
	if (AfxGetModuleThreadState()->m_nTempMapLock != 0)
	{
		TRACE1("Warning: Temp map lock count non-zero (%ld).\n",
			AfxGetModuleThreadState()->m_nTempMapLock);
	}

	AfxLockTempMaps();
	AfxUnlockTempMaps();
#endif

	AfxWinTerm();

#ifdef DISPLAYCONSOLE  // By Matra
  // ferme la console pour le cout 
  fclose( stdout );
  //hCrt = _fcloseall();  :-)
  rep = FreeConsole();  
#endif // DISPLAYCONSOLE  // By Matra


	return nReturnCode;
}