Hide a function or variable from the Class View

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >


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

  • The software-defined data center (SDDC) and new trends in cloud and virtualization bring increased agility, automation, and intelligent services and management to all areas of the data center. Businesses can now more easily manage the entire lifecycle of their applications and services via the SDDC. This Aberdeen analyst report examines how a strong foundation in both the cloud and internal data centers is empowering organizations to fully leverage their IT infrastructure and is also preparing them to be able …

  • Microsoft Azure® is a leading choice for businesses looking to take advantage of the cloud. Azure is particularly appealing to businesses that have already invested in Microsoft on-premises and are now considering running these applications and other workloads in the cloud. To understand how to make this move to Azure, many businesses are turning to managed service providers (MSPs) with specific Azure expertise. Read this white paper to learn the eight key areas to focus on when considering an MSP for an …

Most Popular Programming Stories

More for Developers

RSS Feeds

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