home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / lisp / mcl / 1576 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  1.9 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!data.nas.nasa.gov!taligent!apple!cambridge.apple.com!jbk@world.std.com
  2. From: jbk@world.std.com (Jeffrey B Kane)
  3. Newsgroups: comp.lang.lisp.mcl
  4. Subject: Working with pointers
  5. Message-ID: <199211121938.AA27396@world.std.com>
  6. Date: 12 Nov 92 19:38:17 GMT
  7. Sender: info-mcl-request@cambridge.apple.com
  8. Lines: 44
  9. Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
  10.  
  11.  
  12. I've been playing around all morning, trying to get some resources to work properly.
  13. I need a pointer to an icon (for an icon-dialog-item) so I used the resource package
  14. to get a handle, but when I try to use the pointer, all sorts of problems occur.
  15.  
  16. (with-open-resource-file (*my-rsrcs* "Application.rsrc")
  17.   (defparameter *icon-hndl-1* (get-resource "ICON" "Telephone"))
  18.   (defparameter *icon-hndl-2* (get-resource "ICON" "Honda")))
  19.  
  20.   I next try to get a pointer to use by:
  21.  
  22. (when *icon-hndl-1*
  23.   (#_MoveHHi *icon-hndl-1*)
  24.   (#_HLock *icon-hndl-1*)
  25.   (defparameter *my-icon-ptr* (%hget-ptr *icon-hndl-1*)))
  26.  
  27. I should now have a locked, dereferenced pointer, but when I use it to define
  28. and icon-dialog-item I get into trouble:
  29.  
  30. (setf my-window (make-instance 'ccl::scrolling-window :color-p t))
  31. (add-subviews my-window (make-instance 'icon-dialog-item
  32.                      :icon *my-icon-ptr*
  33.                      :view-position #@(50 0)))
  34.  
  35. Inspecting *my-icon-ptr* shows it to be:
  36.     #<A Mac Handle, Unlocked, Size 40 #x263364>
  37. as it should be.
  38.  
  39. The icon drawn is from a garbage pointer, and the machine soon crashes.
  40.  
  41.          Jeffrey
  42.  
  43. P.S.  I know the icon-dialog-item package will use a resouce ID, but I want to 
  44. work with named resources.  Also I need to understand this so I can start to get
  45. some general Mac programming done in MCL.
  46.  
  47. ======================================
  48. Jeffrey Kane, MD
  49. Kane Biomedical Systems
  50. Boston, MA
  51.  
  52. Internet           jbk@world.std.com
  53. Compuserve  74206,640
  54. AppleLink     D0738
  55.