FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

RESOURCES

Avoid errors handling resources


Here are a few rules to follow.

1) After FN pGreplaceRes, your resource handle is no longer valid. You must use GETRESOURCE to re-get the handle

2) Never dispose of a resource handle. (i.e. don't use DISPOSEH, DISPOSEHANDLE, KILLPICTURE, DISPOSEMENU, etc.)

3) Except in some very rare cases, you don't need to call RELEASERESOURCE.

4) If you detach a resource it is no longer a resource, but you still have a handle in memory to contend with.

5) If you have to lock a resource handle or make it unpurgeable, use these steps:

hState = FN HGETSTATE(resHndl&)
OSErr = FN HLOCK(resHndl&)

REM do your stuff here...

OSErr = FN HSETSTATE(resHndl&,hState)

STAZ ~)~