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

    Dynamic Controls

    I am writing a reusable class based on CEdit and everything seems to be working OK except that the control does not appear as 3D when created dynamically in a dialog (i.e. no resource ID) but rather appears as a plain old Win16 edit box. The control does appear as 3D when used in a dialog with an associated resource ID.

    I would like to create a good framework for dynamic dialgs without having to mess with the resource editor.

    BTW, Can anyone point me to a good book or website dealing with creating controls dynamically at runtime?

    TIA


  2. #2
    Join Date
    Apr 1999
    Location
    Norway
    Posts
    19

    Re: Dynamic Controls

    Hello!

    I had the same problem with editbox created dynamiclly. It disappeared when I followed the following style.

    void CPropEdit::Create(DWORD style, const RECT &rect, CWnd *pParentWnd, int nNewIndex)
    {
    CreateEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_TABSTOP | ES_AUTOHSCROLL | style, rect, pParentWnd, 0);
    SetFont(pParentWnd->GetFont(), FALSE);

    nIndex=nNewIndex;
    }

    Here I used nIndex to keep track of componentindexes in the dialog.

    Good luck
    Hussam


  3. #3
    Join Date
    May 1999
    Posts
    116

    Re: Dynamic Controls

    I came across the same problem before with a custom (CEdit based) control we use at work. I found that by hiding and re-showing it that it drew properly.CMyEdit myEdit;
    myEdit.Create(.........);
    myEdit.ShowWindow(SW_HIDE);
    myEdit.ShowWindow(SW_SHOW);

    Ugly, but it worked.



  4. #4
    Join Date
    May 1999
    Posts
    14

    Re: Dynamic Controls

    Many thanks, it worked like a charm!


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