Click here to Skip to main content
16,006,762 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCHtmlEditCtrl protected destructor Pin
cowboymoore3-Jun-04 16:37
cowboymoore3-Jun-04 16:37 
GeneralRe: CHtmlEditCtrl protected destructor Pin
palbano3-Jun-04 18:17
palbano3-Jun-04 18:17 
GeneralRe: CHtmlEditCtrl protected destructor Pin
cowboymoore4-Jun-04 17:17
cowboymoore4-Jun-04 17:17 
QuestionIs a point in the Polygon? Pin
Xytme3-Jun-04 15:50
Xytme3-Jun-04 15:50 
AnswerRe: Is a point in the Polygon? Pin
Tim Smith3-Jun-04 16:45
Tim Smith3-Jun-04 16:45 
AnswerRe: Is a point in the Polygon? Pin
Andrew Walker3-Jun-04 17:59
Andrew Walker3-Jun-04 17:59 
AnswerRe: Is a point in the Polygon? Pin
basementman4-Jun-04 6:11
basementman4-Jun-04 6:11 
GeneralMDI Child Waiting On Another Child Pin
Cyric743-Jun-04 13:18
Cyric743-Jun-04 13:18 
I'm working on a hobby war simulation game in Visual C++ .NET and am having a problem with multithreading. I don't know much about it, and am wondering if there may even be a better solution than multithreading for this problem:

The game is running in an MDI parent with multiple forms. A user wants to move units from one city to another; The Main Menu child tells the Map child that it needs the user to select a target city. I want the Main Menu to pause its code processing at that point until the user selects a city, which then is passed back to the Main Menu so it may continue processing.

The problem I am running into is this: The player selects an invalid city to move to -- I want to generate another MDI child that acts as a popup to inform them they can't move there and what their options are. When I do this (as shown in the code below) the new Popup child flashes on the screen for just a moment then disappears. I am guessing that this is because the Military_MoveThread is ending, so it closes anything initialized in the thread, but I am not really sure why it does this. I want the thread to end but the new MDI child popup to remain on the screen. I've tried running the popup as a new thread but it does exactly the same thing.

Here is basically what I have:

<br />
//In the Main Menu -- Once player selects move:<br />
void InitiateMove()<br />
{<br />
        ThreadStart *myThreadDelegate = new ThreadStart(this, Military_MoveThread);<br />
	trd = new Thread(myThreadDelegate);<br />
	trd->IsBackground = true;<br />
	trd->Start();<br />
}<br />
void Military_MoveThread()<br />
{<br />
        //Opens the map form for selection<br />
	theClient->EnableMap();<br />
	<br />
        //Tells the map form that we are looking for a target<br />
	theMap->iTargetMode = 1;<br />
<br />
        //Sit and wait until the map decides we have a target<br />
	while( theMap->iTargetMode == 1 )<br />
	{<br />
     	     Thread::Sleep( 100 );<br />
	}<br />
      <br />
        //If they cancled the selection, return to normal mode<br />
	if( theClient->iTargetCity == -1 )<br />
	{<br />
		theClient->EnableAllForms();<br />
		theMap->EnableAllCities();<br />
		return;<br />
	}<br />
<br />
        //If they selected a city that isn't valid, pop up MDI child message box<br />
	if( theClient->PlayerOwnsCity( theClient->iTargetCity ) == false &&<br />
	theClient->clientCityButtons[ theClient->iTargetCity ]->iOwner != -1 )<br />
	{<br />
	        Popup( String::Concat( S"Master ", theClient->Name, S", that city does not belong to us!" ) );<br />
		theMap->EnableAllCities();<br />
		theClient->iTargetCity = -1;<br />
		return;<br />
	}<br />
<br />
        //***Code continues below for movement***<br />
}<br />
void Popup( String *advise )<br />
{<br />
        //confirmPopup is a pre-initialized MDI child form that remains hidden<br />
        //until it gets the RequestConfirm command. It disables all other MDI children<br />
        //on screen until user hits an Okay button<br />
<br />
	confirmPopup->RequestConfirm( advise );<br />
}


My question is: Is there an easier way for the main menu child to wait on the map for data? If not, what do I need to do to keep the confirmPopup child from disappearing right after it appears?

Thanks,
Cyric
Generalwin32 dll - dialog box Pin
Anonymous3-Jun-04 12:48
Anonymous3-Jun-04 12:48 
GeneralRe: win32 dll - dialog box Pin
Cedric Moonen3-Jun-04 20:21
Cedric Moonen3-Jun-04 20:21 
GeneralRe: win32 dll - dialog box Pin
Anonymous4-Jun-04 6:45
Anonymous4-Jun-04 6:45 
GeneralRe: win32 dll - dialog box Pin
ATHMystikal15-Jan-10 15:50
ATHMystikal15-Jan-10 15:50 
Generalhelp! Pin
Archer2823-Jun-04 12:36
Archer2823-Jun-04 12:36 
GeneralRe: help! Pin
*Dreamz3-Jun-04 17:47
*Dreamz3-Jun-04 17:47 
GeneralRe: help! Pin
basementman4-Jun-04 6:12
basementman4-Jun-04 6:12 
GeneralRe: help! Pin
Archer2824-Jun-04 7:55
Archer2824-Jun-04 7:55 
GeneralUNICODE Pin
pnpfriend3-Jun-04 11:30
pnpfriend3-Jun-04 11:30 
GeneralRe: UNICODE Pin
Anthony_Yio3-Jun-04 16:57
Anthony_Yio3-Jun-04 16:57 
GeneralTreeView in dockable DialogBar Pin
NTense3-Jun-04 9:44
NTense3-Jun-04 9:44 
GeneralRe: TreeView in dockable DialogBar Pin
bneacetp3-Jun-04 10:12
bneacetp3-Jun-04 10:12 
Generalunresolved externals when instantiating COM objects Pin
imposterrific3-Jun-04 9:26
imposterrific3-Jun-04 9:26 
Generalstl list error in memory.h Pin
kfaday3-Jun-04 8:57
kfaday3-Jun-04 8:57 
GeneralRe: stl list error in memory.h Pin
palbano3-Jun-04 9:08
palbano3-Jun-04 9:08 
GeneralRe: stl list error in memory.h Pin
kfaday3-Jun-04 9:11
kfaday3-Jun-04 9:11 
GeneralRe: stl list error in memory.h Pin
palbano3-Jun-04 9:23
palbano3-Jun-04 9:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.