Announcement

Collapse
No announcement yet.

I wish to be Educated on Win Resource Files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I wish to be Educated on Win Resource Files

    Hello,

    I am interested in finding and learning about the utilization of Windows Software resources as in a “Resource File”. It appears, to my yet untrained view of Windows software (I have been an Embedded Systems Designer and developer for my 25 plus years as an engineer) that resources that are compiled with programs into ‘exe’ files allow for greater control and versatility of the Windows interface. I have been looking online at the PowerBasic forums and have been unable to find any details as to the structure and makeup of these resources (the nuts & bolts – Sorry, I am a cross experienced hardware guy - details). I have spent some money purchasing Visual Basic 6 and Visual C++ books, as I have come across references to these in the PB Forums, attempting to find out more about resources and have accomplished nothing towards increasing my understanding of the details and the nuts & bolts of how it all works (especially as it would apply in the PowerBasic Programming Environment because I also purchased the big green PowerBasic manual). I am attempting to write an application that will be used to analyze data obtained from testing an advanced control system similar to how a hardware logic analyzer and a multi-channel digital storage oscilloscope would be used for hardware testing in PowerBasic. Could you please help me become familiar with and confident in working with Windows PB written apps and guide me in where to look?

    Thank You,
    John A Dillon

  • #2
    Basically, a program resource is a way of including "non-code data" in your executable (EXE or DLL) file so you don't have to supply separate data files with the application.

    Examples are bitmaps, icons, text files... the kinds of things which are needed for your application to run, but do not change. (Resources are not suitable for volatile data).

    To learn about resources you'll need to take a class or read some books.

    Classes I don't personally like, but books are always good.

    Do a search here on "book" in 'message subject' and you'll find lots of stuff.

    The two most often (as far as I can tell) suggested books are the Petzold and the Rector and Newcomer tomes.

    Then search here on 'resource' and you'll find some code examples.

    You might also try 'resource' in the compiler help file. I have no idea if you'll find anything, but since PB includes a 'resource compiler' it must say something, somewhere about program resources.

    MCM
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Resources are data embeded directly into an EXE file (compiled program).
      They can be text strings, Dialog definitions, bitmaps, icons, cursors and even binary data.

      With PowerBasic you first create an RC file (file extension .rc). RC files can be compiled into resource files specific to PowerBasic (PBR files).

      PBR files (extension .pbr) can be included in a Powerbasic applications source code by using the #RESOURCE compiler directive.

      To learn more about resource (RC) files and how to write them (they are simply text files with the RC file extension) read the "Resource Compiler" Help file that comes with the PB compiler (should be a menu item for it installed when compiler installed). This will explain all the resource compiler commands (how to write a resource file).

      As far as accessing the resources you compile into an application, the Windows API provides a number of API functions for handling resources, such as:

      LoadAccelerators
      LoadBitmap
      LoadCursor
      LoadIcon
      LoadMenu
      LoadString
      LoadImage
      FindResource
      FindResourceEx
      LoadResource

      There are also API's for enumerating the resources (getting a list of what resources are available)
      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      http://twitter.com/EZGUIProGuy

      Comment


      • #4
        To use resources in your program, you must create a "C"-style script file (extension ".rc"), which contains references to the icons and other resources, you then can compile this resource file separately from the IDE.

        Finally, you include the compiled resource file (extension ".pbr") in your main program with the #RESOURCE metastatement and use the API functions (like LoadIcon) to access these resources. That's all there is to it.

        The following link is provided with the PB 8 installation. It is Microsoft's official documentation for the resource compiler:

        Resource Compiler (MSDN)
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          Guys, I think what John meant, was some simple examples to get him started using resource files in PB (the leap from 1 language to another can be rather daunting, especially when the doc's referred to are in the other language)

          John,
          Although the books in the other languages can be of some help. I think the PB specific files you are looking for are the "RC.hlp" file in your "PB\bin" folder. (I did not notice if you bought PB or if you just bought the manual?)

          The "Nuts-and-Bolts" of things John, is that almost "ANYTHING" can be embedded in a program using the resource file. Now I will be the 1st to say I am weak in the area of resource files, because I usually use a working resource file as a template for a resource file in another project. (but sometimes it backfires on me, so I haven't learned why just yet).

          Chris is right with
          As far as accessing the resources you compile into an application, the Windows API provides a number of API functions for handling resources, such as:

          LoadAccelerators
          LoadBitmap
          LoadCursor
          LoadIcon
          LoadMenu
          LoadString
          LoadImage
          FindResource
          FindResourceEx
          LoadResource
          Which PB naitively supports, but there are other ways for using non-native files. *.jpg, *.wmv, *.pdf and etc.
          Currently, I embed *.pdf files in my programs for documentation, and tutorials etc.... but in this case I use a snippet (I believe if you search for "Extract File from Resource", you will find who did it and how it works) and a bit of other code I can open the pdf direct from code.

          MCM is correct with
          Resources are not suitable for volatile data
          So true, I look at resource files as embedding support files so that if the user does not have the file (most do not if it an application specific file)

          To learn about resources you'll need to take a class or read some books.

          Classes I don't personally like, but books are always good.

          The two most often (as far as I can tell) suggested books are the Petzold and the Rector and Newcomer tomes.
          I agree, but they seem to be more geared for C (which since I have not used C++ in years, can get confusing to me, just like the M$ documents), but are well worth the $$$ for learning the more in depth things.

          Some basic hints I can offer up though are "//" at the beginning of a line in the *.rc file will comment out that line. And to look at some examples in the forums using *.rc files to give you the basic format structure. (I would stay away from examples with toolbars for the time being unless you understand how toolbars work)

          on a side note John I saw you mentioned
          I have been an Embedded Systems Designer and developer for my 25 plus years as an engineer

          I am attempting to write an application that will be used to analyze data obtained from testing an advanced control system similar to how a hardware logic analyzer and a multi-channel digital storage oscilloscope would be used for hardware testing in PowerBasic.
          I am interested with what you are coming up with, because I often see hardware devices that are well designed and documented, but software usually is so lacking (or too complicated) that it is almost un-usable to me, unless I can take the time to "Reverse Engineer" how the hardware works and write my own app to interface with it. (USB interfaces especially)

          So its nice to see a "Hardware guy" try to look at the "Software" side and want to add functionality.
          Engineer's Motto: If it aint broke take it apart and fix it

          "If at 1st you don't succeed... call it version 1.0"

          "Half of Programming is coding"....."The other 90% is DEBUGGING"

          "Document my code????" .... "WHYYY??? do you think they call it CODE? "

          Comment


          • #6
            Microsoft's Resource Compiler User's Guide (rc.hlp) can be useful to a point to understand some of the options available to code your own RC file. Check your PB's \BIN directory to see if you have a copy, you should have.

            A resource file can be started with PB Forms if you have that program. A feature of PB Forms is being able to easily manage the version and rights information that would be in a resource file. It also will let you assign an icon to a program dialog, that will be added to the resource. RC files can also be entered and edited) in the PB IDE or another text editor or form generator program as well.

            As has been noted, a resource file can contain lots of different kinds of information which you want to be compiled with your .exe so you do not need to have (or many do not want to have) a bunch of support files.

            Many of the sample programs that come with PBWin include a .rc file. These bear some perusal since they can visibly show you some typical coding to embed resources along with a small .bas and .exe to see how to access the resource and use it in the program; as well as the end result. So just search the PBWin80 samples folder with Windows Explorer for *.rc and you will quickly have enough samples listed to explore and to get a pretty good handle on the simple syntax used. Some embed graphics files, but the same general syntax can be used for help files, audio clips,etc.

            There are some resources that may take a bit more coding to access and use than others. And if you hit on one of those and get stuck, post the problem here. Someone should be able to help you straighten out any syntax that may seem not to be working.
            Rick Angell

            Comment


            • #7
              You might want to download Ed Turner's excellent book on powerbasic programming at http://www.m4ware.com/ click on "Programming Book"
              "There are two novels that can change a bookish fourteen-year old's life: The Lord of the Rings and Atlas Shrugged. One is a childish fantasy that often engenders a lifelong obsession with its unbelievable heroes, leading to an emotionally stunted, socially crippled adulthood, unable to deal with the real world. The other, of course, involves orcs." - John Rogers

              Comment


              • #8
                simple resource file example programs

                Over at...

                http://www.jose.it-berater.org/smffo...php?board=20.0

                are some very simple examples of using resource files with PowerBASIC to create menus and dialog boxes. There are nine tutorials there, and #'s 4 and 5 are about using resource files.
                Fred
                "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                Comment


                • #9
                  Thanks to all for the help.

                  Hello,

                  I wish to thank you all for the help and assistance. I have been extremely busy lately testing a high level software build and have been negligent in following up on myself. Just to let you know I have just ordered the PowerBasic Forms and hopefully it will allow me the power and flexibility to do what I envision.
                  Thank you all for you time and efforts,
                  John Dillon

                  Comment

                  Working...
                  X