home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 21307 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  6.5 KB

  1. Path: sparky!uunet!stanford.edu!unix!css-mac1.sri.com!user
  2. From: mxmora@unix.sri.com (Matthew Xavier Mora)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: CSMP One-liners (Request for updates)
  5. Message-ID: <mxmora-120193101003@css-mac1.sri.com>
  6. Date: 12 Jan 93 18:15:43 GMT
  7. Sender: news@unix.SRI.COM
  8. Followup-To: comp.sys.mac.programmer
  9. Organization: SRI International
  10. Lines: 159
  11.  
  12. I'm putting the finishing touches on the new UMPG and would like any
  13. updates for the oneliners section. I haven't seen Eric post in a 
  14. while is Eric still on the net?
  15.  
  16. I think there is another one to add:
  17.  
  18. If you use SetGWorld then don't use SetPort.
  19.  
  20. Maybe someone can explain why.
  21.  
  22.  
  23. Below is the list to refresh your RAM.
  24.  
  25. Xavier
  26.  
  27. ---------------------------
  28. Oneliner's
  29.  
  30. Compiled by Eric Pepke
  31. Additional material by Steve Maker, Keith Rollin, Gregory Dudek, Brian
  32. Bechtel,
  33. Henry Minsky, Carl C. Hewitt, Jim Lyons, Alex Lau, Kent Borg, Peter W.
  34. Poorman,
  35. Ross Yahnke, Mark Fleming, Mark Anderson.
  36.  
  37. Send suggestions to pepke@gw.scri.fsu.edu on the
  38. Internet or PEPKE@FSU on BITNET.  Have fun.
  39.  
  40.  
  41.  
  42. The Main Loop and Events
  43.  
  44. Call MaxApplZone and MoreMasters when the application starts up.
  45. If you call SetApplLimit, do it before calling MaxApplZone.
  46. Use HT in MacsBug while running to estimate how many times to call
  47. MoreMasters.
  48. Don't use SetEventMask to disable mouseUp events.  Better not to use it at
  49. all.
  50. SetPort to a known good grafPort once every time through the event loop.
  51. Calling WaitNextEvent with more than 50 ticks will fail on some systems.
  52. Set the cursor on suspend and resume events.
  53. Call GetDblTime to get the maximum time for a double click.
  54. Measure double click time from mouse up to mouse down.
  55. Call either WaitNextEvent or both GetNextEvent and SystemTask.
  56. Call IsDialogEvents and DialogSelect even if GetNextEvent returns false.
  57.  
  58. Menus
  59.  
  60. Use SetItem to include meta characters literally in menus.
  61. Never make MENU resources purgeable.
  62.  
  63. Resources
  64.  
  65. GetResource never produces resNotFound.  Check for a NIL handle instead.
  66. To create a resource file, call Create, then CreateResFile.
  67. To open a resource file read-only for shared access, use OpenRFPerm.
  68. Don't leave ResLoad set to false.
  69. GetResource on a dctb may return a non-resource copy of the dctb.
  70.  
  71. Windows, Alerts, and Dialogs
  72.  
  73. Drag windows to the bounding box of GetGrayRgn.
  74. Hide scroll bars when deactivating a window.
  75. Call DrawGrowIcon when activating or deactivating a window with a grow
  76. region.
  77. DrawGrowIcon does not check to see if the window has a grow region.
  78. Call PenNormal before calling DrawGrowIcon.
  79. itemHit will not be set when a dialog filter is called.
  80. Use a disabled UserItem to draw the roundrect outline around the OK button.
  81. ModalDialog assumes the dialog is already visible and in the front.
  82. Use screenBits . bounds to center dialogs, alerts, etc. below the menu bar.
  83. If you save window locations in files, they may not be valid for all
  84. monitors.
  85. DragWindow expects startPt in boundsRect; if not it may not call
  86. SelectWindow.
  87. SelectWindow does not automatically call SetPort.  You must do that
  88. yourself.
  89. DialogSelect responds to activate events but ignores suspend/resume events.
  90. Call PenNormal before calling DrawControls.
  91. The Control Manager only works when the origin of a window is at (0, 0)
  92. To find the position of a window, use LocalToGlobal on the origin.
  93.  
  94. Drawing
  95.  
  96. Always set the VisRgn and ClipRgn of offscreen ports.
  97. Set the ClipRgn first when making a picture.
  98. Don't make rowBytes in bitMaps greater than 8191.
  99. To dim text, draw a rectangle with penPat=gray and penMode=patBic over it.
  100. To draw rotated text, draw to an offscreen bitmap, rotate it, and CopyBits
  101. it.
  102. Don't use picSize to determine the size of a picture.  Check the handle
  103. size.
  104. Never draw outside a window except in XOR mode for temporary effects like
  105. drag.
  106. To avoid animation flicker, synchronize drawing to the vertical retrace.
  107. Lock handles to pictures before calling DrawPicture.
  108. CopyBits on more than 3Kb data will work, but it might have to allocate
  109. memory.
  110. The small Mac screen is 512 pixels wide by 342 pixels high including menu
  111. bar.
  112.  
  113. Interrupts and VBL Tasks
  114.  
  115. Don't call any Memory Manager routines during an interrupt.
  116. Unlocked handles may not be valid during an interrupt.
  117. To synchronize to the vertical retrace on Macs with slots, use
  118. SlotVInstall.
  119.  
  120. Files
  121.  
  122. Don't write in the application file.  This will fail with read-only
  123. devices.  
  124. Use PBGetVInfo to convert a VRefNum to a volume name. 
  125. Delete uses the Poor Man's Search Path, so don't delete blindly.
  126. File Manager routines with dirID=0 use the Poor Man's Search Path.
  127. Truncate and reallocate files before overwriting to reduce fragmentation.
  128. Check/change the creator and type of Save As... files before overwriting.
  129. If you rewrite files by deleting and creating, copy all Finder information.
  130. Directory ID's are longs, not shorts.  Shorts work ALMOST all the time.
  131. If a file version number appears in a file manager call, always set it to
  132. 0.
  133. To convert a pathRefNum to a name or file number, use PBGetFCBInfo.
  134. Prevent the creation of files with names that begin with a period.
  135. Write/update the Finder info before writing data or resource forks.
  136.  
  137. Handles and Pointers
  138.  
  139. Lock handles before passing their dereferenced pointers to any routine.
  140. Lock handles before setting referenced data to expressions containing
  141. functions
  142. Put an odd long at location zero on a 68000 to help find NIL handle
  143. references.
  144. Call MoveHHi before locking a handle to avoid memory fragmentation.
  145. Use HGetState/HLock/HSetState to lock a handle then put it back as it was.
  146.  
  147. General
  148.  
  149. Always use unsigned characters within text and Pascal-format strings.
  150. Save application preferences in a folder named Preferences in the System
  151. Folder
  152. Use SysEnvirons to find the System (Blessed) Folder.
  153. Use GetAppParms to get the name of the application.
  154. The high bit of SysParam . volClik enables the alarm clock.
  155. Check the application name at $910 before exiting with ES within MacsBug.
  156. To exit to shell in the mini-debugger, enter SM 0 A9 F4 and then G 0.
  157. In Pascal, don't nest procedures to be passed by procedure pointer.
  158. In Pascal, "with theHandle^^" is unsafe if memory compaction can occur.
  159.  
  160. Controversy Corner (Don't shoot me; I'm just the messenger.)
  161.  
  162. Avoid writing tail patches for traps.
  163. There is no official way to tell if MultiFinder is running or not.
  164.  
  165.  
  166. --
  167. ----------------------------------------------------------------------
  168. Matthew Xavier Mora                                mxmora@unix.sri.com
  169. SRI International                                       (415) 859-5011
  170. ----------------------------------------------------------------------
  171.