CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    4

    Dynamic Creation of CStatic Control

    I am trying to create some dynamic static controls within a dialog box. I have found one function that works but the other does not. I would like to use Create instead of CreateWindow. Create Window works, Create is not displaying the text.

    Here is the example. Any help would be appreciated.

    int CDynamicDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    if (CDialog::OnCreate(lpCreateStruct) == -1)
    return -1;

    // TODO: Add your specialized creation code here
    // This works
    CreateWindow("static", "Text from CreateWindow", WS_CHILD | WS_VISIBLE,
    10,10,300,20, m_hWnd, (HMENU)11, 0, NULL);

    // This does not work
    CStatic m_Text;
    m_Text.Create(_T("Text From Create"), WS_CHILD | WS_VISIBLE,
    CRect(100,100,300,20), this, 12 );

    return 0;
    }



  2. #2
    Join Date
    May 1999
    Location
    Texas, USA
    Posts
    568

    Re: Dynamic Creation of CStatic Control

    First of all, if your code in the program is exactly like you wrote in the message, CStatic is a local, when it exits the function it destroys itself. Move CStatic declaration to the header file.

    Wayne



  3. #3
    Join Date
    May 1999
    Posts
    4

    Re: Dynamic Creation of CStatic Control

    Thank you, it took care of the problem.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured