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. How to use the same class for two dialogs? (avoiding IDD clash...)

How to use the same class for two dialogs? (avoiding IDD clash...)

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionannouncement
7 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.
  • L Offline
    L Offline
    largeinsd
    wrote on last edited by
    #1

    Hi, I am creating a class for a dialog that can be used either in modal or modeless form, and I would like to use them both at the same time in a dialog-based app. The complication is that the modal form and the modeless form use different resources (modal form has an 'OK' and 'Cancel' button, modeless does not) wondering if it's possible to use them in the same application since VS2005 puts the following line in CDialog-derived classes: [code] // Dialog Data enum { IDD = IDD_DX9MATERIAL_DIALOG }; [/code] which seems to tie the class to the dialog, no? Is it not possible to the use the same class for two dialogs? Or should I just create another version of the class for the two types of docs? Thanks - @LRG

    M 1 Reply Last reply
    0
    • L largeinsd

      Hi, I am creating a class for a dialog that can be used either in modal or modeless form, and I would like to use them both at the same time in a dialog-based app. The complication is that the modal form and the modeless form use different resources (modal form has an 'OK' and 'Cancel' button, modeless does not) wondering if it's possible to use them in the same application since VS2005 puts the following line in CDialog-derived classes: [code] // Dialog Data enum { IDD = IDD_DX9MATERIAL_DIALOG }; [/code] which seems to tie the class to the dialog, no? Is it not possible to the use the same class for two dialogs? Or should I just create another version of the class for the two types of docs? Thanks - @LRG

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      @largeinsd wrote:

      which seems to tie the class to the dialog, no?

      Yes. It's only source code....feel free to alter it for your own use :) The IDD is used only one place by default - it is passed to the CDialog constructor. With a little modification you can pass whatever resource ID you want to the base class. Another alternative in this case, is to use one resource and show or hide the two buttons depending on if the dialog is used modal or modeless. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      L 1 Reply Last reply
      0
      • M Mark Salsbery

        @largeinsd wrote:

        which seems to tie the class to the dialog, no?

        Yes. It's only source code....feel free to alter it for your own use :) The IDD is used only one place by default - it is passed to the CDialog constructor. With a little modification you can pass whatever resource ID you want to the base class. Another alternative in this case, is to use one resource and show or hide the two buttons depending on if the dialog is used modal or modeless. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        L Offline
        L Offline
        largeinsd
        wrote on last edited by
        #3

        Mark Salsbery wrote:

        Another alternative in this case, is to use one resource and show or hide the two buttons depending on if the dialog is used modal or modeless.

        Kaboom! That's why you're the MVP... and I'm just glad we're on the same team. :) Thanks Mark, I will implement that.

        M 1 Reply Last reply
        0
        • L largeinsd

          Mark Salsbery wrote:

          Another alternative in this case, is to use one resource and show or hide the two buttons depending on if the dialog is used modal or modeless.

          Kaboom! That's why you're the MVP... and I'm just glad we're on the same team. :) Thanks Mark, I will implement that.

          M Offline
          M Offline
          Maxwell Chen
          wrote on last edited by
          #4

          @largeinsd wrote:

          I'm just glad we're on the same team.

          What team? :confused:


          Maxwell Chen

          M 1 Reply Last reply
          0
          • M Maxwell Chen

            @largeinsd wrote:

            I'm just glad we're on the same team.

            What team? :confused:


            Maxwell Chen

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            Team MFC/C++! Of course :)

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            M 1 Reply Last reply
            0
            • M Mark Salsbery

              Team MFC/C++! Of course :)

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              M Offline
              M Offline
              Maxwell Chen
              wrote on last edited by
              #6

              Mark Salsbery wrote:

              Team MFC/C++!

              I thought that you and largeinsd were co-woring on some specific project. ;)


              Maxwell Chen

              M 1 Reply Last reply
              0
              • M Maxwell Chen

                Mark Salsbery wrote:

                Team MFC/C++!

                I thought that you and largeinsd were co-woring on some specific project. ;)


                Maxwell Chen

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Heh - nah....I took it more as an expression - same thing as "I'm glad we aren't enemies" or "glad we're not working against each other" :) Cheers, Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                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