home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PM-M2B.ZIP / PM-M2.DOC < prev    next >
Text File  |  1990-10-05  |  9KB  |  252 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                   Writing Presentation Manager Programs in Modula-2
  8.  
  9.                                    by Chris Barker
  10.  
  11.                                    October 4, 1990
  12.  
  13.      The files contained in this zipped file constitute my attempt to write OS/2
  14.      Presentation Manager programs using JPI's Modula-2 for OS/2 version 2.0.  I
  15.      am both new to Modula-2 and to programming for the Presentation Manager.
  16.      Previously I have been programming extensively with Turbo Pascal and less
  17.      extensively with Turbo C.
  18.  
  19.      Since the preponderance of documentation for writing PM code is in C, I
  20.      thought the world might benefit from some examples written in another
  21.      language such as Modula-2.  I have taken a very clearly written book,"OS/2
  22.      Presentation Manager - Programming Primer" by Asael Dror and Robert Lafore,
  23.      and adapted their "C" examples to Modula-2.  Hopefully, my adaptions have
  24.      been correct!
  25.  
  26.      Personally, I find the protective environment of Pascal/Modula-2 (i.e.
  27.      strong type checking, promoting modular projects, etc.) a much more
  28.      comfortable and rewarding programming experience.  I am a very high level
  29.      minded kind of programmer that would prefer to adapt and reuse mine or
  30.      someone else's code (OOP?) to get a job done rather than wallowing down in
  31.      the internals of my computer's CPU.  I am always impressed by the
  32.      blindingly fast routines of a Zen assembler master like Michael Abrash, but
  33.      I'd rather work on a higher level.  Jeff Duntemann is programmer I look up
  34.      to.
  35.  
  36.      Speaking of OOP, my other reason for being attracted to JPI's M2 for OS/2
  37.      is its inclusion of object extensions to Modula-2.  The example program,
  38.      PMTEST, is my own cursory attempt at encapsulating some of the complexity
  39.      of PM programming using OOPS.  I hope to extend this and leverage some real
  40.      power.  I hope to hear from others that may be trying the same thing.
  41.  
  42.      Since I first released this archive to the public in August of 1990, I have
  43.      learned a lot about programming for PM with JPI's Modula-2.  Special thanks
  44.      go to Martin Waldron and Don Dumitru of JPI for patiently answering my
  45.      questions and pointing me down the proper path.  Also, JPI's recent release
  46.      of version 1.06b of Modula-2 now removes some lingering bugs that had
  47.      hampered some of my efforts.
  48.  
  49.      The most significant contribution Don made was to describe the recommended
  50.      approach to simulating the "C macros", such as SHORTFROMMP, that populate
  51.      so many PM programs.  The "proper" approach is to define a definition
  52.      module without an implementation module that contains inline procedures to
  53.      perform the proper type conversions.  The file, OS2MAC.DEF, contains the
  54.      definitions for the more commonly called macros.  Other macros can be added
  55.      by following the syntax shown in the file.
  56.  
  57.      So far I have gotten through chapter eight of the book and will hopefully
  58.      update this file as I adapt further examples.  Please read the header
  59.      comments in each program before you run the program so you will understand
  60.  
  61.  
  62.      Writing OS/2 PM Programs in Modula-2         October 4, 1990         Page 2
  63.  
  64.  
  65.  
  66.      what each is supposed to do.  I hope these examples will encourage others
  67.      to try a hand at PM programming using Modula-2.
  68.  
  69.      I would love to hear from other programmers.  Please send a message to me,
  70.      Chris Barker, at one of the following:
  71.  
  72.          -  Compuserve ID: 72261,2312
  73.  
  74.          -  Pete Norloff's OS/2 Shareware BBS - (703) 385-4325
  75.  
  76.          -  Max's Doghouse BBS - (703) 548-7849
  77.  
  78.             The above two BBS carry the Fidonet OS/2 echo which I read
  79.             regularly.
  80.  
  81.          -  Programmer's Corner - (301) 596-1180
  82.  
  83.          -  CPCUG Mix (Window Sig) BBS - (301) 738-9060
  84.  
  85.      Enjoy!
  86.  
  87.      ---------------------------------------------------------------------------
  88.  
  89.      The following is a listing of the executable programs contained in this
  90.      archive:
  91.  
  92.      PMTEST            A simplistic program that demonstrates the OOP extensions
  93.                        to JPI's M2.
  94.  
  95.      SOUND             Simply sounds a beep on the desktop and ends.
  96.  
  97.      SCROLLBR          Puts a giant scollbar on the desktop.  You should run
  98.                        this from a full screen session since there are no
  99.                        provisions to shutdown this program.
  100.  
  101.      FAMILY            Creates a "family" of client windows demonstrating the
  102.                        relationship between a client window and its siblings.
  103.  
  104.      DEFWIN            Simple standard client window.
  105.  
  106.      BEEP              Adds menu options to a window.
  107.  
  108.      STDWIN            Another way of creating a standard client window.
  109.  
  110.      WMPAINT           Places text in the center of window and automatically
  111.                        recenters the text when the window is resized.
  112.  
  113.      MESSAGES          An interesting way to see the actual messages that are
  114.                        being sent to a window.  This is in some ways a cruder
  115.                        version of PMSPY.  Program will start beeping a few
  116.                        seconds before a window appears.
  117.  
  118.      STATIC            Clicking the left mouse button will draw text on the
  119.                        window at the current pointer position.
  120.  
  121.  
  122.  
  123.                                         - 2 -
  124.  
  125.  
  126.      Writing OS/2 PM Programs in Modula-2         October 4, 1990         Page 3
  127.  
  128.  
  129.  
  130.      ROTATE            My favorite program so far!  This creates a client window
  131.                        with the four quadrants of the window set to a different
  132.                        color.  When you press start, the colors will appear to
  133.                        rotate as each quadrant changes colors.  Provisions are
  134.                        available to change the speed of rotation as well as the
  135.                        colors.  Be sure to minimize this to see an example of a
  136.                        "moving" icon.  Neat!
  137.  
  138.      BEEPS             Simple example of adding a menu bar to a window.
  139.  
  140.      BUTTONS           Puts two 3-D buttons in the middle of the screen whose
  141.                        purpose will be obvious.
  142.  
  143.      RADIOBUT          Another nice program that demonstrates the use of radio
  144.                        buttons.  Selecting each button will change the desktop
  145.                        background color to the indicated color.  Upon exit, the
  146.                        program will restore the color to its original value.
  147.  
  148.      CHECKBOX          Places a checkbox on the screen that when checked will
  149.                        cause a beep to be heard when the window is resized.
  150.  
  151.      CLICK             Pressing the left mouse button anywhere on the screen
  152.                        will sound a beep.
  153.  
  154.      ERASEBKG          Clears the client windows background.
  155.  
  156.      POSITION          Similar to click, except if you click in the left hand
  157.                        quarter of the window a high pitched beep will be heard.
  158.                        Clicking on the right side of the window will sound a
  159.                        lower pitched beep.
  160.  
  161.      POSTMSG           When the left mouse button is pressed anywhere on the
  162.                        window, the program will end.
  163.  
  164.      BEEPSKBD          Demonstrates the addition of keyboard input to the menu
  165.                        of a client window.
  166.  
  167.      BEEPSACC          Similar to BEEPSKBD, but uses the accelerator option in
  168.                        the resource file to add keystroke input to the window.
  169.  
  170.      ENTRY             Creates a text entry box for you to enter a short
  171.                        message.
  172.  
  173.      LISTBOX           Shows how to create a scolling listbox in a window.
  174.  
  175.      SCROLL            Supposed to display a long list of text that can be
  176.                        displayed by moving the scrollbar.  There is a bug that
  177.                        needs to be fixed!
  178.  
  179.      STRING            Posts messages taken from a resource file.
  180.  
  181.      ICON              Shows how to add an icon resource bitmap to a program so
  182.                        that an icon will be shown when the window is minimized.
  183.  
  184.  
  185.  
  186.  
  187.                                         - 3 -
  188.  
  189.  
  190.      Writing OS/2 PM Programs in Modula-2         October 4, 1990         Page 4
  191.  
  192.  
  193.  
  194.      POINTR            Demonstrates how to change the shape of a pointer in your
  195.                        application.
  196.  
  197.      CUSTOM            Supposed to show how to add a custom defined resource to
  198.                        a program.  There is a bug in this program that I haven't
  199.                        had a chance to fix.
  200.  
  201.      ---------------------------------------------------------------------------
  202.  
  203.      History
  204.  
  205.      August 1990 - First release of PM-M2 zip file.
  206.  
  207.      October 1990 - Updated release of PM-M2 with numerous fixes and many
  208.      program additions.
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.                                         - 4 -
  252.