home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / template.zip / README < prev    next >
Text File  |  1998-04-20  |  9KB  |  176 lines

  1.     SAMPLE PRESENTATION MANAGER APPLICATION TEMPLATE
  2.     ================================================
  3.  
  4. The sources contained here are designed to serve as a template for
  5. your PM application.  These source files contain the overhead
  6. routines necessary to create a PM application as well as stubs
  7. for the basic menu items that all applications should have.  The
  8. source files are organized so that only a few of the files need to
  9. be modified; most of the source files can be left alone.  All of
  10. standard initialization and general functionality routines are placed
  11. in separate source files.  Since most applications will not need to
  12. change these routines, these files do not need to be changed.
  13.  
  14.  
  15.     ORGANIZATION OF SOURCE FILES
  16.     ============================
  17.  
  18. Here is list of the source files included in the template application
  19. and their general purpose.  All filenames have been limited to four
  20. characters so that you may add a prefix to the filenames to designate
  21. which ones have been modified for your application.
  22.  
  23.     main.h - application constants
  24.     xtrn.h - external variable and function declarations
  25.     help.h - help panel ids
  26.     dlg.h  - dialog box constants and item ids.  This file is designed
  27.              to be used with the Dialog Editor.
  28.  
  29.     main.c - main function, main window procedure, basic menu handler
  30.     init.c - initialization and Exit List processing routines
  31.     file.c - routines for processing File menu items
  32.     edit.c - routines for processing Edit menu items
  33.     user.c - functions for processing menu items and messages
  34.              specific to the application
  35.     dlg.c  - application specific dialog boxes
  36.     help.c - help manager functions
  37.     pnt.c  - routines for painting the main window
  38.  
  39.     main.rc - main resource file containing menus, string table, etc.
  40.     help.rc - resource file for help panels
  41.  
  42.     template.ipf - main help text file, contains the link to the others
  43.     file.ipf - help text file for the file menu items
  44.     edit.ipf - help text file for the edit menu items
  45.     menu.ipf - help text file for the application defined menu items
  46.     dlg.ipf  - help text file for the dialog boxes
  47.     help.ipf - help text file for the help menu
  48.  
  49.     template.mak - make file for the sample application
  50.     template.def - module definition file for the sample application
  51.  
  52.  
  53. Also included are two blank headers for use in your source files.
  54.  
  55.     funchead.c - blank header used before each function
  56.     head.c     - blank header used at the beginning of each source file
  57.  
  58.  
  59.     ORGANIZATION OF THE SAMPLE TEMPLATE
  60.     ===================================
  61.  
  62. Most of the general setup and overhead code is located in the main.c
  63. file.  Since this code is standard for all PM applications, you
  64. will probably not need to modify main.c at all.  Main.c
  65. contains the window procedure for the main window (MainWndProc())
  66. as well as the routine for processing the WM_COMMAND message
  67. received by the main window (MainCommand()).  MainWndProc() handles
  68. all the messages that every window must handle.  MainCommand()
  69. handles all of the WM_COMMAND messages posted by all of the standard
  70. menu items and by calling the appropriate routine to process the
  71. command.  There is one routine for each standard menu item and
  72. they are located in separate source files, one file for each menu.
  73.  
  74. While these two routines handle all of the standard messages and
  75. menus, some additions will be required to one or both when you add
  76. your own menus or other features. Rather than have you modifying the
  77. file that shouldn't need to be changed, the parts you can modify have
  78. been moved into their own file, user.c.
  79.  
  80. User.c contains the user defined version of the window procedure
  81. (UserWndProc()) and the WM_COMMAND message handler (UserCommand()).
  82. These two routines are called by the main routines if the message was
  83. not one of the standard messages or menu.  For example, the user window
  84. WM_COMMAND processor is called if the message was not posted by one of
  85. the standard menu items.  By placing UserWndProc() and UserCommand()
  86. into their own file, you can now add the processing necessary for your
  87. application in a spot isolated from the standard processing code.
  88.  
  89.  
  90.  
  91.     USING THE SAMPLE TEMPLATE
  92.     =========================
  93.  
  94. If you compile and link the sample application now, it will create an
  95. application that will run.  Although the application will not do
  96. anything, it is worth building the application in order to test your
  97. build environment and to see what a basic PM application looks like.
  98.  
  99. The sample application has only three menu items, File, Edit, and Help.
  100. The File menu contains commands for use on documents, e.g. opening a
  101. document or saving it to disk.  The Edit menu contains commands for
  102. processing data in a document, namely cutting, copying, and pasting
  103. data to and from the clipboard.  The Help menu contains the standard
  104. commands for interfacing with the help manager.
  105.  
  106. The routines for processing the standard menu commands are located in the
  107. *.c source files, where * is the name of the menu (e.g. File.c for the
  108. File menu).  The source file contains one routine for each
  109. menu item and the routine is named with the menu item name prefaced
  110. by the menu name.  For example, the routine that processes the New
  111. menu item of the File menu is FileNew().  The routines currently
  112. perform any actions which most applications will also take and then
  113. leave it up to you to add any application specific code.  The
  114. FileOpen() routine, for instance, calls the standard File Open dialog
  115. to retrieve a file name and opens the file for reading.  All you need
  116. to do is supply the code to read in the file.  You will need to
  117. supply routines to process all of the menu items whose commands are
  118. in these files.  Consult your CUA Style Guide if you have any questions
  119. as to the function of these menus.
  120.  
  121. You will also need to add any other menus which your application will
  122. use.  First add the menu item id values in the main.h file.  Next add
  123. the menu resource to the main.rc file.  Now, add the code to process
  124. the WM_COMMAND messages posted by the menus to the UserCommand() routine
  125. in user.c.  Add the menu item id values to the switch statement and
  126. include any menu item processing code there.
  127.  
  128. Should you wish to process any of the messages sent to the main
  129. window which are not processed by the standard window procedure, you
  130. can add these to the UserWndProc() routine in user.c.  Add the
  131. message id to the switch statement along with the routines for
  132. processing the message.  Make sure that the default case calls
  133. WinDefWindowProc().
  134.  
  135. Any other initalization, such as command line processing, can be done
  136. by adding code to the Init() routine in init.c.  If there is additional
  137. processing you want done when the main window is created, add these
  138. routines to the InitMainWindow() function of init.c.
  139.  
  140. Remember to add the source text for new help screens for any menu items
  141. you add (to menu.ipf) and for any new dialog boxes you create (to dialog.ipf).
  142.  
  143. Finally, change the the name of the source files you modified to reflect
  144. the name of your application.  If you use this template for more than
  145. one application, you will need an easy way to tell which source files
  146. belong to which application.  Embedding the identification of the
  147. application within the name of a source file will help you keep
  148. track of which application that source file is a part.  Now if you use
  149. this template for more than one application you will be able to
  150. discern the sources for each application, even if you have copies
  151. of the sources to more than one application on the same disk.
  152.  
  153. To tag the source files with an identifier for each application but
  154. still retain the identity of the source file, you should implement
  155. a prefix_suffix naming scheme for your source files.  The prefix
  156. should be a three letter abbreviation for your application name
  157. while the suffix should be the current name of the file.  All
  158. source files of the same application will then begin with the same
  159. three letters.  Yet they will still contain the original name of
  160. the file so that the contents of the file can easily be determined
  161. by name.  For example, suppose you have two applications,
  162. APP1.EXE and APP2.EXE.  You would know that the files AP1_INIT.C and
  163. AP1_DLG.C both are part of application 1.  You also know that
  164. AP1_PNT.C and AP2_PNT.C contain the paint routines for each
  165. application.
  166.  
  167. The make file and module definition file should be changed to use the
  168. name of your application, not just an abbreviation.  Using the
  169. above example, your make file for application 1 would be APP1.MAK and
  170. the module definition file would be APP1.DEF.
  171.  
  172. Remember to change all references to files in your make file to
  173. match the name changes you make.  If you change header file names,
  174. also be sure to change all #include statements in the source
  175. and resource files that refer to those header files.
  176.