Omgili, forum search, forums search, search forums, discussion search,discussions search, search discussions, board search, boards search, search boards
  Advanced Search

Common Resource in multiple applications

On Fri, 5 Jun 2009 10:00:58 -0500, "AliR [VC++ MVP]" <...@online.nospam

Hi Guys,

Just want to get some opinions on this. Say I have a dialog box that is
used in more than one application, as we all know, I can simply put the cpp
and h file in a common folder and add it to the project of both
applications.

The resource is a different story, would you simply copy and paste the
resource from one app into another, or would you create a common resource
that both projects would have to include?

Now multiply this question by 5 or 6. There are 6 applications that share
the same resources, but not everyone will need the same resources. Hopefully
everyone can follow what I'm saying. Say app 1, 2 , and 4 use resource X,
app 1, 3, and 6 use resource Y, and Apps 2, 5, and 6 use Resource Z. (I'm
not there yet, but it could come this soon).

The copy and paste is very ugly, and I'm starting to think about common
resource file, but how would you keep the resources ids from overlapping?

As I was typing I started thinking, "Maybe I should be using a resource
dll?"

But hey this is why I'm posting this message. To get ideas on how to do this
right.

Thanks
AliR.



On Fri, 05 Jun 2009 11:05:31 -0500, Stephen Myers <...@microsoft.com"

It sounds like you should move the dialog (.cpp & resource) into a dll.

You could use resource names instead of IDs to eliminate some of the
problems due to overlapping IDs.

Steve

On Fri, 5 Jun 2009 09:41:58 -0700 (PDT), Ajay <...@yahoo.com

Look at MFC Regular DLLs which let you have your own resource IDs as
opposed to MFC Extension DLLs.

--
Ajay

On Jun 5, 11:00 am, "AliR [VC++ MVP]" <...@online.nospam

On Fri, 5 Jun 2009 20:37:41 +0100, "David Webber" <...@musical-dot-demon-dot-co.uk

"AliR [VC++ MVP]" <...@TK2MSFTNGP05.phx.gbl...

I have a resource DLL for resources used by more than one program. Not a
resource-only DLL - it also exports classes derived from CDialog and so on,
and wrappers around the DoModal() - in the form of a "user class" which
ensures the dialogue template is chosen from the right linguistic option.
[In parallel with my not-resource-only DLL are a number of resource only
DLLs for each available language other than English.]

ID's which are not needed outside the resource DLL are therefore not a
problem - they are not needed outside the DLL.

If an ID is needed outside (as string IDs usually are), I move it to a
special header file commonresource.h which can be included in the calling
modules. I make sure resource IDs in this do not overlap those in the
calling modules pretty much manually.

Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mozartists/mailinglist.htm

On Fri, 5 Jun 2009 15:16:58 -0500, "AliR [VC++ MVP]" <...@online.nospam

Looks like I need to add a new dll to the project. :) Thanks guys.

AliR.

"AliR [VC++ MVP]" <...@TK2MSFTNGP05.phx.gbl...


On Mon, 8 Jun 2009 04:40:45 -0700 (PDT), Goran <...@gmail.com

There are three approaches I can think of: extension DLL(s), regular
DLL(s) and a *.lib. DLL options are/will be explained here. I'll try
to explain the third - the *.lib option. It seems to be less used,
probably because there's no help from VisualStudio for that - it
really likes it's "one *.rc per executable" approach ;-).

So... You put your *.hpp/*.cpp in the library (or directly in a
project). You create *.rc/*.h pair alongside. *.rc/*.h contain
resource definition and corresponding IDXXXX constants for code in
*.hpp/*.cpp. You include that *.rc in your main project's *.rc2 (that
file is included by your main *.rc and VisualStudio isn't touching it
- it's yours). You may want to include resource *.h in *.hpp. (don't
call it "resource.h", though ;-), but you also may do without that.

If you do this, overlapping resource IDs break resource compilation,
so a convention for ID ranges for your main project and "satellites"
is in order.

To avoid having unneeded resources in your final executable, you might
want to use some conditional compilation (e.g. /D "USING_DIALOG_XYZ"
in project properties and #ifdef USING_DIALOG_XYZ in *.rc file of the
dialog XYZ).

HTH,
Goran.