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. Re: TextBox creation, w/o resource editor?

Re: TextBox creation, w/o resource editor?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelplearning
11 Posts 4 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.
  • M mla154

    Hello, The check boxes provided in the resource editor are pretty, but I would like to create check boxes without using the resource editor (dynamically). How do I do this? Any help is appreciated.

    P Offline
    P Offline
    prasad_som
    wrote on last edited by
    #2

    Need to use CButton class with BS_CHECKBOX style . e.g.

    // Create check box.
    m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX,
    CRect(10,10,100,30), pParentWnd, 1);

    Prasad Notifier using ATL | Operator new[],delete[][^]

    M 1 Reply Last reply
    0
    • P prasad_som

      Need to use CButton class with BS_CHECKBOX style . e.g.

      // Create check box.
      m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX,
      CRect(10,10,100,30), pParentWnd, 1);

      Prasad Notifier using ATL | Operator new[],delete[][^]

      M Offline
      M Offline
      mla154
      wrote on last edited by
      #3

      Hello, I put the following code into CPrintOptionsDlg::OnInitDialog() CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX, CRect(0,0,10,30), this, 1); However, I didn't see the check box. Any ideas? My CPrintOptionsDlg class is derived from CDialog.

      M P 2 Replies Last reply
      0
      • M mla154

        Hello, I put the following code into CPrintOptionsDlg::OnInitDialog() CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX, CRect(0,0,10,30), this, 1); However, I didn't see the check box. Any ideas? My CPrintOptionsDlg class is derived from CDialog.

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

        mla154 wrote:

        I put the following code into CPrintOptionsDlg::OnInitDialog()

        Did you call CDialog::OnInitDialog() before creating the button?

        M 1 Reply Last reply
        0
        • M Mark Salsbery

          mla154 wrote:

          I put the following code into CPrintOptionsDlg::OnInitDialog()

          Did you call CDialog::OnInitDialog() before creating the button?

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

          Yes, I did. My function looks like this: BOOL CPrintOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE/*|BS_CHECKBOX*/, CRect(0,0,10,30), this, 1); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }

          M 1 Reply Last reply
          0
          • M mla154

            Yes, I did. My function looks like this: BOOL CPrintOptionsDlg::OnInitDialog() { CDialog::OnInitDialog(); CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE/*|BS_CHECKBOX*/, CRect(0,0,10,30), this, 1); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }

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

            your CButton object is going out of scope (so it is destroyed) when the OnInitDialog() method returns. Try moving CButton m_Button; to your class definition (so it's a member of your CPrintOptionsDlg class).

            M 1 Reply Last reply
            0
            • M mla154

              Hello, The check boxes provided in the resource editor are pretty, but I would like to create check boxes without using the resource editor (dynamically). How do I do this? Any help is appreciated.

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

              Try this

              CButton m_Button;
              m_Button.Create("Test",WS_CHILD|BS_AUTOCHECKBOX|WS_VISIBLE,CRect(0,0,100,23),this,1);
              

              WhiteSky


              1 Reply Last reply
              0
              • M Mark Salsbery

                your CButton object is going out of scope (so it is destroyed) when the OnInitDialog() method returns. Try moving CButton m_Button; to your class definition (so it's a member of your CPrintOptionsDlg class).

                M Offline
                M Offline
                mla154
                wrote on last edited by
                #8

                It works. Thanks.

                1 Reply Last reply
                0
                • M mla154

                  Hello, I put the following code into CPrintOptionsDlg::OnInitDialog() CButton m_Button; // Create check box. m_Button.Create(_T("Check Box"), WS_CHILD |WS_VISIBLE|BS_CHECKBOX, CRect(0,0,10,30), this, 1); However, I didn't see the check box. Any ideas? My CPrintOptionsDlg class is derived from CDialog.

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #9

                  I've mentioned CButton variable name as m_Button, which implies its a class member variable.

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  M 1 Reply Last reply
                  0
                  • P prasad_som

                    I've mentioned CButton variable name as m_Button, which implies its a class member variable.

                    Prasad Notifier using ATL | Operator new[],delete[][^]

                    M Offline
                    M Offline
                    mla154
                    wrote on last edited by
                    #10

                    It worked, thanks.

                    P 1 Reply Last reply
                    0
                    • M mla154

                      It worked, thanks.

                      P Offline
                      P Offline
                      prasad_som
                      wrote on last edited by
                      #11

                      My Pleasure. :)

                      Prasad Notifier using ATL | Operator new[],delete[][^]

                      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