TweetFollow Us on Twitter

Summer 91 - PRINT HINTS FROM LUKE & ZZ

PRINT HINTS FROM LUKE & ZZ

HELP FOR YOUR DIALOG APPENDAGES

PETE "LUKE" ALEXANDER and Zz

[IMAGE Luke+Zz.GIF]

Zz speaks

OK, so you're cruising your source like a madman trying to get all those little System 7.0 changes in before that target ship date (whatever it is this week), and you notice that the items you've added to the Page Setup/Print dialogs don't have any Balloon HelpTM--you know, those items like Reverse Pages, Print Hidden Text, or even Use Fractional Font Widths. (Coming up with meaningful names for these items, in four words or less, was a little tricky.) But now there's help, literally, in System 7.0. Great! Then you remember that there wasn't a simple Printing Manager call to add those items to the dialogs. You had to resort to the technique described in Technical Note #95, How to Add Items to the Print Dialogs. As you remember, it used a set of procedures that modified the Printing Manager's (that is, the selected print driver's) dialog item list (DITL) resource.

Remembering the actual code in Tech Note #95, you consider that the Standard File package shipped with 7.0 has a new call that allows you to append things to its dialog, including Help Manager resources. Feeling relieved, you think, "Ah, there must be a similar call in the new Pri . . ." But no, the new printing architecture has been delayed. A quick scan shows that there isn't even a Printing Manager chapter inInside Macintosh Volume VI! Help!!! It's not as bad as you might expect. If you consult Tech Note #95, you'll see the rather husky AppendDITL procedure. This procedure is called to append the items that you want to add to the dialog item list being used by the particular dialog (Page Setup or Print).

The sample code from Tech Note #95 calls some Printing Manager routines that let you get in after the DITL resource has been loaded, but before the dialog has been displayed. You add your items to the resource in memorywithout calling either ChangedResource or WriteResource. The driver then uses this DITL and displays your items. Once the dialog is dismissed, the resource is purged, and the driver doesn't even know you were there. Life is good.

As you've probably guessed by now, you're going to have to append to the Help Manager dialog item help ('hdlg') resource in the same way that you appended to the DITL resource. You simply scan the list to the end, and then append the appropriate items. The 'hdlg' resource is purged in the same way as the DITL resource, so once again you make no permanent changes.

On the next page is the definition of the Append2hdlg procedure. We start by getting both 'hdlg' resources into memory. It's safe to assume the source 'hdlg' resource hasn't been loaded yet, but we use the SetResLoad trick on the destination in case it has already been loaded. (The SetResLoad trick is a method for determining whether a resource has already been loaded. This trick is important, since in cases where the resource has already been loaded by the system, you don't want to unload it or permanently change any of its resource attributes.) The trick works like this: You SetResLoad to false so that the Resource Manager doesn't load the resource data; instead, it just creates an empty resource handle that can be passed to routines like GetResInfo. You then call GetResource on the resource you're looking for. If the handle returned is empty (that is, points to nil), you know the resource isn't already in memory. If the handle returned is not empty, something else (like the system) has already loaded it before you called GetResource. In this example, since we use HGetState and HSetState to preserve the resource attributes, and we want the resource to be left in memory when we're done, we don't really need to know if it was already loaded. The SetResLoad code is included for anyone who is planning on modifying this code to do more.

Next we initialize our locals. We want to point srcPtr to the place in the source resource that we want to start copying from. To do this, we need to point past the "missing item." The size of the item is stored in the resource just after the resource header. We first use srcPtr to get the size (in bytes) of the missing item. Using that size, we can calculate the starting location for the copy. We don't actually initialize srcPtr yet, since resizing the destination handle could move memory. Next we initialize dstPtr and dstLength. In the process, we resize dstHdl to make room for the items we're going to append. Once SetHandleSize has been called, we also initialize srcPtr. Now that srcPtr and dstPtr are set up, we use BlockMove to copy the new items into the destination resource. After unlocking the resource handles, we update the numItems field of the destination resource so that the Help Manager will know how many items we added. Finally, we release the source resource. We don't want to release the destination, since our changes would then be lost.

void Append2hdlg(srcResID, dstResID)
short   srcResID, dstResID;
{
    Handle              srcHdl, dstHdl;
    Ptr                 srcPtr, dstPtr;
    short               srcLength, dstLength;
    short               missingItmSz;
    SignedByte      dstHState;
    
    srcHdl = GetResource('hdlg', srcResID); 
    if (srcHdl != nil) {
        SetResLoad(false);  /* System resource, make sure it's not */
        dstHdl = GetResource('hdlg', dstResID); /* already loaded. */
        SetResLoad(true);
        if (*dstHdl == 0)
            dstHdl = GetResource('hdlg', dstResID);
        dstHState = HGetState(dstHdl);
        
        if (dstHdl != nil) {
            srcPtr = (Ptr)*srcHdl + sizeof(hdlgHeader);
            missingItmSz = *((IntPtr)srcPtr);
            srcLength = GetHandleSize(srcHdl) - (sizeof(hdlgHeader)
                - missingItmSz);

            dstLength = GetHandleSize(dstHdl);
            SetHandleSize(dstHdl, dstLength + srcLength);
            if (MemError() != noErr) {
                DebugStr("\pMemError");
                            /* Use this error handler, go to jail. */
                ExitToShell();              /* It's the law! */
            }
            dstPtr = (Ptr)*dstHdl + dstLength;
            srcPtr = (Ptr)*srcHdl + sizeof(hdlgHeader) +
                missingItmSz;

            HLock(srcHdl);
            HLock(dstHdl);

            BlockMove(srcPtr, dstPtr, srcLength);

            HUnlock(srcHdl);
            HSetState(dstHdl, dstHState);

            ((hdlgHeaderPtr)*dstHdl)->hdlgNumItems +=
                ((hdlgHeaderPtr)*srcHdl)->hdlgNumItems;
        }
    }
    ReleaseResource(srcHdl);
}

So that's about it. Append2hdlg is a lot smaller than AppendDITL because we don't actually need to parse the contents of the 'hdlg' resource. Although it's another piece of code to be added to your application, this should be quite painless, unlike other Printing Manager exercises. Don't forget to read the Help Manager chapter of Inside Macintosh Volume VI for guidelines on the contents of your Help Manager balloons. See ya next time . . .


SCOTT "ZZ" ZIMMERMAN loves Disneyland--we think it's because he's really a cartoon character at heart. When asked, he admitted to wanting to be Captain Hook when he grew up. His favorite ride is Peter Pan because it's romantic, cool, dark, and the main character is a kid who never grew up. Except for the romantic, cool, and dark parts, it reminds him a lot of life at Apple. When he's at Apple he makes sure he drinks at least 15 gallons of Mountain Dew a day--he says it powers the mechanism for his retractable Barbie Doll hair. In closing, we'll leave you with his favorite question, "How can I miss you if you won't leave?"*

For more information on the format and use of the "missing item" in an 'hdlg' resource, and much more about Balloon Help, see the Help Manager chapter in Inside Macintosh Volume VI. *

 
AAPL
$102.64
Apple Inc.
+1.58
MSFT
$46.56
Microsoft Corpora
-0.50
GOOG
$581.13
Google Inc.
-6.24

MacTech Search:
Community Search:

Software Updates via MacUpdate

GarageSale 6.8 - Create outstanding eBay...
GarageSale is a slick, full-featured client application for the eBay online auction system. Create and manage your auctions with ease. With GarageSale, you can create, edit, track, and manage... Read more
ScreenFlow 4.5.3 - Create screen recordi...
Save 5% with the MacUpdate coupon code: 68031AE15F -- Buy now! ScreenFlow is powerful, easy-to-use screencasting software for the Mac. With ScreenFlow you can record the contents of your entire... Read more
NeoOffice 2014.3 - Mac-tailored, OpenOff...
NeoOffice is a complete office suite for OS X. With NeoOffice, users can view, edit, and save OpenOffice documents, PDF files, and most Microsoft Word, Excel, and PowerPoint documents. NeoOffice 3.x... Read more
Typinator 6.2 - Speedy and reliable text...
Typinator turbo-charges your typing productivity. Type a little. Typinator does the rest. We've all faced projects that require repetitive typing tasks. With Typinator, you can store commonly used... Read more
PopChar X 6.7 - Floating window shows av...
PopChar X helps you get the most out of your font collection. With its crystal-clear interface, PopChar X provides a frustration-free way to access any font's special characters. Expanded... Read more
Evernote 5.6.0 - Create searchable notes...
Evernote allows you to easily capture information in any environment using whatever device or platform you find most convenient, and makes this information accessible and searchable at anytime, from... Read more
Monosnap 2.2.2 - Versatile screenshot ut...
Monosnap allows you to save screenshots easily, conveniently, and quickly, sharing them with friends and colleagues at once. It's the ideal choice for anyone who is looking for a smart and fast... Read more
Tunnelblick 3.4beta36 - GUI for OpenVPN...
Tunnelblick is a free, open source graphic user interface for OpenVPN on OS X. It provides easy control of OpenVPN client and/or server connections. It comes as a ready-to-use application with all... Read more
SoftRAID 5.0.4 - High-quality RAID manag...
SoftRAID allows you to create and manage disk arrays to increase performance and reliability. SoftRAID's intuitive interface and powerful feature set makes this utility a must have for any Mac OS X... Read more
Audio Hijack Pro 2.11.3 - Record and enh...
Audio Hijack Pro drastically changes the way you use audio on your computer, giving you the freedom to listen to audio when you want and how you want. Record and enhance any audio with Audio Hijack... Read more

Latest Forum Discussions

See All

Why I Don’t Want to Upgrade to the iPhon...
I’ve been living with my iPhone 4S for the past two years or so, and if I was living in a world where I wasn’t bombarded with new phone announcements and people of the general public caring enough to upgrade constantly, I wouldn’t think my phone... | Read more »
Tictail Review
Tictail Review By Jennifer Allen on September 23rd, 2014 Our Rating: :: CLASSY SHOPPINGiPhone App - Designed for the iPhone, compatible with the iPad Tictail is an attractive and stylish way of looking for some great new clothes... | Read more »
Super Glyph Quest is Bringing More Match...
Super Glyph Quest is Bringing More Match-3 Magics to the App Store Soon Posted by Jessica Fisher on September 23rd, 2014 [ permalink ] Fans of Glyph Quest, by Alex Trowers and Leanne Bayley, | Read more »
Sword King Review
Sword King Review By Jennifer Allen on September 23rd, 2014 Our Rating: :: WEAK, SO WEAKUniversal App - Designed for iPhone and iPad Ever wanted to tap on a screen and assume you’ve killed a monster or two? Probably not, but just... | Read more »
Pangea Software Unveil Bundles and iOS 8...
Pangea Software Unveil Bundles and iOS 8 Updates Posted by Ellis Spice on September 23rd, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Race Team Manager Review
Race Team Manager Review By Jennifer Allen on September 23rd, 2014 Our Rating: :: LIGHT RACINGUniversal App - Designed for iPhone and iPad Want to be in charge of a racing team but not be overwhelmed by tactics and options? Race... | Read more »
Kobojo Works with Creative Minds from Fi...
Kobojo has announced details for their newest game, Zodiac – a 2D persistent online RPG. Kobojo has put together a crack team of developers including composer Hitoshi Sakimoto and scenario writer Kazushige Nojima, whose work includes many of the... | Read more »
PlayHaus Review
PlayHaus Review By Amy Solomon on September 23rd, 2014 Our Rating: iPad Only App - Designed for the iPad PlayHaus is a interesting, stylish app for young children, full of cause-and-effect interactions.   | Read more »
Astropolo Review
Astropolo Review By Amy Solomon on September 23rd, 2014 Our Rating: Universal App - Designed for iPhone and iPad Astropolo is a space-themed children’s app with a great sense of style.   | Read more »
New E*TRADE Update Includes Touch ID and...
New E*TRADE Update Includes Touch ID and Home Screen Widget for iOS 8 Posted by Jessica Fisher on September 23rd, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Razer DeathAdder Chroma Gaming Mouse Upgraded...
Razer has announced the launch of their new Razer DeathAdder Chroma gaming mouse. Even if you’re not a gamer, the DeathAdder bears considering. I’m a fan of the hard-wired tracking accuracy,... Read more
Check Apple prices on your device with iTracx
MacPrices is proud to offer readers a free iOS app (iPhones, iPads, & iPod touch) and Android app (Google Play and Amazon App Store) called iTracx, which allows you to glance at today’s lowest... Read more
Refurbished 2013 MacBook Pros available for u...
The Apple Store has Apple Certified Refurbished 13″ and 15″ MacBook Pros available starting at $929. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros (4GB RAM/... Read more
New iPhones Score Big in SquareTrade Breakabi...
SquareTrade has announced the iPhone 6 and its larger sibling, iPhone 6 Plus, performed impressively in Breakability testing, and each carries the top Breakability Score in their respective category... Read more
10 Million + First Weekend Sales Set New iPho...
Apple has announced it sold over 10 million new iPhone 6 and iPhone 6 Plus models, a new record, just three days after the launch on September 19. iPhone 6 and iPhone 6 Plus are now available in the... Read more
Betty Crocker Launches New Cookbook for iOS
Betty Crocker, a General Mills brand, an established food industry leader, has announced its free digital cookbook app has been refreshed to make cooking with iPhone, iPad and iPod touch even easier... Read more
Apple restocks some refurbished 2014 MacBook...
The Apple Store has restocked some Apple Certified Refurbished 2014 MacBook Airs, with prices starting at $769. An Apple one-year warranty is included with each MacBook, and shipping is free. These... Read more
13-inch 128GB MacBook Air on sale for $949, s...
B&H Photo has the new 2014 13″ 1.4GHz/128GB MacBook Air on sale for $949.99 including free shipping plus NY tax only. Their price is $50 off MSRP. B&H will also include free copies of... Read more
Apple offering free $25 iTunes Gift Card with...
The Apple Store is offering a free $25 iTunes Gift Card with the purchase of a $99 Apple TV for a limited time. Shipping is free. Read more
Apple refurbished iPod touch available for up...
The Apple Store has Apple Certified Refurbished 5th generation iPod touches available starting at $149. Apple’s one-year warranty is included with each model, and shipping is free. Most colors are... Read more

Jobs Board

Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.