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. Problem using MFC to create multiple CDialog threads

Problem using MFC to create multiple CDialog threads

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++designhelpquestion
5 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.
  • S Offline
    S Offline
    Spawn Melmac
    wrote on last edited by
    #1

    The problem I have is essentially very simple. I need to have multiple CDialog thread in my application that do not lock the primary UI thread. Their purpose will be to display specific data in each one. My problem is that although I have been able to achieve this for one of the dialogs by

    public:
    CSimulator thSim;
    ...

    thSim.CreateThread();
    

    but any attempt I make to repeat this approach does not give me the dialog although no errors are generated at compile or runtime. I have also tried using the

    OnInitDialog()

    of my main dialog but this just results in the main dialog having the child dialog pasted over it. Not pretty. Ultimately I am planning to use an SDI for the main interface with CDialog's for the children. This would allow the child dialogs to be arranged across multiple montiors independantly of the main UI. Whilst MFC is quite an old thing to be using I have to be sure the application will run on ANY Windows platform without having to worry too much about dependancies (i.e. from XP to Windows 7). Also the target machines are tightly controlled so adding .Net to them is a no go before anyone suggests it. So does anyone have any suggestions how best to create and manage multiple CDialog's? Many thanks

    Alan

    C A 2 Replies Last reply
    0
    • S Spawn Melmac

      The problem I have is essentially very simple. I need to have multiple CDialog thread in my application that do not lock the primary UI thread. Their purpose will be to display specific data in each one. My problem is that although I have been able to achieve this for one of the dialogs by

      public:
      CSimulator thSim;
      ...

      thSim.CreateThread();
      

      but any attempt I make to repeat this approach does not give me the dialog although no errors are generated at compile or runtime. I have also tried using the

      OnInitDialog()

      of my main dialog but this just results in the main dialog having the child dialog pasted over it. Not pretty. Ultimately I am planning to use an SDI for the main interface with CDialog's for the children. This would allow the child dialogs to be arranged across multiple montiors independantly of the main UI. Whilst MFC is quite an old thing to be using I have to be sure the application will run on ANY Windows platform without having to worry too much about dependancies (i.e. from XP to Windows 7). Also the target machines are tightly controlled so adding .Net to them is a no go before anyone suggests it. So does anyone have any suggestions how best to create and manage multiple CDialog's? Many thanks

      Alan

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      sounds like you need modeless dialogs[^].

      image processing toolkits | batch image processing

      1 Reply Last reply
      0
      • S Spawn Melmac

        The problem I have is essentially very simple. I need to have multiple CDialog thread in my application that do not lock the primary UI thread. Their purpose will be to display specific data in each one. My problem is that although I have been able to achieve this for one of the dialogs by

        public:
        CSimulator thSim;
        ...

        thSim.CreateThread();
        

        but any attempt I make to repeat this approach does not give me the dialog although no errors are generated at compile or runtime. I have also tried using the

        OnInitDialog()

        of my main dialog but this just results in the main dialog having the child dialog pasted over it. Not pretty. Ultimately I am planning to use an SDI for the main interface with CDialog's for the children. This would allow the child dialogs to be arranged across multiple montiors independantly of the main UI. Whilst MFC is quite an old thing to be using I have to be sure the application will run on ANY Windows platform without having to worry too much about dependancies (i.e. from XP to Windows 7). Also the target machines are tightly controlled so adding .Net to them is a no go before anyone suggests it. So does anyone have any suggestions how best to create and manage multiple CDialog's? Many thanks

        Alan

        A Offline
        A Offline
        Avi Berger
        wrote on last edited by
        #3

        If I am understanding this correctly, your difficulty is that you are attempting to use modal dialogs. What you want is to use modeless dialogs. These are still based on CDialog but have some differences in what you need to do in some overridden methods and how you start them up. You do not need a seperate thread to run them, they are just fine on your main UI thread. I have talked about them before in this post. I haven't double checked if I have everything in there that you need, but there is at least a good part of it. This should give you some direction. If necessary I could try to fill more stuff in, but I have to head out to a baby naming this afternoon and have a six hour drive tomorrow, so I'm leaving it at this for now. Good luck

        Please do not read this signature.

        S 1 Reply Last reply
        0
        • A Avi Berger

          If I am understanding this correctly, your difficulty is that you are attempting to use modal dialogs. What you want is to use modeless dialogs. These are still based on CDialog but have some differences in what you need to do in some overridden methods and how you start them up. You do not need a seperate thread to run them, they are just fine on your main UI thread. I have talked about them before in this post. I haven't double checked if I have everything in there that you need, but there is at least a good part of it. This should give you some direction. If necessary I could try to fill more stuff in, but I have to head out to a baby naming this afternoon and have a six hour drive tomorrow, so I'm leaving it at this for now. Good luck

          Please do not read this signature.

          S Offline
          S Offline
          Spawn Melmac
          wrote on last edited by
          #4

          Thank you for the suggestions. Modeless sounds like it could be what I need to do. I will experiment with your suggestions.

          Alan

          S 1 Reply Last reply
          0
          • S Spawn Melmac

            Thank you for the suggestions. Modeless sounds like it could be what I need to do. I will experiment with your suggestions.

            Alan

            S Offline
            S Offline
            Spawn Melmac
            wrote on last edited by
            #5

            Thank you for the suggestions and Modeless certainly works to a point. Sorry if I am being a newbie but I have spent most of my time deep behind the UI so this is all a bit of a novelty. The problem I have now is that when I spawn the modeless dialogs, overlapping them causes painting issues. i.e. each dialog becomes contaminted with whatever was infront of it when it takes focus. Oddly this is does not happen on Windows 7 which is my development platform. Now I am assuming this is because I am not handling the change in focus correctly, which I am looking into, but any suggestions? I have to be able to spawn between 2 and 255 of my modeless dialogs (yes I know it is a lot) and be sure that they all repaint correctly.

            Alan

            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