# More MAC Programming Techniques 1995 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-015dc5cd6590de4c89001b1101ad0874d869fb12c9cd7e3a357d7ad01c460cc4)

Transcribed text:

New Technology Building Blocks

More MAC Programming Techniques

DISK INCLUDED

• Customize your Macintosh programs

• Create file resources

• Use custom controls

• Includes examples in both Symantec C++ and Metrowerks CodeWarrior

M&T BOOKS

Dan Parks Sydow

Image description: A book cover with a dark and purple background, a large yellow-orange title, a bullet list on the left beside a floppy disk icon, and a photo of a keyboard, floppy disk, and abstract colored shapes on the right.

Reading notes: The small 'DISK INCLUDED' label and the M&T BOOKS logo text are small but appear legible; the 'New Technology Building Blocks' tagline is printed in spaced italic at the top and is read as a series label.

Printed product names: Symantec C++ · Metrowerks CodeWarrior

Languages: English

[Original Image 1](https://www.vintageapple.net/files/e849034cd612e3c938cbbc925492d7568458e704dfcb3d13b5d5a63b9fa5de43/3ca7b27050ba8b5ed518b6d5.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-98a75e94a94267cba28726930b4160072e27976ec42aad2eb92eed2bb3b34e00)

Transcribed text:

New Technology Building Blocks

More MAC Programming Techniques

DISK INCLUDED

• Customize your Macintosh programs

• Create file resources

• Use custom controls

• Includes examples in both Symantec C++ and Metrowerks CodeWarrior

M&T BOOKS

Dan Parks Sydow

Image description: A book cover with a dark purple and black background, large yellow-orange title type, a floppy disk icon, bulleted feature list, and a photo of a keyboard and floppy disks in blue, pink and orange tones.

Reading notes: Small logo text on the M&T Books mark is stylized and may not be fully legible; 'M&T BOOKS' reading is inferred from the logo.

Printed product names: Symantec C++ · Metrowerks CodeWarrior

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-3ae2fc1e6fb21ae051a50a2e4fe1690274ebf1bfbbfdb564e72ed7437c3c8c9d)

Image description: The image is a plain, blank white page with no visible artwork, text, or layout elements.

Reading notes: The image appears entirely blank with no visible text, so the transcript and printed fields are empty.

[Original PDF page 2](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-283e238f303365ebaf4fdd1bd2d725182727ea79f86e2c3cd214e99dd6df9145)

Transcribed text:

Contents
Introduction   .................................................... 1
What's on the Disk .............................................................................. 2
What You Need .................................................................................... 3
Why This Book is for You .................................................................... 3
Chapter 1: Custom Menus and the MDEF......... 5
The MDEF and Menu Definition   Procedure   .................................... 6
Setting   the MDEF ID of a   MENU   Resource ................................. 7
The MDEF Defines the Look and Actions of a Menu ................. 8
Creating and   Using   an MDEF Code Resource ........................... 11
The MDEF   Source   Code ................................................................... 14
The Menu Definition   Procedure   Entry   Point   ............................ 15
Taking Care of the Preliminaries ..   ..   ..   ..   ..   ...   ..   ..   ..   ....   ...   ..   ..   ..   ....   ..   ..   ...   ..   ..   . 19
Handling an   mSizeMsg   Message ................................................. 22

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-4aa4a8c02ebc62d690cfbdcee17d3c92ec50c63537ff797443282f77bcfbf289)

Transcribed text:

More Mac Programming Techniques
Handling an mDrawMsg Message ............................................... 23
Handling an mChooseMsg Message ........................................... 27
The MyMDEF   Source   Code Listing ............................................ 34
Building the MDEF Code Resource ................................................. 37
Building with CodeWarrior ......................................................... 39
Building with Symantec C++   /THINK C .....................................   40
The MDEF Test Application ............................................................. 42
What the Test Application Does   .................................................. 43
The Test Application Resources .................................................. 43
The Test Application   Source   Code ............................................. 4   7
Cl1apter   Summary   ............................................................................. 55
Chapter 2: Custom   Controls   and the CDEF   ....   57
The CDEF and Control Definition Function .................................. 58
Setting   the CDEF ID of a CNTL Resource ................................. 59
The   CDEF   Defines the Look and Actions of a   Control   .................. 62
Tl1e   CDEF   Source   Code   .................................................................... 63
The   Control   Definition Function Entry Point ........................... 64
Taking   Care   of the   Preliminaries   ................................................ 67
Handling a testCntl Message ....................................................... 71
Handling a   drawCntl   Message ..................................................... 74
The MyButtonCDEF   Source   Code   Listing   ....................................... 84
Building the   CDEF   Code   Resource .................................................. 88
Building with   Code Warrior ......................................................... 88
Building with Symantec   C++/THINK   C .....................................   90
The   CDEF   Test Application .............................................................. 92
V\'hat   the Test Application Does .................................................. 92
The Test Application Resources ....................................................... 95
The Test Application   Source   Code   ...........................................   102
Adding a   Second   Button to MyTestApp   .........................................   108
Changing   the MyTestApp Resource File ..................................   108
Building a New MyTestApp Application ...................................   110
Adding   Control   Variation Handling to MyButtonCDEF .............. 112
vi

Reading notes: Source appears to be a table of contents; page numbers and dot leaders are not body text.

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-f9bca257e25fbe4714f38e1871c255d6614d068a2e8291e645cb335288844a8f)

Transcribed text:

Contents
Changing the MyTestApp Resource File .................................. 112
The CDEF   Source   Code for Control Variations   ....................... 115
Adding More Control Variations to a CDEF ............................ 123
Chapter   Summary   ........................................................................... 125
Chapter 3: More Custom   Controls:   Sliders   ....   127
The CDEF and   Slider   Controls ...................................................... 128
Drawing the   Slider   Control and Indicator ............................... 128
The   Slider   Resources ...   ..   ..   ..   ..   .....   ...   ..   ....... ..   ..   ..   ...   ...   ..   ...   ...   ..   ..   ..   ..   .   ..   ..   ..   .. 131
Slider   Control   Source   Code ....   ....   .. ..   ..   ..   ...   ..   ..   ..   ..   ..   ..   ..   ..   ..   ..   ..   ..   ...   ...   ..   ...   ..   ..   . 134
The   Slider   CDEF Entry Point .................................................... 135
Taking Care of the Preliminaries .............................................. 138
Calculating the Thumb Rectangle ............................................ 139
Handling a testCntl Message ..................................................... 144
Calculating the Thumb Region   ................................................. 145
Handling a thumbCntl Message ............................................... 148
Handling a posCntl Message ..................................................... 155
Handling a drawCntl Message   ................................................... 159
Building the CDEF Code Resource .......................................... 161
The   Slider   Test Application ............................................................ 161
The Test Application Resources ................................................ 162
The Test Application   Source   Code ........................................... 164
Sliders   and Custom Dragging   ......................................................... 166
The CDEF Messages   ................................................................... 166
Handling a dragCntl Message ................................................... 168
Smoother Custom Dragging   ........................................................... 174
Adding New PICT Resources .................................................... 174
Taking Care of the Preliminaries ..   ..   ..   ..   ..   ..   ..   ..   ...   ...   .. .. .. ..   ...   .. ..   ... .. .... 177
Handling a dragCntl Message ................................................... 178
Handling a drawCntl Message ...................................................   180
Covering the   Old   Thumb .......................................................... 183
Adding a Label to the Control .................................................. 185
Chapter   Summary   ........................................................................... 187
vii

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-c46ff7efe79c5d8415d3b97098c1f732c87bbbb99ef49fecaf512dd205d13594)

Transcribed text:

More Mac Programming Techniques
Chapter 4:   Control   Panels   and cdevs   ..........   189
Control   Panels   and the Finder .......................................................   190
A Control Panel or an Application? .......................................... 193
(~011   trol   Panel   Resources   ................................................................. 194
About the MySetSound Control Panel ..................................... 195
MySetSound and the Required Control   Panel   Resources   ....... 198
MySetSound and the Familiar Resource Types ........................ 199
MySetSound   and the nrct Resource Type ................................   204
MySetSound and the mach Resource Type ..............................   209
Control   Panel   Source   Code   ............................................................ 211
Control   Panels   and   Private   Data   Storage   ................................. 211
The Control Device Function Entry   Point   ............................... 213
Taking Care of the Preliminaries .............................................. 215
Handling an initDev Message   .................................................... 216
Setting   the Radio Buttons   .......................................................... 217
Handling a hitDev Message ....................................................... 221
The MySetSound   Source   Code   Listing   ..................................... 225
Building the cdev   Code   Resource .................................................. 227
Building with   Code Warrior ....................................................... 229
Building with   Syman   tee   C++   /THINK   C   ...................................   230
Enhancing the MySetSound   Control   Panel   ............................. 232
Creating an Icon Family ............................................................ 234
Changing the   Control   Panel's   Display Font ............................. 236
Additional Resources ................................................................. 238
Additions to the   Source   Code   ................................................... 239
The   MySetSoundPlus   Source   Code Listing .............................. 242
The Mylnsanity   Control   Panel   ....................................................... 246
The Mylnsanity Resources ......................................................... 248
Handling a nulDev Message ...................................................... 252
Selective   Execution: The mach Resource and the
macDev Message ................................................................... 254
The Mylnsanity   Source   Code   Listing   ........................................ 257
Chapter   Summary   ...........................................................................   260
viii

Reading notes: Possible OCR errors: 'Mylnsanity' may be 'MyInsanity'; 'nrct' may be 'nrct' or 'nrct' resource type; '(~011 trol' likely 'Control'

Printed product names: MySetSound · MySetSoundPlus · Mylnsanity

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-66101f8409c61033c84034c8995d5ed5f63e839c870771efd33a411930abd377)

Transcribed text:

Contents
Chapter 5: Resources................................. 261
About Resources   .............................................................................. 262
Using Multiple DITL Resources in   One   Dialog Box .................... 263
About Dynamic Dialog Box Items   ............................................. 263
The MulitpleDITLs Resources .................................................. 266
The AppendDITL() and ShortenDITL() Routines   ................. 271
Keeping Track of DITL Items ................................................... 273
The MultipleDITLs   Source   Code   Listing ................................. 276
Building the MultipleDITLs Program ...................................... 281
Using   Custom   Resource Templates   ................................................ 282
The TemplateUser Program ...................................................... 284
Creating a New Resource Type and Template ......................... 285
Using   Resource Data In an Application ................................... 294
The TemplateUser   Source   Code   Listing .................................. 298
Chapter   Summary   ...........................................................................   300
Chapter 6: Resource   Files   .   .   ..   ..   .   ..   ..   .   ..   .   ..   .   ..   ..   ..   ..   303
The MultipleRsrcFiles Resources ..............................................   307
Resource File Reference Numbers ...........................................   308
Opening and   Closing   a Resource File   Source   Code   ................   310
The MultipleRsrcFiles   Source   Code   Listing ............................. 312
Dynamically   Creating   a New Resource File ................................... 316
The CreateRsrcFile Resources   ................................................... 318
Resource File   Creation   Code   .................................................... 319
The CreateRsrcFile   Source   Code   Listing ................................. 323
Dynamically   Copying   a Resource to Another File   ......................... 324
The RsrcCopier Resources ........................................................ 325
DetachResource() and ReleaseResource() Explained ............ 327
Resource   Copying   Code   ............................................................ 334
The   RsrcCopier   Source   Code   Listing .......................................   340
Working with a   Preferences   File ..................................................... 343
The PreflJser Resources ............................................................ 345
ix

Reading notes: Chapter heading and table-of-contents entries are interleaved with dot leaders; reading order is clear but page numbers are not dates. Possible OCR error: 'MulitpleDITLs' and 'PreflJser' may be misspellings of 'MultipleDITLs' and 'PrefsUser'.

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-f554e2c9a5894b355a088d6349c8f5c0004310514b768c7ccbe8fd952f9493ea)

Transcribed text:

More Mac Programming Techniques
Using   a   Preferences   File to   Set   Dialog Box Items   .................... 349
Chapter   Summary   ........................................................................... 366
Chapter 7:   Files   .........................................   369
Opening a   Ne\v   Document   .............................................................   370
Windows and Document Records ............................................. 371
The NewDocument   Source   Code Listing   ................................. 376
Opening   an Existing   PICT   File ...................................................... 379
Reading and Displaying the Contents of a   PICT   File .............. 381
The   OpenPICTfile   Source   Code Listing .................................. 385
Saving   a Document to a   PICT   File .................................................   390
Expanding the Document Record ............................................ 392
Saving   a Document with   "Save   As"   ............................................ 394
Saving   a Document With   "Save"   ................................................   402
The   SavePICTfile   Source   Code Listing ....................................   403
Opening an Existing TEXT File .....................................................   409
The Text Window Document Record ....................................... 411
Reading and Displaying the Contents of a TEXT File   ............. 412
The   OpenTEXTfile   Source   Code Listing   ................................. 419
Saving   a Document to a TEXT File ................................................ 423
Adding Text to a Document ...................................................... 424
Saving   a TEXT Document with   "Save   As"   ................................ 425
The   Save TEXTfile   Source   Code Listing ...................................   430
Chapter   Summary   ........................................................................... 435
Chapter 8: Printing   ..................................... 437
About   Printing   ................................................................................. 438
The   Printer   Resource File ......................................................... 438
The   Printer   Driver Resource ..................................................... 442
Printing Manager Functions   ........................................................... 443
The   Print   Record ....................................................................... 444
The MinimalPrint   Source   Code Listing ................................... 444
The Basic   Printing   Manager Functions .................................... 445
x

Reading notes: Table of contents page numbers and dot leaders are present but not part of the headline or product data. Chapter headings contain a possible OCR error: 'Ne\v' appears where 'New' is likely intended.

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-4de9b203247f290b907251f074b38027676d2e0e326e551a753495c7118efd24)

Transcribed text:

Contents
Running MinimalPrint ..............................................................   450
Printing   Pictures   ........................................................................ 451
Printing   a Document ...................................................................... 456
Walking Through   PrintPICTdoc   ............................................... 457
The   PrintPICTdoc   Source   Code   Listing   ................................... 462
Multiple Windows and Printing ..................................................... 466
The   PrintPICTdocll   Resources ................................................. 467
The   PrintPICTdocll   Interface .................................................. 467
Handling Selections from the File Menu .................................   470
The   PrintPICTdocll   Source   Code   Listing   ................................ 4   73
Printing   Dialog Item Text ............................................................... 481
The PrintDITLscreens Resources ............................................. 483
Printing   Lines of Text   Using   Static Text Items   ......................... 486
The PrintDITLscreens Source   Code   Listing ............................ 493
Chapter   Summary   ...........................................................................   500
Appendix A: Errors   .   ..   ..   .   ..   .   ..   .   ...   .   ...   ..   .   ...   .   ....   ..   .   ....   501
Syman   tee and   Code   Resource Errors   .............................................   501
ResEdit   Crash   While Working with   CNTL   Resources   ..............   502
Slider   Control   Freezes in Built Application .............................   503
Global Variables Don't Hold Values .........................................   503
Strings   Contain   Garbage Characters ........................................   505
Multisegment   Project   Error.......................................................   506
Metrowerks and   Code   Resource Errors .........................................   508
ResEdit   Crash   While Working with   CNTL   Resources   ..............   508
Slider   Control   Freezes in Built Application .............................   510
Link Error: Illegal Single Segment 32-Bit Reference ..............   510
Global Variables Don't Hold Values ......................................... 511
Strings   Contain   Garbage Characters ........................................ 513
Multisegment   Project   Error   ....................................................... 514
System   Crashes:   Errors at Runtime ................................................ 516
Routines Available   Only   in   System   7   ......................................... 516
Index   .........................................................   5::1.!J
xi

Reading notes: Index page number '5::1.!J' is garbled and uncertain

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-552578bb3c19a18a7d79d1777e951dc1001412ec8a40b97f0a5018ba4895f179)

Transcribed text:

ACKNOWLEDGMENTS
Michael Sprague, Development Editor, M&T Books, for keeping things
rolling smoothly.
Stephanie Doyle,   Production   Editor, M&T Books, for a page layout effort
that resulted in a great looking book.
Peter Ferrante, Apple Computer, for another helpful technical edit, and
for taking the time to test the software.
Michael C. Amorose, Alamo Computer, for including his mach resource
template on this book's disk.
Jason Anderson, Beyond Midnight Software, for including his   PictSize
utility on this book's disk.
Alessandro Levi Montalcini, for adding his shareware cdevEloper utility
to the book's disk.
John Holder, for including his shareware utility Resource Handler   FKEY
with this book's disk.
Carole McClendon, Waterside   Productions,   for making this book happen.

Reading notes: Line-break hyphenation and spacing irregularities in source text may affect reading of some names.

Printed product names: PictSize · cdevEloper · Resource Handler FKEY

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/1#scan-807cdce14a472fda1979a7358dbb1f3f9fef654d74782fae8df8ed1953c16988)

Transcribed text:

Introduction
Chapter 1 covers the MDEF-the menu definition procedure.   An   MDEF
is a code resource, that is, compiled code that can be used by other appli-
cations. Because the first four chapters of this book all deal with code
resources, you   '11   read a thorough description of code resources and defi-
nition procedures in general, and then menu definition procedures in
particular. This chapter has a detailed walk-through of the creation of an
MDEF that displays patterns rather than text items, and of the test appli-
cation that makes use of this MDEF.
Chapters 2 and 3 describe the CDEF, or control definition function.
This type of code resource can be used to add 3-D buttons of your own
creation to any Mac program. In Chapter 2, you'll see an example that
does just that. Chapter 3 continues the discussion of the CDEF using slid-
ers in the example programs.
Chapter 4 covers the cdev, or control device function. After building
a cdev   you'll   have   what's   more commonly known as control panel-just
like those under the Apple menu of any Mac.
1

Reading notes: Spacing irregularities in words such as "'11" and "cdev" may reflect OCR artifacts.

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/37ee367a7e5a7c3b665d26556bd3fa1c3f2775efdf1bcb3cba64eb8b665d640f/More_MAC_Programming_Techniques_1995.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-more-mac-programming-techniques-1995-bbb201/2.md)
