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. Using CWnd windows and controls

Using CWnd windows and controls

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialc++helpquestionlearning
8 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.
  • 4 Offline
    4 Offline
    4288
    wrote on last edited by
    #1

    Hi all, I need to create a child dialog for my mfc dialog-based application but I don't want to use a resource template, so I decided to create a CWnd derived class and create there my window and controls. I can't find on the entire web one good example, can you be so kind to link me some guide or explain me how to create a dialog using CWnd derived class and how to manage its events (paint, lmouseclick, etc..) please? Thanks for any help, a newbie

    ---

    M 1 Reply Last reply
    0
    • 4 4288

      Hi all, I need to create a child dialog for my mfc dialog-based application but I don't want to use a resource template, so I decided to create a CWnd derived class and create there my window and controls. I can't find on the entire web one good example, can you be so kind to link me some guide or explain me how to create a dialog using CWnd derived class and how to manage its events (paint, lmouseclick, etc..) please? Thanks for any help, a newbie

      ---

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

      4288 wrote:

      how to create a dialog using CWnd derived class

      The derived class you want to use is CDialog. ;P What features of a dialog are you looking for if you're not using a dialog template? With MFC and Visual Studio, you can create a CWnd-derived class and add message handlers all with a few clicks of the mouse (and a little typing to give your class a name). Mark

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

      4 1 Reply Last reply
      0
      • M Mark Salsbery

        4288 wrote:

        how to create a dialog using CWnd derived class

        The derived class you want to use is CDialog. ;P What features of a dialog are you looking for if you're not using a dialog template? With MFC and Visual Studio, you can create a CWnd-derived class and add message handlers all with a few clicks of the mouse (and a little typing to give your class a name). Mark

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

        4 Offline
        4 Offline
        4288
        wrote on last edited by
        #3

        I need to create a simple child window (a frame in the right of my parent's area) and I need to add some combo boxes and label (these controls change by user's preferences so they are not a fixed number) I thought creating the child window dynamically without res template, adding dynamically controls based on user's preferences was a good idea Otherwise i should implement almost 12 child template windows ._.!! If you need clarifies, I could try to give more info Thanks

        ---

        M 1 Reply Last reply
        0
        • 4 4288

          I need to create a simple child window (a frame in the right of my parent's area) and I need to add some combo boxes and label (these controls change by user's preferences so they are not a fixed number) I thought creating the child window dynamically without res template, adding dynamically controls based on user's preferences was a good idea Otherwise i should implement almost 12 child template windows ._.!! If you need clarifies, I could try to give more info Thanks

          ---

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

          You can create the controls at runtime, but you have to do the positioning yourself. Another method (if it applies to this) would be to use a dialog resource with all the controls you need, but the controls are hidden.  At runtime you can make the appropriate controls visible and reposition them easier because the layout is already partially done for you. Mark

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

          4 N 2 Replies Last reply
          0
          • M Mark Salsbery

            You can create the controls at runtime, but you have to do the positioning yourself. Another method (if it applies to this) would be to use a dialog resource with all the controls you need, but the controls are hidden.  At runtime you can make the appropriate controls visible and reposition them easier because the layout is already partially done for you. Mark

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

            4 Offline
            4 Offline
            4288
            wrote on last edited by
            #5

            I definitely prefer placing controls by myself, but how to get Onclick event handler for a CStatic control for example? Have I to use a derived class?

            ---

            M 1 Reply Last reply
            0
            • 4 4288

              I definitely prefer placing controls by myself, but how to get Onclick event handler for a CStatic control for example? Have I to use a derived class?

              ---

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

              4288 wrote:

              how to get Onclick event handler for a CStatic control for example? Have I to use a derived class?

              With MFC, a CStatic-derived class is simpler.  Just add a WM_LBUTTONDOWN handler. Mark

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

              4 1 Reply Last reply
              0
              • M Mark Salsbery

                4288 wrote:

                how to get Onclick event handler for a CStatic control for example? Have I to use a derived class?

                With MFC, a CStatic-derived class is simpler.  Just add a WM_LBUTTONDOWN handler. Mark

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

                4 Offline
                4 Offline
                4288
                wrote on last edited by
                #7

                thanks for the advice!

                ---

                1 Reply Last reply
                0
                • M Mark Salsbery

                  You can create the controls at runtime, but you have to do the positioning yourself. Another method (if it applies to this) would be to use a dialog resource with all the controls you need, but the controls are hidden.  At runtime you can make the appropriate controls visible and reposition them easier because the layout is already partially done for you. Mark

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

                  N Offline
                  N Offline
                  Nelek
                  wrote on last edited by
                  #8

                  Yes, and change the size of the window / dialog to adapt it to the shown controls as well. I mean, 5 controls = one size, 10 controls = another size and so on. It is the easiest way.

                  Greetings. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson

                  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