Hide a function or variable from the Class View


The Class View displays all the functions defined in a class (even global functions) but it does not provide any means of organizing them. With more and more functions in a class the Class View becomes less and less useful. With too many functions listed you need to scroll more often and it takes a while longer to find the function. We can alleviate the situation by hiding trivial function from the Class View. Functions such as the trivial OnUpdateXXXX functions are ideal candidates.

The Class View (and the Class Wizard and the Wizard Bar) does not support hiding of functions. It, however, preprocess the file and we use use this knowledge to fool it into not recognizing a function. To achieve this we declare a couple of macros to camouflage the parentheses. If there is more than one class that you want to hide functions in, you may want to declare the macros in stdafx.h, otherwise declaring it in the header file for the class is OK.

Make sure you document this in each header file you modify, otherwise your code is going to be a big headache for the next person seeing it.

#define HIDE____ (
#define ____HIDE );

The first macro is used for the starting paren and the second macro for the ending parent and the semi colon.

Here's how you would hide a function
Change

	afx_msg void OnUpdateFunction(CCmdUI* pCmdUI);
To
	afx_msg void OnUpdateFunction HIDE___ CCmdUI* pCmdUI ___HIDE

Note that there is no ending semi-colon. That's taken care of by the macro.

To hide a variable, define a macro to substitute for the semi-colon. Use this macro to end the statement



Comments

  • Doesnt work with VC++ 6.0

    Posted by Legacy on 11/22/1999 12:00am

    Originally posted by: SHAILESH BARVE

    I tried the stuff but doesnt look like its working with VC++ 6.0 editor...

    Doesnt look that stratight forward the way it looks...but its a good try!

    Reply
  • 'Hide' Class (only) in VC6 using folder

    Posted by Legacy on 09/20/1999 12:00am

    Originally posted by: Arnt Witteveen

    In VC6 (don't know about VC5) you can make a folder in the classview. This is a simple way to organize classes, and this might provide wath some of you are looking for.

    You can drag all classes you don't want to see into some folder, e.g. all classes of some library into a folder with the name of the library. That folder could be contained in a folder "libraries", which leaves you with only 1 extra folder, for all the libs you have.

    It is very usefull for organising my own code too...

    Reply
  • Hidiing from ClassView

    Posted by Legacy on 01/05/1999 12:00am

    Originally posted by: Paul Whitehead

    From the previous comments sounds like some people are having problems.

    If you can still see the class member / method, then try "Update All Dependencies" from the Build / Project menu (depending on VC4 / VC5). If that doesn't work, come out of the IDE (i.e. close MSDEV). Delete the .ncb file. Restart MSDEV. One of these two usually work...

    The second problem: sounds like you got a problem with pre-compiled headers. It should have worked fine. The only down side to pre-compiled headers is that to get rid of them and rebuild them you need to do a full build - which may be a horrendous proposition if your project is large. The other way is to go and delete the pre-compiled header files (if you've got more than one or more than one target). Deleting a pre-compiled header file will minimise the amount of rebuilds if you have more than one pre-compiled header but it is more of a headache. It will also depend on where you have set the pre-compiled header to stop - either in the build/project settings or by means of a #pragma hdrstop. The simplest solution is just to do a full rebuild.

    Reply
  • Hiding a function from classview

    Posted by Legacy on 11/04/1998 12:00am

    Originally posted by: Pankaj

    It has help me lot in browsing through my code .
    
    Thanks
    Regards
    Pankaj.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: January 28, 2015 @ 11:00 a.m. ET / 8:00 a.m. PT Check out this upcoming live webcast and join Jeff Sloyer, IBM Developer Evangelist and Master Inventor, for a tutorial for building cloud-based applications. Using IBM's platform as a service, Bluemix, Jeff will show you how to architect and assemble cloud-based applications built for cloud scale. Leveraging the power of microservices, developers can quickly translate monolithic applications to a cloud-based microarchitecture. This hour-long …

  • The 3rd Platform of computing, based around the four pillars of mobile computing, social media, big data and analytics, and cloud, is redefining what IT infrastructure needs to provide. Endpoint solutions must meet not only traditional data protection requirements, but also a new set of requirements driven by the explosion in mobile computing. This IDC white paper explores the customer challenges associated with safeguarding data residing on various endpoint devices, including laptops, tablets, and …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date