Technotes


Resource in CDEV?



Technote OV 18February 1992



Written by: C. K. Haun <TR> February 1992

This Technical Note discusses the new 'fwst' resource added to some Control Panels under System 7.0 and later.


A New World for Control Panels

System 7 changes many of the rules for Control Panels (cdevs), and these changes are very well documented in Chapter 10 of Inside Macintosh Volume VI. However, there is one thing not documented in IM VI that you need to be aware of, as it could cause you confusion and frustration-- the 'fwst' resource.

Two groups of developers should be interested in this information: Control Panel developers and developers of virus and disk security software.

What Is This 'fwst' Thing in My CDev?!?!?!

OK, we admit it. The System can add a resource to your Control Panel. But it does it for a good reason, really!

Control Panels do not show up in the Control Panel desk accessory anymore. Each Control Panel a user opens will show up in its own window. Because of this, the Finder needs to have a way to remember (among other things) the position of the Control Panel window on the user's desktop so that the Finder can position the Control Panel in the same location every time the user opens it, thereby saving the user from having to continually reposition the window.

A new resource type--the 'fwst' resource--was created to keep track of the Control Panel window position (and other things). The contents of this resource is private; you should make no assumptions about the contents, size, or use of the components of the 'fwst' resource. The only public aspect of this resource is that it is used by the Finder to position a Control Panel window on the desktop.

The 'fwst' resource does not automatically get added to your Control Panel. If a user opens your Control Panel and closes it without moving the Control Panel window, then no 'fwst' resource is needed, since the default position for the window has not changed.

However, if the user moves the window and closes the Control Panel, a 'fwst' resource is added. This tells the Finder where to place the Control Panel window when the user opens it up again. This obviously is a very user-friendly thing to do. Users get consistent positioning of their windows, and are not frustrated by having to shuffle windows all the time. Note, however, that it could cause problems for you if you don't know that it may show up.

If you check your own resource fork for any reason (for example, scanning for viruses) you need to know that the 'fwst' resource may be there. If it's there, that is normal, and you should not treat that as a damages resource fork or a viral infection. If you notice the 'fwst' resource being added to a Control Panel and if you are a virus protection or disk security software developer you should not alert the user that a resource has been added or that a viral attack is taking place.

One More Thing

The presence of an 'fwst' resource has one more effect that you may find very frustrating, since until you know about it you can't figure it out. Another resource that you normally add to a Control Panel is the 'nrct' resource. This resource is used to specify a list of rectangles that your Control Panel used in the pre-System 7 Control Panel desk accessory.

The 'nrct' rectangle resource is described in Inside Macintosh Volume V, and the removal of the size restriction is documented in IM VI. Basically, what IM VI says is that now, since each Control Panel has its own window, your 'nrct' does not have to fit inside the old Control Panel bounding rectangle. Your Control Panel under System 7 can be much bigger than it was in any previous system. One thing that IM VI doesn't explicitly say is that the first rectangle in your 'nrct' resource is the bounding rectangle for the Control Panel window under System 7 and later.

What Does This Have to Do With the 'fwst'?

The 'fwst' takes precedence over the 'nrct'. So, if you have a 'fwst' in your Control Panel, any changes to the first rectangle in your 'nrct' will not be recognized!

This can be very frustrating during Control Panel development. You've been merrily debugging your Control Panel, moving it around the Finder, and making sure everything works. You decide you need to add another item to the Control Panel, and therefore you want the Control Panel window to be bigger. "Great," think you,"System 7 doesn't care how big I make it!" and you go into ResEdit and change your 'nrct'. You go back to the Finder, open the Control Panel, and nothing has changed!

What's happening is that the 'fwst' is overriding the 'nrct'. If you need to change the 'nrct' of your Control Panel, make sure you check to see if there is an 'fwst' resource in your Control Panel's resource fork. If there is, delete it and make the necessary changes to your 'nrct'. With no 'fwst', your 'nrct' values will be recognized, and a new 'fwst' reflecting the correct rectangle will be created if the window is moved. Use ResEdit, your favorite resource editor, or Rez in MPW to remove the 'fwst'. Here's a command line you can add to MPW build script for your Control Panel that will remove the 'fwst' resource from the Control Panel automatically during the build process;

echo "delete 'fwst';" | Rez -a -o "{MyControlPanelName}"

Of course, replace "{MyControlPanelName}" with whatever name or variable you are using in your build script to identify your Control Panel.

And remember to remove whatever 'fwst' is in the Control Panel before your ship your product. This will let the Control Panel come up on your user's machines in the default location, and the user can decide where he or she would like the Control Panel placed.

Further Reference:




Technotes
Previous Technote | Contents | Next Technote