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. Modal dialog box in a Thread

Modal dialog box in a Thread

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionlounge
4 Posts 3 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.
  • I Offline
    I Offline
    iayd
    wrote on last edited by
    #1

    Hi, I want to create a modal dialog box instead of a messagebox in a worker thread.But when I closed the dialog box the program is gone (shutting down). What can cause to this problem? Is there a way to create a modal dialog box in a thread? I think I shoud say that I am writing the program for Windows CE, but I think that the problem may be a general problem. Thanks

    S M 2 Replies Last reply
    0
    • I iayd

      Hi, I want to create a modal dialog box instead of a messagebox in a worker thread.But when I closed the dialog box the program is gone (shutting down). What can cause to this problem? Is there a way to create a modal dialog box in a thread? I think I shoud say that I am writing the program for Windows CE, but I think that the problem may be a general problem. Thanks

      S Offline
      S Offline
      SandipG
      wrote on last edited by
      #2

      Can you Paste your code ??

      Regards, Sandip.

      1 Reply Last reply
      0
      • I iayd

        Hi, I want to create a modal dialog box instead of a messagebox in a worker thread.But when I closed the dialog box the program is gone (shutting down). What can cause to this problem? Is there a way to create a modal dialog box in a thread? I think I shoud say that I am writing the program for Windows CE, but I think that the problem may be a general problem. Thanks

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        Don't create UI in your worker thread, send a message to your main UI thread and create a dialog there. use synchronisation event to wait for the dialog in your thread.

        This signature was proudly tested on animals.

        I 1 Reply Last reply
        0
        • M Maximilien

          Don't create UI in your worker thread, send a message to your main UI thread and create a dialog there. use synchronisation event to wait for the dialog in your thread.

          This signature was proudly tested on animals.

          I Offline
          I Offline
          iayd
          wrote on last edited by
          #4

          My code is like that;

          UINT ComThreadEvent1(LPVOID lParam)
          {
          CNotepad *dlg = (CNotepad *)lParam;
          while(HD != NULL)
          {
          ::Sleep(500);
          int index = dlg->events.Find(_T("\r\n"),0);
          if(index == 0 )
          {
          dlg->thread2->ResumeThread();
          dlg->GetEvent(dlg->events.Left(index));
          }
          }
          return 0;
          }

          void CNotepad::GetEvent(CString event)
          {
          CString str;
          if(event.Mid(9,2) == "C0")
          {
          str = "Hello";
          CMessageBox mBox;
          mBox.DoModal();
          }
          }

          Here GetEvent() method is creating Modal Dialog box.How can I send a message to my main UI thread and create a dialog there? Thanks

          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