[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Working with pointers

I've been playing around all morning, trying to get some resources to work properly.
I need a pointer to an icon (for an icon-dialog-item) so I used the resource package
to get a handle, but when I try to use the pointer, all sorts of problems occur.

(with-open-resource-file (*my-rsrcs* "Application.rsrc")
  (defparameter *icon-hndl-1* (get-resource "ICON" "Telephone"))
  (defparameter *icon-hndl-2* (get-resource "ICON" "Honda")))

  I next try to get a pointer to use by:

(when *icon-hndl-1*
  (#_MoveHHi *icon-hndl-1*)
  (#_HLock *icon-hndl-1*)
  (defparameter *my-icon-ptr* (%hget-ptr *icon-hndl-1*)))

I should now have a locked, dereferenced pointer, but when I use it to define
and icon-dialog-item I get into trouble:

(setf my-window (make-instance 'ccl::scrolling-window :color-p t))
(add-subviews my-window (make-instance 'icon-dialog-item
                     :icon *my-icon-ptr*
                     :view-position #@(50 0)))

Inspecting *my-icon-ptr* shows it to be:
    #<A Mac Handle, Unlocked, Size 40 #x263364>
as it should be.

The icon drawn is from a garbage pointer, and the machine soon crashes.


P.S.  I know the icon-dialog-item package will use a resouce ID, but I want to 
work with named resources.  Also I need to understand this so I can start to get
some general Mac programming done in MCL.

Jeffrey Kane, MD
Kane Biomedical Systems
Boston, MA

Internet           jbk@world.std.com
Compuserve  74206,640
AppleLink     D0738