Problem using MFC to create multiple CDialog threads
-
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
-
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
sounds like you need modeless dialogs[^].
-
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
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.
-
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.
Thank you for the suggestions. Modeless sounds like it could be what I need to do. I will experiment with your suggestions.
Alan
-
Thank you for the suggestions. Modeless sounds like it could be what I need to do. I will experiment with your suggestions.
Alan
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