home *** CD-ROM | disk | FTP | other *** search
/ Better Windows, Better Works / CDRM93801.bin / winutil / util42 / pundit.txt < prev    next >
Text File  |  1991-11-20  |  20KB  |  536 lines

  1.  
  2. -----------
  3. Pundit v1.1
  4. -----------
  5.  
  6.  
  7.                      -- INTRODUCTION --
  8.  
  9. Pundit is a Microsoft Windows 3.0 program that pops up a
  10. window to display a quotation, fortune, or other basically
  11. useless (but hopefully entertaining) saying.  The window
  12. remains on the screen for a given amount of time then
  13. disappears, to return with a new quote later.
  14.  
  15. The amount of time that the window remains on the screen
  16. and the amount of time that it stays hidden may both be set
  17. by the user.
  18.  
  19. This program has two purposes:
  20.  
  21.     1) to be a (mildly) amusing diversion and excuse for
  22.        why you couldn't get that Excel spreadsheet done
  23.        on time
  24.  
  25.     2) to provide budding Windows programmers with an
  26.        example of some of the things that can be done
  27.        with Windows 3.0
  28.  
  29. This program is "shareware"; it is copyrighted, but is
  30. being made available to the outside world by the author.
  31. Feel free to distribute this program to your friends, but
  32. please stay within the following restrictions:
  33.  
  34.     1) No charge may be made for distribution of this
  35.        program beyond the nominal fees charged by
  36.        organizations that are in the "business" of
  37.        distributing "shareware".
  38.  
  39.     2) The entire package (executable, source, icon,
  40.        documentation, etc.) MUST be distributed together.
  41.        It is not fair for you to benefit from having the
  42.        source code if you won't share it.
  43.  
  44.     3) No modifications may be made to the distributed
  45.        program (especially the copyright notice).  You may
  46.        make changes in your own copy (such as changing the
  47.        quotations) so long as you DO NOT change the
  48.        copyright notice and you distribute the original in
  49.        exactly the same condition in which you received it.
  50.  
  51.  
  52. If you like this program, a donation of $5 (five dollars)
  53. would be appreciated --- this will not make me rich, but it
  54. will encourage me to release more programs (with source).
  55. Send any donations to:
  56.  
  57.                        Jeff Bienstadt
  58.                 13305 NE 171st Street  #D130
  59.                    Woodinville, WA  98072
  60.  
  61. (For those of you who have Version 1.0, please note the
  62. change of address).
  63.  
  64. If you have any questions or comments about this program, I
  65. would love to hear from you (this includes Windows Wizards
  66. with comments about how to improve it).  I can be reached
  67. at the above address or on CompuServe at 72200,3477.
  68.  
  69.  
  70.  -- Files in the Distribution --
  71.  
  72. The distribution contains the following files:
  73.  
  74.     PUNDIT.EXE    The executable program
  75.     PUNDIT.TXT    This file
  76.     PUNDIT.H      Header file containing important constants
  77.     PUNDIT.C      The C source for the main program
  78.     SETTINGS.C    The C source for the Settings dialog, etc.
  79.     EXTRAS.C      The C source for some Windows extras
  80.     EXTRAS.H      Header file for EXTRAS
  81.     PUNDIT.RC     The resource file
  82.     STRINGS.TBL   The string table with the quotations
  83.     PUNDIT.ICO    The Icon
  84.     PUNDIT        The Make file (for NMAKE)
  85.     PUNDIT.DEF    The Linker Definition File
  86.     PUNDIT.HLP    The Help File
  87.     PUNDIT.RTF    The source for the Help File
  88.     PUNDIT.HPJ    The Help Project File (for HC)
  89.  
  90. Please be sure that you have all of these files in your distribution
  91.  
  92.  
  93.  
  94.  -- Changes from Version 1.0 --
  95.  
  96. Several things about Pundit have changed since version 1.0.
  97. Among them are:
  98.  
  99.     Pundit now maintains its own .INI file.
  100.     Version 1.0 save its settings in the WIN.INI file, which
  101.     cluttered up that file, and slowed down the saving and
  102.     retrieving of settings.  Settings are now saved in PUNDIT.INI.
  103.  
  104.     Quote categories.
  105.     You may now choose from several different catgegories of quotes
  106.     for Pundit to display, or you may have Pundit choose a category.
  107.     Also, there are more quotes to play with.
  108.  
  109.     Hide mode choices.
  110.     Version 1.0 simply hid the window when Pundit was "out".  Now you
  111.     may choose between hiding the window or making it an icon.
  112.  
  113.     Clipboard Support.
  114.     The quote currently displayed in the Pundit window may now be
  115.     copied to the Windows Clipboard.
  116.  
  117.     Help.
  118.     Pundit 1.1 now provides help.
  119.  
  120.  
  121.  
  122.                      -- USER'S GUIDE --
  123.  
  124. Pundit is very easy to use.  Run it by any of the
  125. "normal" Windows methods of launching a program.
  126.  
  127. When Pundit starts up, it will place a window near the
  128. upper-left corner of your screen, and display a quotation
  129. in the window.  After about 5 seconds, the window will
  130. vanish.  About 20 seconds later, the window will reappear,
  131. displaying a new quotation, and the cycle will start over
  132. again.
  133.  
  134.  
  135.  
  136.  -- The Menu --
  137.  
  138. Besides the "system" menu (for sizing, etc.) Pundit
  139. contains three selections on the main menu.
  140.  
  141.     Choices     Control whap Pundit does
  142.     Edit        Copy the quote to the clipboard
  143.     Help        Get help
  144.  
  145.  
  146. Once the menu is activated, Pundit will suspend counting
  147. seconds, and will stay active while you work. (It would be
  148. somewhat disconcerting to have the window disappear while
  149. you are deciding what to do.)
  150.  
  151. Following is a description of the Pundit menu selections:
  152.  
  153.  
  154.     Choices Menu
  155.  
  156.     The Choices menu contains four items:
  157.  
  158.         Categories Menu
  159.  
  160.         This selection brings up a sub-menu with categories
  161.         of quotes.  You may choose from:
  162.  
  163.             Quotes  Quotations from various people
  164.             Laws    Murphy's laws and other laws
  165.             Snigs   "Sniglets"* -- Definitions of unreal words
  166.             Misc    Odd little "sayings"
  167.             Random  Pundit will choose from one of the above
  168.                     catetories.
  169.  
  170.             When one of these items is selected, Pundit will
  171.             choose a new quote from the new category and display
  172.             it.
  173.  
  174.             When Pundit exits, the current category choice will be
  175.             saved, and that will be the category used the next time
  176.             Pundit is run.
  177.  
  178.  
  179.         Settings...
  180.  
  181.         Choosing the "Settings..." memu item brings up a dialog box
  182.         which will allow you to change the amount of time that the
  183.         window is displayed and hidden, and the foreground and
  184.         background colors of the text window.
  185.  
  186.         Change the time that the Pundit window is visible or hidden
  187.         with the two scroll bars labeled "Seconds In" (the number of
  188.         seconds that the window is visible) and "Seconds Out" (the
  189.         number of seconds that the window is hidden).
  190.  
  191.         The amount of time that the window is visible ranges from
  192.         1 second to 60 seconds (1 minute).  The amount of time that
  193.         the window is hidden ranges from 1 second to 3600 seconds
  194.         (1 hour).
  195.  
  196.         Use the three scroll bars labeled "Red", "Green" and "Blue"
  197.         to control the color for the Pundit text window.  You may
  198.         select colors for the foreground and background by selecting
  199.         one of the radio buttons labeled "Foreground" and "Background".
  200.  
  201.         As you change the color values, a text box will display an
  202.         example of what the text will look like using that color
  203.         combination.
  204.  
  205.         There are also three buttons -- "OK", "CANCEL", and
  206.         "Save Settings" -- that determine what happens to the
  207.         settings you change.
  208.  
  209.         Pressing the "OK" button will make Pundit act on your
  210.         changes for now, but will NOT save them; the next time you
  211.         run Pundit the settings will revert to what they were
  212.         before you changed the settings.
  213.  
  214.         Pressing the "CANCEL" button will ignore the changes you
  215.         make and Pundit will continue on as before.
  216.  
  217.         Pressing the "Save Settings" button will save your settings
  218.         choices in the WIN.INI file.  You will also be asked if you
  219.         want to save the current position and size of the window
  220.         (in case you moved or resized it).  Pressing the "Yes"
  221.         button will save the current size/position as well as the
  222.         new timer values.  Pressing the "No" button will save the
  223.         new timer values, but not the size/position.
  224.  
  225.         Pressing the "Save Settings" button will NOT exit the
  226.         dialog box; you will need to press the "OK" or "CANCEL"
  227.         buttons to return Pundit to its normal operation.
  228.  
  229.  
  230.         NoShow
  231.  
  232.         The NoShow menu item brings up a sub-menu which allows you
  233.         to control what happens to the Pundit window when it is not
  234.         displaying a quote.
  235.  
  236.             Hide        Causes the window to vanish when not active.
  237.                         When the window is "out", there will be no
  238.                         trace of the window (even on the Task List).
  239.             Iconize     Causes the window to become an icon when not
  240.                         active. The window will display an icon along
  241.                         with any other inactive applications you may
  242.                         have.
  243.  
  244.  
  245.         Exit
  246.  
  247.         The Exit selections terminates Pundit.  The current settings
  248.         for the Categories and NoShow menu selections are saved.
  249.  
  250.  
  251.     Edit Menu
  252.  
  253.     The Edit menu contains one selection, Copy, which copies the
  254.     current quote into the Windows Clipboard.  Once in the clipboard,
  255.     the quote may be copied into another application.
  256.  
  257.  
  258.     Help Menu
  259.  
  260.     The Help menu contains these menu items:
  261.  
  262.         Index
  263.  
  264.         Brings up the Windows Help system, starting with the index
  265.         for Pundit's help text.
  266.  
  267.  
  268.         Using Help
  269.  
  270.         Brings up the Windows Help system, starting with help text
  271.         describing how to use the Help system.
  272.  
  273.  
  274.         About...
  275.  
  276.         Displays an "About Box" describing Pundit.
  277.  
  278.  
  279.  
  280.  -- PUNDIT.INI --
  281.  
  282. The information about Pundit's settings are saved in a file called
  283. PUNDIT.INI.  This file is an ASCII text files containing a line for
  284. each of the items
  285.  
  286.     InSecs=n    number of seconds the window is shown
  287.     OutSecs=n   number of seconds the window is hidden
  288.     X=n         the X position (column) of the window
  289.     Y=n         the Y position (row) of the window
  290.     Width=n     the width of the window
  291.     Height=n    the height of the window
  292.     Back=n n n  the Red, Green, and Blue color values for the background
  293.     Fore=n n n  the Red, Green, and Blue color values for the foreground
  294.     Category=n  the quote category
  295.     Hide=n      the hide mode
  296.  
  297.     (in the above, n represents a number)
  298.  
  299. Deleting any of these item will cause Pundit to revert
  300. to its "default" behavior for that item.
  301.  
  302.  
  303.  -- Caveats --
  304.  
  305.     1)  Pundit does NOT know what is happening with any
  306.         other window, so when Pundit pops up it may
  307.         disrupt what you are doing. This includes making
  308.         the menus on other windows go away, and canceling
  309.         the "Switch to..." dialog box.
  310.         This is true for the Windows Help system as well as
  311.         any other window.  If you activate Help from Pundit,
  312.         the Pundit window may "go away" while you are in Help.
  313.         Also, any keyboard operations you may be performing
  314.         will suddenly stop when Pundit pops up, unless you
  315.         re-activate the window you were working in.  Control
  316.         of the window you were working in will be restored
  317.         when Pundit hides its window.
  318.  
  319.     2)  If you are blazing fast and furious with the mouse
  320.         in some Windows application (such as Solitiare),
  321.         you may notice that your application froze for a
  322.         moment and is suddenly being repainted.  Don't
  323.         panic!  All that happened is that Pundit popped up
  324.         on top of that application (temporarily de-activating
  325.         that application's window) and you clicked the
  326.         mouse somewhere within the application windows'
  327.         client area that was not covered by Pundit, and
  328.         your original application was brought back up to
  329.         the fore and the client are was repainted.
  330.         This is sometimes annoying, but not fatal.
  331.  
  332.     3)  A few of the quotations in Pundit were formatted
  333.         to use multiple lines (such as a poem or cheer).
  334.         The default size of the window is really not big
  335.         enough to display these quotations correctly, so
  336.         they may wrap strangely at the right edge of the
  337.         window or may be clipped at the bottom edge.  When
  338.         these quotations are displayed, you have two
  339.         choices:
  340.  
  341.             a)  Resize the window to give more room for the
  342.                 quotation, or
  343.  
  344.             b)  Ignore the quotation altogether
  345.  
  346.  
  347.     4)  Pundit uses the rand() function in the Microsoft
  348.         C 6.0 library.  This is a fairly good random-number
  349.         system, but it is NOT perfect, so it is possible
  350.         that some quotations may repeat themselves while
  351.         others may not show up at all.  To be fair, when
  352.         Pundit starts up,  I call the srand() function,
  353.         passing it part of the current system time. This is
  354.         probably NOT the best way to seed the random-number
  355.         generator, but it is one of the most convenient, so
  356.         I will accept part of the blame for repeated text.
  357.  
  358.  
  359.  
  360.                -- PROGRAMMER'S INFORMATION --
  361.  
  362. Pundit is distributed with the complete source code,
  363. heavily commented.  In some places the comments tend to
  364. severely clutter up the listing, so if you want to remove
  365. some of the comments to improve readability, please do so
  366. (remembering that you may not distribute it that way).
  367.  
  368. It is not my intention to fully explain how each aspect of
  369. the code works -- you can look up most of it in the Windows
  370. SDK documentation -- but I do want to make a few points
  371. about some of the interesting(?) things this program makes
  372. use of.  Among these are the use of the STRINGTABLE
  373. resource, private messages, and an error in the Windows SDK
  374. documentation.
  375.  
  376. When reading the source code, beware of where the commas
  377. are.  For some of the internal strings, I have used the C
  378. language's string constant concatenation feature to
  379. "improve" readability of the string constants.
  380.  
  381.  
  382.  -- The STRINGTABLE --
  383.  
  384. All of the quotations used by this program are contained
  385. within a STRINGTABLE resource in Pundit.rc.  Some of
  386. these strings are made up of more than one line.  If you
  387. look at the quotes in Pundit.rc, you will see that some
  388. of them contain the substring \012.  This is an octal
  389. (base 8) contant that represents a LineFeed, and tells
  390. Windows to break the line at that point.  I have indented
  391. each new line by two spaces in order to help visually
  392. separate "real" line breaks from line breaks that Windows
  393. has produced.
  394.  
  395. You may also notice an occasional substring of \042. This
  396. allows the use of the double-quote character (") within a
  397. string.
  398.  
  399. The primary advantage to the STRINGTABLE resource is that
  400. Windows loads the strings into memory ONLY WHEN IT NEEDS
  401. TO, rather than having them taking up precious memory for
  402. the entire time Pundit is running.  Also, it makes it
  403. easier to modify (or add or delete) quotations -- only the
  404. resource needs to be recompiled and linked rather than the
  405. C source file.
  406.  
  407. Having the quotations contained within the .EXE file as a
  408. resource does make for a fairly large .EXE file, but there
  409. is one very important point to remember:  in Windows programs,
  410. the size of the .EXE file often has very little to do with
  411. the amount of memory actually required to run the program.
  412. Since a good part of the PUNDIT.EXE is resources, and these
  413. resources are loaded ONLY WHEN REQUIRED, Pundit really does
  414. not eat that much memory.
  415.  
  416. NOTE:
  417.     In the PUNDIT.H file, there are #define'd constants
  418.     that determine that starting position and number of
  419.     strings for each category in the STRINGTABLE. If you
  420.     change the STRINGTABLE, these contants MUST change
  421.     to reflect your changes or Pundit will behave
  422.     badly.
  423.  
  424. NOTE:
  425.     Some of the entries in the STRINGTABLE are lines that
  426.     exceed 200 characters.  If your editor imposes a maximum
  427.     line length (such as Brief) you may need to either use
  428.     a different editor (The Norton Editor will handle very
  429.     long lines), or reconfigure your editor to accept a
  430.     longer line (you can do this for Brief in the "setup"
  431.     program).
  432.  
  433.  
  434.  
  435.  -- Private Messages --
  436.  
  437. Windows Programs are not limited to the Messages described
  438. in WINDOWS.H -- you may Send, Post, and process your own
  439. messages if you wish.  Pundit uses three private messages,
  440. PM_START, PM_PAUSE (which are used to inform Pundit to start
  441. and suspend the timer), and PM_DLGPAINT (which is used to help
  442. in painting the color example in the settings dialog box.  These
  443. private messages are given values higher than that of WM_USER in
  444. order to ensure that they do not conflict with the standard
  445. Windows Messages.
  446.  
  447.  
  448.  -- Knowing About the Menu --
  449.  
  450. One important consideration when designing a program like
  451. this is that you do not want the window to vanish when a
  452. menu is up and the user is deciding what he/she wants to
  453. do.  Also, if the user decides to cancel the menu (with the
  454. ESC key or clicking outside the menu area), the program
  455. needs to return to normal operation.
  456.  
  457. Fortunately, Windows provides a couple of Messages to help
  458. in this situation, namely WM_INITMENU and WM_MENUSELECT.
  459. Unfortunately, the documentation for WM_MENUSELECT is
  460. incomplete and slightly incorrect (at least in my copy of
  461. the SDK).
  462.  
  463. When the user activates a menu, Windows sends a WM_INITMENU
  464. Message to the application.  This is great, since it allows
  465. us to know that a menu was activated and gives us the
  466. opportunity to shut down the timer while the menu is up,
  467. thus preventing our window from vanishing for a while.
  468.  
  469. Windows also sends a WM_MENUSELECT message each an item is
  470. selected (highlighted) on that menu, and the wParam and
  471. lParam values contain information about what was selected.
  472. But here's where the problems come in: the documentation
  473. for the WM_MENUSELECT message says:
  474.  
  475.     If the low-order word of the lParam parameter contains
  476.     -1 and the high-order word of the wParam parameter
  477.     contains 0, Windows has closed the menu because the user
  478.     pressed ESC or clicked outside the menu.
  479.  
  480. First of all, there is what appears to be a typographical
  481. error in this description: what need to be checked for 0 is
  482. the high-order word of lParam, not wParam (wParam does not
  483. have a high-order and low-order word -- it is just one
  484. word).
  485.  
  486. That's the slightly incorrect part; the incomplete part is
  487. that what they don't tell you is that the conditions of
  488. wParam and lParam apply whenever Windows closes the menu
  489. EVEN IF THE USER CHOSE A MENU ITEM!  (Run the Windows SDK
  490. "Spy" utility on an application and choose a menu item --
  491. you'll see the Message).
  492.  
  493. Because of this situation, we have to shut down the timer
  494. for Pundit when we enter a dialog box (unless we want the
  495. main window to vanish while a dialog box is active).  This
  496. is done by processing the WM_INITDIALOG Message and shutting
  497. down the timer in each of the two dialog boxes in Pundit.
  498.  
  499. This is by no means as bad a situation as it sound here.
  500. It was just a little annoying, since it was not documented
  501. correctly, and it took a little time to track down (thank
  502. Microsoft for "Spy"!)
  503.  
  504.  
  505.  
  506.  -- Suggested Enhancements --
  507.  
  508. The source code to Pundit is provided both as an example of some
  509. Windows code and so that you may change the program to suit you.
  510. Just remember not to incorporate your changes into the distribution
  511. files.
  512. Some things that you might want to do are:
  513.  
  514.     Alter the ranges for Time In and Time Out.  The ranges that I
  515.     initially programmed in are pretty arbritrary.
  516.  
  517.     Add more quotes or even more categories.
  518.  
  519.     Allow Pundit to remain "on hold" when Help is activated.
  520.         Hint:   You might try getting the window handle
  521.                 for the Help window, and fetching the caption.
  522.  
  523.  
  524.  
  525. I hope that those of you who are newer to programming for
  526. Windows than I am will benefit from all this, and that
  527. those of you who are more experienced will point out any
  528. errors or improvements.
  529.  
  530.  
  531. Thank you ---
  532.  
  533.                 Jeff Bienstadt
  534.  
  535.  
  536.