Click here to Skip to main content
Click here to Skip to main content

The Groovyness of the Gallery

, 11 Feb 2003
Rate this:
Please Sign up or sign in to vote.
An article on using the Gallery to resuse classes.

Introduction

Sometimes, gentle reader, you may wish to use the same code in many projects (an honorable and just practice) and for reasons best left to yourself you choose not to partake in the creation of lib files and dll’s.

In fact many programmers choose to create a directory and dump classes (the .h and cpp files), which they think they may use often, and then add the relevant paths to VC++ (Tools->Options->Directories then setting the relevant include and source directories as necessary). Moreover other programmers like to simply dump a copy of the .h an .cpp files into the project folder they want to use it in and work from there. And still others yet like to use the Gallery to create ogx files. The purpose of this article then, gentle reader, is to elucidate as to how to take advantage of the Gallery.

A Beginning

Suppose my friend, you have created a most excellent class that you believe you will want to use in another project. You don’t wish to use dll’s or lib files. Perhaps each time you need to use it some minor modification may be necessary or perhaps even you dear reader just simply want access to the source code in the project without having to go dropping copies of the source code around into folders.

A very lithesome ion to this problem is provided by using the Gallery. According to the help files provided by Microsoft™…

The Gallery provides a convenient way to add complex code such as components and ActiveX controls to your project, or to let you reuse previously written code.”

But how do we add our class(es) to this magical Gallery?

Simple my good friend – follow this gentle procedure.

  1. Open the project in which the class of interest already exists.

  2. Open the Workspace (View Menu->Wordspace, or ALT-0)

  3. Click on the root node of the Tree (in this case “MyCoolApp classes”) and there will now be a list of the classes in the application (see below).

    The Workspace

  4. Click on the class of interest (in this case we will use “CMyGroovyClass” and from the menu displayed choose “Add to Gallery”).

    Workspace with menu

  5. This will now create a nice sparkly new folder in something like “C:\Program Files\Microsoft Visual Studio\Common\MSDEV98\Gallery” (depending on where you have VC++ installed). The folder will have the same name as the project (in this case “MyCoolApp”) and inside this folder will be a .ogx file with the same name as your class (in this case it will be My Groovy Class.ogx (see below)

  6. gallery directories

You can share this file with others if you wish. To use it, all they need to do is either create a similar sub-folder in the Gallery folder and place the .ogx file into that, or they can drop the file into “Visual C++ Components” folder (Although it is probably best if they create a new folder).

Now what?

Now you have added your class to the Gallery, you are now free to use it in other projects with little effort to you dear reader.

How do I use it?

  1. Open the project you want to add the class to (or start a new project).

  2. Open the Gallery (Project Menu-> Add to Project->Components and Controls)

    Components and Controls

  3. From the “Components and Controls Gallery” window that appears, select the folder that holds the .ogx (in this case MyCoolApp).

  4. Components and Control Gallery

  5. Then either double click the .ogx file, or select the .ogx file then click “Insert”, you will now be prompted with the following dialog:

    Double checking component insertion

  6. Click “OK”, then close the “Components and Controls Gallery” window. The class will now be inserted into your project (just like magic but better).

Look mum, a new class!

Having passed on my wisdom I am now free to go about my daily business as too are you my dear reader. I hope this has been enlightening and wish you happiness and heartiness on your quest for perfect programming

An additional pointer to you all in your journey - You can also add ActiveX controls or third party components to your projects. Read the MSDN help files for information on how to do this and for more information on .ogx files.

Here-in ends the lesson.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

bryce
Software Developer (Senior)
Australia Australia
No Biography provided

Comments and Discussions

 
QuestionMissing virtuals and windows message option PinmemberVaclav_Sal10-Aug-07 4:53 
AnswerRe: Missing virtuals and windows message option Pinmemberbryce10-Aug-07 13:48 
GeneralMy ogx-inserted class does not appear in ClassWizard. PinmemberMojo Jojo13-Aug-03 12:04 
QuestionHow about DLLs? PinmemberPerFnurt11-Jun-03 5:42 
Generalcool! PinmemberGilad Novik17-Feb-03 20:49 
GeneralRe: cool! Pinmemberbryce18-Feb-03 13:47 
GeneralDialog boxes PinmemberHeywood13-Feb-03 6:51 
GeneralRe: Dialog boxes PinmemberGeno Carman18-Feb-03 5:25 
GeneralGroovy....Very Groovy... PinmemberKant13-Feb-03 5:15 
QuestionVS.NET version? PinmemberMarc Clifton12-Feb-03 14:21 
AnswerRe: VS.NET version? Pinmemberbryce12-Feb-03 14:25 
GeneralRe: VS.NET version? PinmemberArt Friesz18-Feb-03 6:57 
GeneralRe: VS.NET version? PinsussAnonymous19-Feb-03 5:39 
GeneralRe: VS.NET version? PinmemberArt Friesz19-Feb-03 12:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 12 Feb 2003
Article Copyright 2003 by bryce
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid