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. Dymanic windows

Dymanic windows

Scheduled Pinned Locked Moved C / C++ / MFC
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
    Alton Williams
    wrote on last edited by
    #1

    I would like to know how create child windows at runtime and get them all displyed Yes I've used:

    • a pointer for the control
    • the new operator for the window type
    • CWnd::Create method
    • CWnd::ShowWindow method
    • CWnd::MoveWindow method

    All I'm getting is a blank dialog box. I can't understand why. What do I have to do display them?

    J D M 3 Replies Last reply
    0
    • A Alton Williams

      I would like to know how create child windows at runtime and get them all displyed Yes I've used:

      • a pointer for the control
      • the new operator for the window type
      • CWnd::Create method
      • CWnd::ShowWindow method
      • CWnd::MoveWindow method

      All I'm getting is a blank dialog box. I can't understand why. What do I have to do display them?

      J Offline
      J Offline
      Jens Doose
      wrote on last edited by
      #2

      Please show us a little bit of your source code...

      A 1 Reply Last reply
      0
      • A Alton Williams

        I would like to know how create child windows at runtime and get them all displyed Yes I've used:

        • a pointer for the control
        • the new operator for the window type
        • CWnd::Create method
        • CWnd::ShowWindow method
        • CWnd::MoveWindow method

        All I'm getting is a blank dialog box. I can't understand why. What do I have to do display them?

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

        Most of the time, creating controls at runtime is not necessary. Can you explain a bit more of what you are doing?


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        A 1 Reply Last reply
        0
        • A Alton Williams

          I would like to know how create child windows at runtime and get them all displyed Yes I've used:

          • a pointer for the control
          • the new operator for the window type
          • CWnd::Create method
          • CWnd::ShowWindow method
          • CWnd::MoveWindow method

          All I'm getting is a blank dialog box. I can't understand why. What do I have to do display them?

          M Offline
          M Offline
          marcosvpp
          wrote on last edited by
          #4

          Yes, I understand!! I'm trying to create a MenuBar at runtime but all itens in the menu is GRAYED (disabled) when created!!! I don't know why?!?!? Maybe some help in your doubt helps in mine!!! :) Thanks Marcos Vinícius

          J 1 Reply Last reply
          0
          • J Jens Doose

            Please show us a little bit of your source code...

            A Offline
            A Offline
            Alton Williams
            wrote on last edited by
            #5

            This is a snippets of my code in the dialog header file class CMyDialouge : public CDialog{ public CEdit *m_EditWnd; CRect m_WndRect; }; The dialog's constructor CMyDialouge::CMyDialouge(CWnd* pParent /*=NULL*/) : CDialog(CMyDialogue::IDD, pParent) { m_EditWnd = NULL; m_Rect = CRect(23,30,54,14); } Create 5 versions of the edit control BOOL CMyDialouge::OnInitDialog() { // TODO: Add extra initialization here this->m_EditWnd = new CEdit[5]; for(int i = 0; i < 5; i++) { m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i); m_EditWnd[i].MoveWindow(m_Rect); m_EditWnd[i].ShowWindow(SW_SHOW); m_Rect.top += 30; } return TRUE; // return TRUE unless you set the focus to a control } void CMyDialouge::OnDestroy { for (int i=0; i <5; i++) m_EditWnd[i].DestroyWindow(); CDialog::OnDestroy(); // TODO: Add your message handler code here delete[] m_EditWnd; } I hope I've clarified it. Thanks Alton

            J 1 Reply Last reply
            0
            • D David Crow

              Most of the time, creating controls at runtime is not necessary. Can you explain a bit more of what you are doing?


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              A Offline
              A Offline
              Alton Williams
              wrote on last edited by
              #6

              I just wanted to play around with dynamic controls I've given code snippets in the reply before yours. Thanks Alton

              1 Reply Last reply
              0
              • A Alton Williams

                This is a snippets of my code in the dialog header file class CMyDialouge : public CDialog{ public CEdit *m_EditWnd; CRect m_WndRect; }; The dialog's constructor CMyDialouge::CMyDialouge(CWnd* pParent /*=NULL*/) : CDialog(CMyDialogue::IDD, pParent) { m_EditWnd = NULL; m_Rect = CRect(23,30,54,14); } Create 5 versions of the edit control BOOL CMyDialouge::OnInitDialog() { // TODO: Add extra initialization here this->m_EditWnd = new CEdit[5]; for(int i = 0; i < 5; i++) { m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i); m_EditWnd[i].MoveWindow(m_Rect); m_EditWnd[i].ShowWindow(SW_SHOW); m_Rect.top += 30; } return TRUE; // return TRUE unless you set the focus to a control } void CMyDialouge::OnDestroy { for (int i=0; i <5; i++) m_EditWnd[i].DestroyWindow(); CDialog::OnDestroy(); // TODO: Add your message handler code here delete[] m_EditWnd; } I hope I've clarified it. Thanks Alton

                J Offline
                J Offline
                Jens Doose
                wrote on last edited by
                #7

                In CMyDialouge::OnInitDialog() you wrote m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i); m_EditWnd[i].MoveWindow(m You used m_EditBox AND m_EditWnd, may it be that this is your mistake? Jens

                A 1 Reply Last reply
                0
                • M marcosvpp

                  Yes, I understand!! I'm trying to create a MenuBar at runtime but all itens in the menu is GRAYED (disabled) when created!!! I don't know why?!?!? Maybe some help in your doubt helps in mine!!! :) Thanks Marcos Vinícius

                  J Offline
                  J Offline
                  Jens Doose
                  wrote on last edited by
                  #8

                  If your using MFC one of the more common mistakes is that there is no command handler yet. In that case MFC grayes all the unavailable menu commands. Jens

                  L 1 Reply Last reply
                  0
                  • J Jens Doose

                    In CMyDialouge::OnInitDialog() you wrote m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i); m_EditWnd[i].MoveWindow(m You used m_EditBox AND m_EditWnd, may it be that this is your mistake? Jens

                    A Offline
                    A Offline
                    Alton Williams
                    wrote on last edited by
                    #9

                    Jens Doose wrote: m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i); Correct to (compiler will complain): m_EditWnd[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i);

                    J 1 Reply Last reply
                    0
                    • A Alton Williams

                      Jens Doose wrote: m_EditBox[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i); Correct to (compiler will complain): m_EditWnd[i].Create(WS_CHILD|ES_MULTILINE| WS_VISIBLE|ES_WANTRETURN,CRect(0,0,0,0),this,1000 + i);

                      J Offline
                      J Offline
                      Jens Doose
                      wrote on last edited by
                      #10

                      You used CRect(23,30,54,14); as the location to move the window to. This statement create a rect with the following settings:

                      - m_Rect {top=30 bottom=14 left=23 right=54}

                      • tagRECT {top=30 bottom=14 left=23 right=54}
                        left 23
                        top 30
                        right 54
                        bottom 14

                      Since "bottom" is less than "top" this is a rect with a negativ height. I am pretty sure that was not your intention, was it? ;-) Jens

                      1 Reply Last reply
                      0
                      • J Jens Doose

                        If your using MFC one of the more common mistakes is that there is no command handler yet. In that case MFC grayes all the unavailable menu commands. Jens

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

                        But, why is it unavailable? I can't just put a Message_Map in my class that handle the App MenuBar and that will enable the MenuItens? Take a look in my last thread posted: Menu at runtime (dynamic menu) Thanks. Marcos Vinícius

                        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