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. Dialog box focus

Dialog box focus

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
11 Posts 5 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.
  • A Offline
    A Offline
    aangerma
    wrote on last edited by
    #1

    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

    L _ 2 Replies Last reply
    0
    • A aangerma

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • A aangerma

        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

        _ Offline
        _ Offline
        _AnsHUMAN_
        wrote on last edited by
        #3

        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

        A 1 Reply Last reply
        0
        • _ _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

          A Offline
          A Offline
          aangerma
          wrote on last edited by
          #4

          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

          M C L 3 Replies Last reply
          0
          • A aangerma

            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

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

            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.

            C 1 Reply Last reply
            0
            • M Maximilien

              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.

              C Offline
              C Offline
              Chandrasekharan P
              wrote on last edited by
              #6

              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.

              M 1 Reply Last reply
              0
              • C Chandrasekharan P

                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.

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

                Yes, you can; but if the user experiment another behavior, there is a bigger issue.

                Watched code never compiles.

                1 Reply Last reply
                0
                • A aangerma

                  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

                  C Offline
                  C Offline
                  Chandrasekharan P
                  wrote on last edited by
                  #8

                  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.

                  1 Reply Last reply
                  0
                  • A aangerma

                    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

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    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.

                    A 1 Reply Last reply
                    0
                    • L Lost User

                      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.

                      A Offline
                      A Offline
                      aangerma
                      wrote on last edited by
                      #10

                      can you explain me what does it mean 'modeless dialog', and how can I change it? thanks

                      C 1 Reply Last reply
                      0
                      • A aangerma

                        can you explain me what does it mean 'modeless dialog', and how can I change it? thanks

                        C Offline
                        C Offline
                        Chandrasekharan P
                        wrote on last edited by
                        #11

                        Have a look at the below links Tutorial - Modeless Dialogs with MFC[^] Create a modeless dialog box as child window[^]

                        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