Dialog box focus
-
Hello, I am writing a program using VC++ with MFC, I added some dialog boxes and I want that once one of the dialog is opened by DoModal() all the buttons on the parent dialog will be disabled, How can I do it? thanks Avishag
In the dialog's OnInitDialog[^] function, you can call EnableWindow[^] on each control. This is assuming you want the greyed look of the controls; a modal dialog with a parent window automatically disables the parent window until the dialog is closed.
-
Hello, I am writing a program using VC++ with MFC, I added some dialog boxes and I want that once one of the dialog is opened by DoModal() all the buttons on the parent dialog will be disabled, How can I do it? thanks Avishag
Just a query: Why do you want to disable the controls on the parent dialog i.e. only for the look and feel?. Since the dialog being popped up is a result of the DoModal thing, the hit on the parent dialog will not work unless you dismiss the popped dialog. On the other hand as suggested with the parent dialog pointer you can disable the control on it in the InitDialog of the dialog being popped up.
You talk about Being HUMAN. I have it in my name AnsHUMAN
-
Just a query: Why do you want to disable the controls on the parent dialog i.e. only for the look and feel?. Since the dialog being popped up is a result of the DoModal thing, the hit on the parent dialog will not work unless you dismiss the popped dialog. On the other hand as suggested with the parent dialog pointer you can disable the control on it in the InitDialog of the dialog being popped up.
You talk about Being HUMAN. I have it in my name AnsHUMAN
thanks for the replay, I have a dialog that has a menu and clicking on the menu items causes to open other dialogs by DoModal(); The problem is that, while one dialog is opened the user can click other menu items and open more dialogs and its causes me a mess. How can I declare that the main dialog will be a parents of the other dialogs? thanks again
-
thanks for the replay, I have a dialog that has a menu and clicking on the menu items causes to open other dialogs by DoModal(); The problem is that, while one dialog is opened the user can click other menu items and open more dialogs and its causes me a mess. How can I declare that the main dialog will be a parents of the other dialogs? thanks again
aangerma wrote:
The problem is that, while one dialog is opened the user can click other menu items and open more dialogs and its causes me a mess.
Are you certain you are calling
DoModal
? If the dialog is modal (DoModal
) the parent window should not be active and the user should not be able to click on other menus/buttons. If that is happening, you have other issues to fix.Watched code never compiles.
-
aangerma wrote:
The problem is that, while one dialog is opened the user can click other menu items and open more dialogs and its causes me a mess.
Are you certain you are calling
DoModal
? If the dialog is modal (DoModal
) the parent window should not be active and the user should not be able to click on other menus/buttons. If that is happening, you have other issues to fix.Watched code never compiles.
Maximilien wrote:
indow should not be active and the user should not be able to click on other menus/buttons.
Can i correct it as If the dialog is modal (DoModal) the parent window will not be active and the user will not be able to click on other menus/buttons.
-
Maximilien wrote:
indow should not be active and the user should not be able to click on other menus/buttons.
Can i correct it as If the dialog is modal (DoModal) the parent window will not be active and the user will not be able to click on other menus/buttons.
Yes, you can; but if the user experiment another behavior, there is a bigger issue.
Watched code never compiles.
-
thanks for the replay, I have a dialog that has a menu and clicking on the menu items causes to open other dialogs by DoModal(); The problem is that, while one dialog is opened the user can click other menu items and open more dialogs and its causes me a mess. How can I declare that the main dialog will be a parents of the other dialogs? thanks again
I have a doubt that you are using DoModal. If that was the case as Maximilien told in the last mail you will not have access to the parent dialog. Looks like you are using Modeless Dialog.
-
thanks for the replay, I have a dialog that has a menu and clicking on the menu items causes to open other dialogs by DoModal(); The problem is that, while one dialog is opened the user can click other menu items and open more dialogs and its causes me a mess. How can I declare that the main dialog will be a parents of the other dialogs? thanks again
-
As Chandru080 wrote, using a modeless dialog would explain this behaviour. Alternatively, if the parent window handle is invalid or NULL, the result would be the same. Could you post the relevant code please? It should be possible to say for sure then.
-
Have a look at the below links Tutorial - Modeless Dialogs with MFC[^] Create a modeless dialog box as child window[^]