Click to See Complete Forum and Search --> : Making a control Visible


John Hagen
April 27th, 1999, 02:05 AM
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

Rail Jon Rogut
April 27th, 1999, 02:13 AM
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
railro@earthlink.net
http://home.earthlink.net/~railro/

tchung
April 27th, 1999, 02:21 AM
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

John Hagen
April 27th, 1999, 02:21 AM
Thanks for the input. I appreciate your tiome and effort. It worked great!

John