Hiding stuff II - The Static

How can I hide a group box, static text etc.  
thanks
LVL 1
The_BrainAsked:
Who is Participating?
 
thresher_sharkCommented:
Yes, yes, I am a little slow.  I have very little spare time.  Sorry for keeping you waiting.
0
 
MirkwoodCommented:
DIdn't I give you this answer yesterday?
Use ShowWindow.
0
 
The_BrainAuthor Commented:
no, I want to hide STATIC and GROUP as well.  I know that you told me yesterday.  but that was for Edit control combo, list custum etc.  but Not static text, group etc.  (which have no predifined classes.) (how can I safely add a class for static text.  (static text is not a hell of a problem, If I can't get it I will use a flat read only textbox.  But the GROUP thing I need to hide.  thanks


0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
thresher_sharkCommented:
Try the following:

1) Rename the ID of the static control to something other than ID_STATIC like ID_MYSTATIC (yeah, sure, but you get the idea :-).

2) Then use, GetDlgItem (ID_MYSTATIC)->EnableWindow (FALSE);

Does that work?
0
 
MirkwoodCommented:
You can still use showwindow on a group or a static. Similar like thresher_shark said. Just get the hwnd of the groupbox or static and call ShowWindow on this hwnd.
0
 
The_BrainAuthor Commented:
I will try it  ...  thanks :)
0
 
TallBoyCommented:
Here's a code snippet.  Basically, the dialog controls can be named anything you want.  If they are STATIC, just rename 'em.
SW_SHOW will make them visible and SW_HIDE will hide them.

------------------------------------------
if( iShow )
{
  GetDlgItem( IDC_OUT1 )    -> ShowWindow( SW_SHOW );
  GetDlgItem( IDC_ONADA )   -> ShowWindow( SW_SHOW );
  GetDlgItem( IDC_OCLOSE )  -> ShowWindow( SW_SHOW );
}
else
{
  GetDlgItem( IDC_OUT1 )    -> ShowWindow( SW_HIDE );
  GetDlgItem( IDC_ONADA )   -> ShowWindow( SW_HIDE );
  GetDlgItem( IDC_OCLOSE )  -> ShowWindow( SW_HIDE );
}
UpdateData( TRUE );             // Update The Dialog

0
 
MirkwoodCommented:
Oh, tallboy. It's not very nice to take somebody elses suggestion and post it as an answer.
0
 
TallBoyCommented:
If it was "answered", then why didn't you close the question?

Frankly, I only skimmed the others' responses to see if someone had bothered to post some example code -- code which I'd written a few years before.

If you don't want to use my code, then don't -- I promise I won't cry into my pillow over it.
0
 
The_BrainAuthor Commented:
Since you promised, I will reject it, because I feel what you did was wrong anyway.   (even though I know what you are saying.)
You should realise that commenting is sometimes the unselfish way of giving an answer, giving the user a chance to see other expert opinions.  (I have not tried any of the answers out yet, but I am sure that if you are right then Shark is right, because he posted the best code in "context" (no offence, but I dislike recieving code snippets which is a pain to convert to your program just to get it to work) (i know that this wouldn't be such a pain :^)

So please post an answer Shark, and if it works I will accept it first thing in the morning, (13:00 h from now.) thanks...
(could you perhaps tell me exactly how to go about this, (just in case I can't do it tommorow, I don't wanna have to wait another few hours if I could have asked now.)
just say where, how, and whereelse. then (run-time hide/show.)

thanks a billion.  (Sorry tallboy, no grudge held, it is only fair that Shark gets it.)

P.S Shark could you please delete my minesweeper question, thanks.
0
 
The_BrainAuthor Commented:
Actually, after renaming it, I can give it a class name, and do
m_Static1.ShowWindow(SW_HIDE);

(this works, and yours)

Technically speaking tallboy's answer is Correct.  (Sorry Tallboy, please send an answer. (Sorry Shark, TallBoy is right.  with his answer.)  

EnableWindow does not have the disired effect.
0
 
thresher_sharkCommented:
Whoopsy, I meant GetDlgItem (ID_MYSTATIC)->ShowWindow (SW_HIDE);

You see, I copied the code out of a program I wrote a while ago, and since it was just after I woke up, I apparently missed the error.  Let me guess, the static text became grayed out? :-)
0
 
thresher_sharkCommented:
Also, yes, you can attached a CStatic control to the resource, and then call ShowWindow in that method.  As you have found, either way will work.

If you still want TallBoy to answer, that is fine with me.  It makes little difference as long as you got a solution that works.
0
 
The_BrainAuthor Commented:
You can have it, I realise that you have made a typo.  So please answer, I was tired when I tried your solution :^)
besides I don't think tallboy is comming back soon.


thanks for being so considirate, YOU have the right attitude and rightly deserve the points :^) please collect it.
0
 
The_BrainAuthor Commented:
go on Shark take the answer :^) I am waiting...
0
 
The_BrainAuthor Commented:
Dere U go.  tanks so mutch, (I have used this feature extensively(to hide and show))
0
 
thresher_sharkCommented:
Glad you have it working :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.