Author Topic: Resources, dialogs, etc - what tools for what jobs?  (Read 4927 times)

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1324
  • Karma: +26/-0
    • View Profile
Resources, dialogs, etc - what tools for what jobs?
« on: November 18, 2023, 04:41:34 pm »
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: [Select]
Error
G:\code\source\os2\pumonitor\src\source\pumon2.rc 20:Expecting END

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.

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: [Select]
...
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
}
...
« Last Edit: November 18, 2023, 04:55:44 pm by Dariusz Piatkowski »

Alex Taylor

  • Sr. Member
  • ****
  • Posts: 389
  • Karma: +5/-0
    • View Profile
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #1 on: November 19, 2023, 12:00:34 am »
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

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4754
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #2 on: November 19, 2023, 01:50:18 am »
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
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Andi B.

  • Hero Member
  • *****
  • Posts: 821
  • Karma: +11/-2
    • View Profile
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #3 on: November 19, 2023, 10:20:08 am »
Quote
I had used very lightly the Prominare URE (Resource Editor). ...
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

  • Hero Member
  • *****
  • Posts: 1324
  • Karma: +26/-0
    • View Profile
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #4 on: November 19, 2023, 09:49:24 pm »
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)

...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.

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

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.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1324
  • Karma: +26/-0
    • View Profile
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #5 on: November 19, 2023, 09:55:48 pm »
Hi Martin,

...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)...

I downloaded but stopped the review as Andi's post showed up. More details in my response to his post.

Sir, I appreciate the extra work you did to research and post the link.

For what it's worth (as maybe others might benefit from this), I looked into the whole "perhaps I need to de-compiled my RES file, which comes from that original RC file, into something usable and then figure out a way to visually work with it" effort.

What did come up actually was the reference to the RESMGR utility, which amongst other things does in fact allow you to do such a decompilation. I haven't tried it yet, although I did have it already deployed in my DEV=>Misc Tools folder, just didn't re-discover it in time. Judging by the included DOCs however this seems like a viable route to pursue.

Dariusz Piatkowski

  • Hero Member
  • *****
  • Posts: 1324
  • Karma: +26/-0
    • View Profile
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #6 on: November 19, 2023, 10:07:22 pm »
Hello Andi!

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...

I am extremely glad you floated this. I have used IRE before for a different project, and given that this was a new build it certainly allowed me to start with a clean slate. I did try IRE here for my PUMonitor project but didn't see a way to literally point to a RES file and use that as the starting point.

OK, so back to the "drawing board" I went per your feedback. My IBMCPP environment is v3.65, and while I have the full VACPP 4.0 installed here as well, because it is a wholly encompassing IDE I decided to avoid what seemed like a much bigger undertaking migrating the existing source tree into a new VACPP 4.0 project. Instead I have been using the OS/2 Toolkit & IBMCPP setups and relying on makefile driven builds.

Alright...so the key was: start a NEW IRE project, but once that initial piece is kicked off import in the existing RES file along with various needed Hs. Sure enough, while I haven't gotten it perfect quite yet, it does a pretty nice job of basically decompiling the RES and producing a nice RC script (which is what the other set of manual tools was driving towards that I referenced in my response to Martin's post above).

Therefore, this is absolutely a viable approach and is the one I'm pursuing. My intention is to wrap up the enhanced RAM monitoring and add the disk throughput next, which will require some dynamic check-box placements based on whatever are the existing storage devices that the system reports.

'Thank You' again for this great reminder!

Andi B.

  • Hero Member
  • *****
  • Posts: 821
  • Karma: +11/-2
    • View Profile
Re: Resources, dialogs, etc - what tools for what jobs?
« Reply #7 on: November 20, 2023, 12:55:53 pm »
URE/IRE - IIRC the version of URE on hobbes is the latest (and hopefully best) version. Even the VACPP4.0 included IRE is older I think. At least that's what I remember and so I use URE. But I don't know what's the difference between the IRE.exe versions included IBMCPP/VACPP4 and URE. Only 'think' URE is the latest greatest we have.

Quote
I decided to avoid what seemed like a much bigger undertaking migrating the existing source tree into a new VACPP 4.0 project. Instead I have been using the OS/2 Toolkit & IBMCPP setups and relying on makefile driven builds.
Good decision I think. I think it doesn't matter very much if you use IRE or URE in this setup. Maybe it's only a habit from me sticking with URE and never really tested the IRE versions.

Btw. I usually prefer RC5.0xx. But sometimes RC4.0xx gives other/better error messages. So when I'm in trouble I try both on the same file(s).
« Last Edit: November 20, 2023, 01:00:00 pm by Andi B. »