Hide a function or variable from the Class View | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 8, 1998
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.