Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MDI Child Waiting On Another Child

MDI Child Waiting On Another Child

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpgame-devhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cyric74
    wrote on last edited by
    #1

    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: //In the Main Menu -- Once player selects move: void InitiateMove() { ThreadStart *myThreadDelegate = new ThreadStart(this, Military_MoveThread); trd = new Thread(myThreadDelegate); trd->IsBackground = true; trd->Start(); } void Military_MoveThread() { //Opens the map form for selection theClient->EnableMap(); //Tells the map form that we are looking for a target theMap->iTargetMode = 1; //Sit and wait until the map decides we have a target while( theMap->iTargetMode == 1 ) { Thread::Sleep( 100 ); } //If they cancled the selection, return to normal mode if( theClient->iTargetCity == -1 ) { theClient->EnableAllForms(); theMap->EnableAllCities(); return; } //If they selected a city that isn't valid, pop up MDI child message box if( theClient->PlayerOwnsCity( theClient->iTargetCity ) == false && theClient->clientCityButtons[ theClient->iTargetCity ]->iOwner != -1 ) { Popup( String::Concat( S"Master ", theClient->Name, S", that city does not belong to us!" ) ); theMap->EnableAllCities(); theClient->iTargetCity = -1; return; } //***Code continues below for movement*** } void Popup( S

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups