OS/2, eCS & ArcaOS - Technical > Programming

Resources, dialogs, etc - what tools for what jobs?

(1/2) > >>

Dariusz Piatkowski:
PUMonitor enhancement project follow-up...

The original author provided a text RC file that defines all the resources the utility uses. No problem there, the Resource Compiler get that into a RES file, which is then ultimately attached to the EXE itself. My makefile handles that. Keep in mind that he developed this in Borland C++, so I am assuming he used the Borland Resource Workshop.

Alright...so now I need to change the Settings dialogs and as best as I know (which granted is very little on this topic ;)) I was expecting to use the Dialog Editor to actually visually modify/add the right layouts, etc. The Dialog Editor however (which is the Toolkit one) only wants to open a RES file, which while managable (b/c I have that as an output of the Resource Compiler run) will not afterwards reflect the changes in the source RC file. In other words: it looks like I can make changes to the RES itself, but once I do how do I get these into the underlying RC itself?

I understand why the ability to just change the RES is desirable: after all, if I want to adjust just a resource it is awfully nice to do so w/o having to recompile all the sources, etc.

OK, so back to my task, my thinking here is: if my makefile is looking to always compile the RC, clearly when I modify just the RES I will always overwrite those changes with the output of compiled RC, no?

Further on I understand that the Dialog Editor should allow me to create the DLG file, with the option to create the compiled version, that being the RES extension. OK, but trying to do this with my Dialog Editor only allows me to open a RES file, and attempting to save it simply points back to the same RES and optional H files.

Alright...so digging through my OS/2 DEV library I see the mention of Dialog Editor ONLY creating DLG text files when one starts with a NEW dialog...hmm??? So is the expectation really that all further changes are to be done by hand (if I want to reflect the actual changes in the underlying DLG source), or through a direct GUI manipulation of the previously generated RES file (using Dialog Editor)?

That just seems weird...I should be able to visually modify a dialog and upon saving it update the source definition file itself, be it RC or DLG (depending of course on what particular resource I am modifying).

So what am I missing here?

FYI - attempting to open the RC file itself in Borland Resource Workshop produces an error:

"Compiling MENU: ID_MENU"


--- Code: ---Error
G:\code\source\os2\pumonitor\src\source\pumon2.rc 20:Expecting END

--- End code ---

The Help feedback states:


--- Quote ---Resource Workshop encountered an unexpected token when searching for the END keyword. This error is frequently caused by a typo in an identifier name.

--- End quote ---

Which I think is strange given that this RC file compiles successfully into RES, which itself is attached into the EXE and by all accounts that's working quite fine.

Here is the matching part of the RC itself:


--- Code: ---...
MENU ID_MENU
{
    MENUITEM "~About"    , ID_MENU_ABOUT, MIS_TEXT
    MENUITEM "~Settings" , ID_MENU_SET  , MIS_TEXT | MIS_SUBMENU
    {
        MENUITEM "~General"       , ID_MENU_SET_0, MIS_TEXT
        MENUITEM "~CPU Meter"     , ID_MENU_SET_1, MIS_TEXT
        MENUITEM "~Memory Meter"  , ID_MENU_SET_2, MIS_TEXT
        MENUITEM "~TCP/IP Traffic", ID_MENU_SET_3, MIS_TEXT
        MENUITEM "M~ail Checker 1", ID_MENU_SET_4, MIS_TEXT
        MENUITEM "M~ail Checker 2", ID_MENU_SET_5, MIS_TEXT
        MENUITEM "M~ail Checker 3", ID_MENU_SET_6, MIS_TEXT
        MENUITEM "M~ail Checker 4", ID_MENU_SET_7, MIS_TEXT
        MENUITEM "M~ail Checker 5", ID_MENU_SET_8, MIS_TEXT
        MENUITEM "C~onnectivity"  , ID_MENU_SET_9, MIS_TEXT
    }
    MENUITEM ""            ,            -1, MIS_SEPARATOR
    MENUITEM "Read ~Mail  ", ID_MENU_MAIL , MIS_TEXT
    MENUITEM ""            ,            -1, MIS_SEPARATOR
    MENUITEM "~Close"      , ID_MENU_CLOSE, MIS_TEXT
}
...

--- End code ---

Alex Taylor:
The Dialog Editor opens RES files, but when you save the file after making any change to any dialog, it should both update the RES file and create a DLG file alongside it. (I just tested and confirmed that here.)  It will not make any changes to an RC file, since those by convention contain non-dialog resources (which the Dialog Editor knows nothing about).

IMO this is a good thing, because the Dialog Editor is old and stupid and isn't capable of properly parsing or saving certain control properties or attributes.  (In particular, it knows nothing about properties or styles which were added after around Warp 3.)  Unfortunately, its solution to encountering stuff it doesn't know about is to silently replace or remove it when the resources are saved. In other words, you can end up with changes you didn't want, or (sadly all too often) actually corrupted and unusable resources.

Basically, using the Dialog Editor to create new dialogs is generally fine. You can also use it to modify dialogs if you're confident there's nothing in them that might cause the Dialog Editor confusion (which should be the case if you originally created them using Dialog Editor and didn't hand-modify them later).

In all other cases, you should not use the Dialog Editor to modify existing dialog resources in-place, especially if you didn't originally write them yourself. If you need to make changes visually, use the Dialog Editor but Save As instead of saving over the original file, then hand-copy the changes you need over to the original DLG file.

FWIW, the code you quoted is not in a valid RC format that I recognize (which uses BEGIN and END instead of {}), so perhaps it's specific to the Borland toolchain?  Never used Borland so I can't speculate further.

Martin Iturbide:
Hello

I had used very lightly the Prominare URE (Resource Editor). Maybe it can be interesting to take it for a spin and see if it can import .RES files. (Please read the installation instructions, it's kind of tricky).

Regards

Andi B.:

--- Quote ---I had used very lightly the Prominare URE (Resource Editor). ...
--- End quote ---
I always thought URE (or the IBMs version IRE which is included with IBMs compilers) is the only tool which should be used for creating and editing such stuff. At least in the last 2 or 3 decades. Even URE/IRE does sometimes delete necessary properties. But most of the time it preserves all stuff it doesn't know about.

If you're in the position to create new stuff probably QT Creator is our most modern tool.

Dariusz Piatkowski:
Hi Alex,

First of all, 'Thank You' for the great explanation. I understand what you wrote, and in some ways this confirms my suspicions, so perhaps I wasn't that far off after all? :o  (certainly refreshing, and somewhat of a 'confidence builder'...at least until the next "brick wall" encounter...LOL)


--- Quote from: Alex Taylor on November 19, 2023, 12:00:34 am ---...FWIW, the code you quoted is not in a valid RC format that I recognize (which uses BEGIN and END instead of {}), so perhaps it's specific to the Borland toolchain?  Never used Borland so I can't speculate further.

--- End quote ---

Re: BEGIN/END vs {/}, as it turns out both are supported keywords in RC, at least the version I'm currently using:


--- Quote ---Version 4.00.011 Oct 10 2000
(C) Copyright IBM Corporation 1988-2000
(C) Copyright Microsoft Corp. 1985-2000

--- End quote ---

This is also documented in the April_2001 'Tools References' INF file, under the 'Resource Compiler => Keywords' section, so at least appears to have an actual confirmation of the intent.

Navigation

[0] Message Index

[#] Next page

Go to full version