|
25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more... |
Home Projects Up Sitemap Search Blog Forum+Chat About Us Privacy Terms of Use Feedback FAQ Images Services Payments Humor Music |
How to avoid resource identifier conflicts in Borland ObjectWindows .RC and .RH filesSummary:
For Borland C++ 4.0 and ObjectWindows Library OWL 2.0 It's been a long time since I used these files, so I cannot write about them with confidence that I still know what I'm talking about, but they address a problem that you might run into if you're working with OWL, so they might turn out to be useful. Copyright (C)1999 Steven Whitney. Published under GNU GPL (General Public License) Version 3, with ABSOLUTELY NO WARRANTY. What they are2/16/06 An OWL (and Windows) project might use many resources such as menu items, command IDs, string resources, messages, graphics of various types, buttons, keyboard accelerators, predefined dialog boxes, and more. Each of these must be assigned a numeric identifier, either automatically or by you. The identifiers must be unique. As you construct a project, creating resources for it, you simultaneously create the IDs. But OWL also has a number of predefined resources, with associated predefined IDs. If you get halfway through a project and decide you want to use one of those predefined resources, the predefined IDs that have been created for them might conflict with ones you've already created, and resolving the conflicts can be difficult. Furthermore, when you use the OWL-predefined resources in your program, Resource Workshop seems not to make a copy of them for use in that one project, but to use the centrally-located one that is part of the Borland OWL installation. Thus, if you modify any of those resources within Resource Workshop, you are modifying the master files, and your changes will apply to all your subsequent OWL program compilations, which could break your preexisting programs. So I gathered together all the predefined OWL resources into a big resource file (OWLRES.RC) and gathered all their identifiers into a big resource header file (OWLRES.RH). When starting a new project, I copied these files into the project directory, renamed them appropriately, and they became the starting RC and RH files for that project. Since they already contained all the OWL predefined resources, and since Resource Workshop would thereafter create only unique identifiers, there was no danger that I would later wind up with "identifier confusion" in the project. Because all the OWL .rc and .rh files are copyrighted by Borland International, their actual text is not included here. Rather, I show you the process by which to create your own.
Instructions5-28-00 Copy the files to your new project, renamed to be the .RC and .RH files for the project. You can then be sure (I hope) that later additions to the project won't create any conflicts with existing resources or identifiers, since the project knew about all the predefined OWL ones from the start. The above isn't quite true. Resource Compiler only seems to check for duplicate IDs within a single resource, not across all resources. Usually this is ok. But duplicate identifiers in concurrently running dialogs and/or windows seem able to cause bizarre application crashes due to misidentified notification or command messages flying about. For example, a control with the same ID as a menu item may cause one window to execute the menu item command when an Executing dialog box may merely have been trying to draw the control. It seems to be a "good idea" to avoid all duplicate IDs at all times, but if you have multiple dialogs running at once, you MUST avoid all duplicate IDs at all times. I have had a lot of trouble any time I tried to use a dialog in a nonstandard way, and this may have been one of the reasons. Any comments in the .RC (and .RH?) files may(?) be lost when the Resource Compiler alters or compiles the file, so it's usually not worth bothering adding comments. //---------------------------------------------------------------------------- When creating a new resource file for a project, the order you do things is important. The default way Resource Compiler handles things is in many cases probably not what you want, so you have to set things up manually. Assuming your project is PROJECT.IDE,
Customize the resulting files however needed. |
This file should contain all the .RH header files that came with OWL. The following lines are a list of them:
// OWLRES.RH 7-20-99 // // Start all new project .RH files with the copied text from this file. // It prevents Resource Workshop from creating identifiers that conflict // with any existing ones defined by OWL, allowing you to add predefined // OWL resources to projects without worrying about such conflicts. // // This file contains all the copied text (edited) from the various OWL .RH files. // 2/16/06: This is a list of the files you need to copy. Don't just add #includes // for them, because I think that's what makes them available to Resource Workshop // to change at their source. \owl\window.rh \owl\mdi.rh \owl\inputdia.rh \owl\except.rh \owl\edit.rh \owl\editsear.rh \owl\editfile.rh \owl\validate.rh \owl\slider.rh \owl\printer.rh //---------------------------------------------------------------------------- // The following were copied from *RC* files. // 2/16/06: Some of the RC files have identifiers declared in them (as #defines). // You should copy those #define lines here, too. // The RC files to search are those associated with these classes: TStatusBar (statusba.rc) TEditView (editview.rc) TListView (listview.rc) TDocManager (docview.rc) //---------------------------------------------------------------------------- // These are definitions for the starting resources for your new project. // I think the names and numbers are the same ones that Resource Workshop uses // so that they'll be pre-defined the first time you open this using Resource // Workshop, to prevent it from creating them(?). // All these will be throwaways except MAINMENU. #define ACCELERATORS_1 1 #define CM_KEY101 101 #define MAINMENU 1 #define CM_POPUPITEM 101
/* OWLRES.RC 7-21-99
Complete copy of the predefined OWL resources. Copy the text from this
file into all new project .RC files. You can edit out anything you know you
won't ever need, or that prevents correct compilation. (Some of these resources
have complicated dependencies that I've spent no effort understanding
or resolving.)
Using these copies will prevent Resource Workshop from modifying the original
files in the include\owl directory.
It also allows you to change such things as string table entries without
permanently changing them for all OWL apps.
Since a properly-used RC file is always RC_INVOKED (since no other file has
any use for it), I removed all the #if RC_INVOKED lines.
Some of the resources here (OWL icon, error stringtables) may be unnecessary;
OWL uses them when needed even if they're not in the project, so they might be in the OWL DLL.
-----
to do
I think 2 of the menus are complete dups, and some stringtable entries may be, too.
*/
#include "OWLRES.RH"
// Here are the resources that you need to gather into this file:
IDI_OWLAPP ICON
\owl\inputdia.rc
\owl\except.rc
\owl\statusba.rc
\owl\validate.rc
\owl\slider.rc
\owl\printer.rc
\owl\editsear.rc
\owl\editfile.rc
\owl\editview.rc
\owl\listview.rc
\owl\docview.rc
//----------------------------------------------------------------------------
// And these are the starting resources for your new project, which
// are at a minimum what you will need.
//----------------------------------------------------------------------------
MAINMENU MENU
{
POPUP "Pop-up"
{
MENUITEM "Item", CM_POPUPITEM
}
}
STRINGTABLE
{
MAINMENU, "string"
}
MAINMENU ACCELERATORS
{
0, CM_KEY101, VIRTKEY
}
|
|
|
|
|
|
Copyright ©2010 Steven Whitney. Last modified Thu 10/21/2010 02:08:03 -0700. |
||