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

The Groovyness of the Gallery

By , 11 Feb 2003
 

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
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionMissing virtuals and windows message optionmemberVaclav_Sal10 Aug '07 - 4:53 
When I add class from Gallery to my project I do not have menu options
Add Virtual funtions
Add Windows Message handlers
 
Where did it get lost?
Vaclav
 
PS Posted same question in Message Board.

AnswerRe: Missing virtuals and windows message optionmemberbryce10 Aug '07 - 13:48 
sorry mate - i havnt a clue Frown | :(
 

Bryce
 
---
To paraphrase Fred Dagg - the views expressed in this post are bloody good ones.
--

Publitor, making Pubmed easy.
http://www.sohocode.com/publitor

Our kids books :The Snot Goblin, and Book 2 - the Snotgoblin and Fluff


GeneralMy ogx-inserted class does not appear in ClassWizard.memberMojo Jojo13 Aug '03 - 12:04 
Hello, Mr. bryce !
I am a beginner and your article has been helpful for me.
But ... have I been wrong somewhere ? I have followed your indications using one of my classes, a CWnd derived one, and I have not fully enjoyed because of NOT finding it (as expected) in ClassWizard (in order to treat some other messages) in the "host-project". Why and how to solve the problem ???
And, maybe you know, is there a way to entirely and easy remove a class from a project, I mean without deleting its files by hand in Workspace / FileView ?
Thanks !
QuestionHow about DLLs?memberPerFnurt11 Jun '03 - 5:42 
Hiya,
 
just adding classes is a bit too static for me.
 
I've seen there's a bunch of DLLs in the Visual C++ Components folder doing things, but I can't find any info on how they work.
 
I'd like to make an appwizardish code generator, and if I could do it in the gallery it'd be neat...
 
Any idea or documentation to point to?
 
/Per N
Generalcool!memberGilad Novik17 Feb '03 - 20:49 
Big Grin | :-D
 
Whoa! The internet is even on computers now!
GeneralRe: cool!memberbryce18 Feb '03 - 13:47 
Gilad Novik wrote:
Whoa! The internet is even on computers now!
 
imagine that
bryce
 

GeneralDialog boxesmemberHeywood13 Feb '03 - 6:51 
What I would find useful is adding an entire dialog box (dialog resource and class) to the gallery so that a dialog can be added to the project with one button click.
 
I haven't figured out if it's possible to make the gallery "resource aware"... so that if your class uses a particular resource (icon, dialog, bitmap etc.), that resource is included in the gallery files. Is this possible?
 

GeneralRe: Dialog boxesmemberGeno Carman18 Feb '03 - 5:25 
I use an About Box class in my Gallery. The dialog resource is included just fine. However, the icons and bitmaps used in the dialog are NOT included.
I am hoping to find a way around that problem.
 
Geno Carman

GeneralGroovy....Very Groovy...memberKant13 Feb '03 - 5:15 
Roll eyes | :rolleyes:
 

Follow live World Cup Cricket scores here[^]

QuestionVS.NET version?memberMarc Clifton12 Feb '03 - 14:21 
So where might this dubiously useful Gallery be in VS.NET?
 
Marc
 
Help! I'm an AI running around in someone's f*cked up universe simulator.
Sensitivity and ethnic diversity means celebrating difference, not hiding from it. - Christian Graus
Every line of code is a liability - Taka Muraoka
Microsoft deliberately adds arbitrary layers of complexity to make it difficult to deliver Windows features on non-Windows platforms--Microsoft's "Halloween files"

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 12 Feb 2003
Article Copyright 2003 by bryce
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid