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 add Button to Child Window ?

How to add Button to Child Window ?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
13 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.
  • T Offline
    T Offline
    tina newcoder
    wrote on last edited by
    #1

    Hi friends, plz tell me how can I add controls like -> Buttons to the Child Window. :confused: I have created a SDI, I now I want to add some text to it, & also some button to take input from the users, plzzz tell me how to to this... :~ Thanx in advance ...

    H D 2 Replies Last reply
    0
    • T tina newcoder

      Hi friends, plz tell me how can I add controls like -> Buttons to the Child Window. :confused: I have created a SDI, I now I want to add some text to it, & also some button to take input from the users, plzzz tell me how to to this... :~ Thanx in advance ...

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Can you use of CreateWindow or CButton class?

      1 Reply Last reply
      0
      • T tina newcoder

        Hi friends, plz tell me how can I add controls like -> Buttons to the Child Window. :confused: I have created a SDI, I now I want to add some text to it, & also some button to take input from the users, plzzz tell me how to to this... :~ Thanx in advance ...

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        tina- wrote:

        I have created a SDI...

        What class is the view derived from?

        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        T 2 Replies Last reply
        0
        • D David Crow

          tina- wrote:

          I have created a SDI...

          What class is the view derived from?

          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          T Offline
          T Offline
          tina newcoder
          wrote on last edited by
          #4

          i have used the following code CButton mybutton; RECT r; r.left=100; r.top=100; r.right=500; r.bottom=500; mybutton.Create("Button",BS_CHECKBOX ,r,this,100); mybutton.Invalidate(); mybutton.UpdateWindow(); mybutton.ShowWindow(SW_SHOW);

          D 1 Reply Last reply
          0
          • D David Crow

            tina- wrote:

            I have created a SDI...

            What class is the view derived from?

            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            T Offline
            T Offline
            tina newcoder
            wrote on last edited by
            #5

            DavidCrow wrote:

            What class is the view derived from?

            -> CWnd

            D 1 Reply Last reply
            0
            • T tina newcoder

              i have used the following code CButton mybutton; RECT r; r.left=100; r.top=100; r.right=500; r.bottom=500; mybutton.Create("Button",BS_CHECKBOX ,r,this,100); mybutton.Invalidate(); mybutton.UpdateWindow(); mybutton.ShowWindow(SW_SHOW);

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              tina- wrote:

              mybutton.Create("Button",BS_CHECKBOX ,r,this,100);

              What is this?

              "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              T 1 Reply Last reply
              0
              • T tina newcoder

                DavidCrow wrote:

                What class is the view derived from?

                -> CWnd

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Of course it is, just like any UI component. But more specifically, what class is the view derived from?

                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                T 1 Reply Last reply
                0
                • D David Crow

                  tina- wrote:

                  mybutton.Create("Button",BS_CHECKBOX ,r,this,100);

                  What is this?

                  "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  T Offline
                  T Offline
                  tina newcoder
                  wrote on last edited by
                  #8

                  DavidCrow wrote:

                  What is this?

                  pointer to the parent window, or is that the place i m committing mistake ? how shall i get the pointer to the parent window ?

                  D T 2 Replies Last reply
                  0
                  • T tina newcoder

                    DavidCrow wrote:

                    What is this?

                    pointer to the parent window, or is that the place i m committing mistake ? how shall i get the pointer to the parent window ?

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    tina- wrote:

                    pointer to the parent window...

                    Which is a?

                    "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    1 Reply Last reply
                    0
                    • T tina newcoder

                      DavidCrow wrote:

                      What is this?

                      pointer to the parent window, or is that the place i m committing mistake ? how shall i get the pointer to the parent window ?

                      T Offline
                      T Offline
                      tina newcoder
                      wrote on last edited by
                      #10

                      void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CButton mybutton; RECT r; r.left=100; r.top=100; r.right=500; r.bottom=500; mybutton.Create("Button",BS_CHECKBOX ,r,this,100); mybutton.Invalidate(); mybutton.UpdateWindow(); mybutton.ShowWindow(SW_SHOW); // Do not call CWnd::OnPaint() for painting messages }

                      1 Reply Last reply
                      0
                      • D David Crow

                        Of course it is, just like any UI component. But more specifically, what class is the view derived from?

                        "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        T Offline
                        T Offline
                        tina newcoder
                        wrote on last edited by
                        #11

                        DavidCrow wrote:

                        Of course it is, just like any UI component. But more specifically, what class is the view derived from?

                        it is like this ... class CChildView : public CWnd

                        D 1 Reply Last reply
                        0
                        • T tina newcoder

                          DavidCrow wrote:

                          Of course it is, just like any UI component. But more specifically, what class is the view derived from?

                          it is like this ... class CChildView : public CWnd

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #12

                          Normally, a view is derived from CView. With your requirement of wanting a button on it, why not use CFormView instead?

                          "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                          T 1 Reply Last reply
                          0
                          • D David Crow

                            Normally, a view is derived from CView. With your requirement of wanting a button on it, why not use CFormView instead?

                            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                            T Offline
                            T Offline
                            tina newcoder
                            wrote on last edited by
                            #13

                            is my code void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CButton mybutton; RECT r; r.left=100; r.top=100; r.right=500; r.bottom=500; mybutton.Create("Button",BS_CHECKBOX ,r,this,100); mybutton.Invalidate(); mybutton.UpdateWindow(); mybutton.ShowWindow(SW_SHOW); // Do not call CWnd::OnPaint() for painting messages } correct enough to display a button ???

                            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