home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Appearance SDK / Tools / DumpControlHierarchy FKEY / DumpControlHierarchy.c next >
Encoding:
Text File  |  1998-01-27  |  2.4 KB  |  80 lines  |  [TEXT/CWIE]

  1.     //
  2.     //    DumpControlHierarchy FKEY, © 1997 Apple Computer, Inc.
  3.     //    Complaints and kudos to Pete Gontier <devsupport@apple.com>
  4.     //
  5.     //    WHAT IS IT?
  6.     //    ===========
  7.     //
  8.     //    It's a very simple diagnostic tool for developers using the
  9.     //    control hierarchy facilities in Appearance. It asks the user
  10.     //    to save a file, and then writes a profile of the control
  11.     //    hierarchy in the frontmost window to that file.
  12.     //
  13.     //    HOW DO I RUN IT?
  14.     //    ================
  15.     //
  16.     //    It's an FKEY, not to be confused with the function keys
  17.     //    appearing in a row across the top of some keyboards (F1,
  18.     //    F2, etc.). FKEYs are documented (a bit) in Inside Macintosh:
  19.     //    Macintosh Toolbox Essentials on page 2-39. What's not
  20.     //    documented is how to install them. During GetNextEvent,
  21.     //    if an appropriate key sequence is detected, Event Manager
  22.     //    calls GetResource to obtain the FKEY resource. GetResource
  23.     //    searches the current chain of resource maps, including that
  24.     //    of the current application and the System File. So you can
  25.     //    install an FKEY anywhere in the current resource map chain.
  26.     //    Just copy and paste the FKEY resource with Resorcerer (or
  27.     //    ResEdit if you must...). Usually FKEYs are installed in the
  28.     //    System file. Unfortunately, nothing arbitrates the resource
  29.     //    IDs of FKEYs, so be careful.
  30.     //
  31.     //    LEGAL NOTICE
  32.     //    ============
  33.     //
  34.     //     You may incorporate this sample code into your applications
  35.     //     without restriction. This sample code has been provided "AS
  36.     //     IS" and the responsibility for its operation is 100% yours.
  37.     //     You are not permitted to redistribute the source as "Apple
  38.     //     sample code" after having made changes. If you're going to
  39.     //     re-distribute the source, we require that you make it clear
  40.     //     in the source that the code was descended from Apple sample
  41.     //     code, but that you've made changes.
  42.     //
  43.  
  44. #define OLDROUTINELOCATIONS        0
  45. #define OLDROUTINENAMES            0
  46. #define SystemSevenOrLater        1
  47.  
  48. #ifndef __APPEARANCE__
  49. #    include "Appearance.h"
  50. #endif
  51.  
  52. #ifndef __STANDARDFILE__
  53. #    include <StandardFile.h>
  54. #endif
  55.  
  56. #ifndef __A4STUFF__
  57. #    include <A4Stuff.h>
  58. #endif
  59.  
  60. void pascal main (void)
  61. {
  62.     WindowPtr frontWindow = FrontWindow ( );
  63.  
  64.     if (!frontWindow)
  65.         SysBeep (-1);
  66.     else
  67.     {
  68.         long preservedA4 = SetCurrentA4 ( );
  69.  
  70.         StandardFileReply sfr;
  71.  
  72.         StandardPutFile ("\pDump control hierarchy as:", "\pcontrol hierarchy dump", &sfr);
  73.  
  74.         if (sfr.sfGood && (DumpControlHierarchy (frontWindow, &(sfr.sfFile))))
  75.             SysBeep (-1);
  76.  
  77.         SetA4 (preservedA4);
  78.     }
  79. }
  80.