Hi,
I'm modifying large bridge playing program written in C++ using MS Visual C++ 6.0 and am having a problem with the program. When I run it in Auto Test mode: it deals, bids and plays hands and posts the results to a dialog window, after 181 hands the GUI in the dialog window stops being updated and if I move the dialog window I get an error message: "Easybridge has encountered a problem ...". The error report lists ModName: ntdll.dll, offset: 0120e.
If I let the dialog box be displayed for several minutes when it has reached 181 hands, its display is NOT updated and nothing happens until I touch it or open another window on top of it. The program appears to have been running while the display was frozen at 181 hands because when I open Wordpad, the display jumps to show more hands played.

On Entering Debug I see one entry for the EasyBridge program in the call stack. The statement at the line shown in the call stack is: if (!AfxGetApp()->PumpMessage())

Also on the stack there is a failed Assert in MFC42D.DLL SelectObject() at line 558 where m_hDC is = NULL

The PumpMessage() statement is in the loop where the program deals, bids and plays the name. The full loop's code follows:
Code:
	do
	{
#ifdef _DEBUG
		msOld.Checkpoint(); // NCR-AT debug
#endif
		// play continuously

		// deal a new hand
		m_strStatus = "Dealing...";
		UpdateData(FALSE);
		pDOC->DealHands();
		numHands++;

		// and get bids
		m_strStatus = "Bidding...";
		UpdateData(FALSE);
		do 
		{
			// get the computer's bids
			int nPos = pDOC->GetCurrentPlayerPosition();
			int nBid = pDOC->GetCurrentPlayer()->Bid();
			nCode = pDOC->EnterBid(nPos, nBid);
			if ((nCode == -99) || (nCode == 1))
			{
				// passed out, or 3 passes, and bidding is complete
				break;
			}
			else if (nCode == -1) 
			{
				AfxMessageBox("Error in Bidding Dialog!");
				bBreak = TRUE;
				break;
			}
		} while (!bBreak);

		// bidding is complete; see if we reached a contract
		if (nCode == -99)
			continue;	// passed out, so redeal

		// start timeing
		long lStartTime = timeGetTime();

		// now play out the hand -- play on full auto
		theApp.SetValue(tnCardPlayMode, CEasyBApp::PLAY_FULL_AUTO_EXPRESS);
		pDOC->SetValue(tbExpressPlayMode, TRUE);
		pDOC->InvokeNextPlayer();

		// pump the mesage loop while the hand is being played out
		m_strStatus = "Playing hand...";
		UpdateData(FALSE);
		if(numHands == 180) { // NCR-AT stop just before abend
			if (AfxMessageBox("The Practice abends at about game 181.  Do you wish to continue?", 
			               MB_ICONQUESTION | MB_YESNO) == IDNO)
			break;
		} // NCR-AT end
		MSG msg;
		int cnt = 0;  // NCR-AT debug
		while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) 
		{ 
			if (!AfxGetApp()->PumpMessage()) 
			{ 
				::PostQuitMessage(0); 
				return; 
			}
			cnt++; // NCR-AT
		} 

		totalCnt += cnt; // NCR
		TRACE("numHands=%d  cnt=%d totalCnt=%d\n", numHands, cnt, totalCnt); // NCR
		
		// reset flags
		pDOC->SetValue(tbExpressPlayMode, FALSE);

		// end timer 
		lNumHands++;
		long lEndTime = timeGetTime();
		lfTotalTime += (lEndTime - lStartTime);
		strAvgTime.Format(_T("%.1f secs"), lfTotalTime / (lNumHands*1000));
		//
		CStatic* pText = (CStatic*) GetDlgItem(IDC_AVG_TIME);
		pText->SetWindowText(strAvgTime);
		pText->UpdateWindow();
		//
		CStatic* pLabel = (CStatic*) GetDlgItem(IDC_LABEL_AVGTIME);
		if (!pLabel->IsWindowVisible())
		{
			pLabel->ShowWindow(SW_SHOW);
			pLabel->UpdateWindow();
		}

		//
		if (m_bStopFlag)
			break;

		// save results and update the display
		Update();

#ifdef _DEBUG
		// NCR-AT dump every so often
		if(numHands % 100 == 1) 
		{
			msNew.Checkpoint();
			msDif.Difference( msOld, msNew );
			msDif.DumpStatistics();
			if(numHands < 20)
				msOld.DumpAllObjectsSince(); // only want a couple
		}
#endif
	} while (!bBreak);
How do I find out what my program is doing to the Windows environment that is causing the problem and fix it?

Any other comments welcome

Thanks,
Norm