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
    Location
    Oklahoma
    Posts
    263

    Making a control Visible

    I have defaulted a CStatic control to NOT VISIBLE in the actual dialog. My problem is how do I make it visible again under program control, and then be able to make it invisible when I want to hide it again? I know, probably something really easy but, easy is one of those four letter words.

    Thanks in advance!

    John



  2. #2
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Making a control Visible

    Change the Control ID to something other than IDC_STATIC, let's say IDC_STATIC_DESC. Now in ClassWizard, create a member variable of type control for IDC_STATIC_DESC, let's call it m_CtrlStDesc.

    Now in the header file you'll have a public class member:

    CStatic m_CtrlStDesc;

    CStatic is derived from CWnd so it inherits all CWnd's member functions... the one you're looking for is CWnd::ShowWindow()

    So to make the control visible:

    m_CtrlStDesc.ShowWindow(SW_SHOW);

    and to hide it:

    m_CtrlStDesc.ShowWindow(SW_HIDE);

    Hope that helps.

    Rail

    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    [email protected]
    http://home.earthlink.net/~railro/

  3. #3
    Join Date
    Apr 1999
    Location
    SungNam KyungKi Korea
    Posts
    14

    Re: Making a control Visible

    just put this code where you want.

    CStatic *pStatic;
    pStatic=(CStatic *)GetDlgItem(IDC_STATIC1);
    pStatic->ShowWindow(SW_SHOW);




    Is that what you want?. I hope so.


    by nfuox

  4. #4
    Join Date
    May 1999
    Location
    Oklahoma
    Posts
    263

    Re: Making a control Visible

    Thanks for the input. I appreciate your tiome and effort. It worked great!

    John



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