Quote:> Hi. Takes to long to explain why, but I have messed
> up. I have some duplicate values in IDS_xxxxx
> like IDS_String1 178 and IDS_String2 178.
> Also I have some strings in the .rc that hasn't
> got a number in resource.h. For ex IDS_String3
> "bla bla bla" and no entry for IDS_String3 in the
> r.h file.
> Questions:
> Does it matter what number a IDS_xxx has?
> Can I just change them to some unused?
> Can I just add the ones that exists in my .rc
> file to the r.h with a uniqe number?
> When are the numers used? Are the
> string names replaced with numbers
> during compiling?
Resources can be give names or numbers. For example,
if you have this:
somefile.rc
about dialog
...
begin
...
then the resource is stored under the name "about" and
you refer to it by "name" like this:
DialogBox(...,"about",...);
But if you have this:
somefile.rh
#define about 123
somefile.rc
#include "somefile.rh"
about dialog
...
begin
end
then the resource is stored as integer value 123 and you
refer to it like this:
#include "somefile.rh"
DialogBox(...MAKEINTRESOURCE(about),...);
So, you can use numbers or names. It's generally considered
more efficient to store resources using numbers.
One problem that people have when they get it all mixed
up (like you have) is that the resource compiler doesn't
really care if it can find the #defined integer values or not.
If you use 'about' and it can't find a #defined integer, it stores
it as "about". So the first thing to do is ensure that the
resource compiler always has access to all of the integer
constants when compiling, so it will store them using
integer id values. You normally do that by putting all of your
#defined integer constants in something like a .rh file (same
as a .h file) and #including that in the .rc (as above). Then
you #include the same .rh file in your .c or .cpp file and use
MAKEINTRESOURCE() on the integer value.
You only have to worry about resource numbers being unique
within each resource type (dialog, bitmap, icon, etc). So
you can use 123 for a dialog, a bitmap and an icon, but you
can not have 2 dialogs or 2 bitmaps or 2 icons with the
id 123. The numbers do not have to be contiguous, nor do
you have to use them all. If you choose to use 12, 123 and
12345 for 3 dialog boxes, that's perfectly ok.
Here's the way I do it. I keep all of my resource id values
in a single file called myapp.rh. That way, I will never use
the same number for 2 dialogs. It might look like this:
#define IDI_ICON1 101
#define IDI_ICON2 102
#define IDI_ICON3 103
...
#define IDD_DIALOG1 201
#define IDD_DIALOG2 202
#define IDD_DIALOG3 203
...
#define IDB_BITMAP1 301
#define IDB_BITMAP1 302
#define IDB_BITMAP1 303
...
#define IDH_DIALOG1 9001
#define IDH_DIALOG2 9002
...
Each .rc file includes myapp.rh
dialog1.rc
#include "myapp.rh"
IDD_DIALOG1 DIALOG
...
BEGIN
...
dialog2.rc
#include "myapp.rh"
IDD_DIALOG2 DIALOG
...
BEGIN
...
And each *.cpp module also includes it:
dialog1.cpp
#include "myapp.rh"
DialogBox(...MAKEINTRESOURCE(IDD_DIALOG1)...);
dialog2.cpp
#include "myapp.rh"
DialogBox(...MAKEINTRESOURCE(IDD_DIALOG2)...);
Of course, you will use more creative names like:
#define IDD_ABOUT 101
#define IDD_PREFERENCES 102
#define IDD_TOOLS 103
In the example above, you can see IDH_ ... These are
the IDs used for the Help button in each dialog box.
By keeping them all in one place, it means they are
unique and are used as unique labels in the HLP file
(# footnotes)
No, I don't manage resource IDs using the resource editor.
I add the values manually to the myapp.rh file in the right
place and with my preferred values. Then when I use the
resource editor and assign the ID, it's already in the
myapp.rh file and it doesn't have to assign a number.
That should give you enough background information to
go back in and sort out your code. If not, ask more
specific questions here.
--
John A. Grant * I speak only for myself * (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here