Solved

Hiding stuff II - The Static

Posted on 1999-01-13
17
227 Views
Last Modified: 2013-11-20
How can I hide a group box, static text etc.  
thanks
0
Comment
Question by:The_Brain
  • 7
  • 5
  • 3
  • +1
17 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1327614
DIdn't I give you this answer yesterday?
Use ShowWindow.
0
 
LVL 1

Author Comment

by:The_Brain
ID: 1327615
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327616
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
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1327617
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
 
LVL 1

Author Comment

by:The_Brain
ID: 1327618
I will try it  ...  thanks :)
0
 
LVL 2

Expert Comment

by:TallBoy
ID: 1327619
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
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1327620
Oh, tallboy. It's not very nice to take somebody elses suggestion and post it as an answer.
0
 
LVL 2

Expert Comment

by:TallBoy
ID: 1327621
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:The_Brain
ID: 1327622
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
 
LVL 1

Author Comment

by:The_Brain
ID: 1327623
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327624
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327625
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
 
LVL 1

Author Comment

by:The_Brain
ID: 1327626
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
 
LVL 1

Author Comment

by:The_Brain
ID: 1327627
go on Shark take the answer :^) I am waiting...
0
 
LVL 6

Accepted Solution

by:
thresher_shark earned 20 total points
ID: 1327628
Yes, yes, I am a little slow.  I have very little spare time.  Sorry for keeping you waiting.
0
 
LVL 1

Author Comment

by:The_Brain
ID: 1327629
Dere U go.  tanks so mutch, (I have used this feature extensively(to hide and show))
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327630
Glad you have it working :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now