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

Re: How to get the window hilite color?



> 
> I'm trying to get the hilite color of a window. One would think
> this should be a pretty trivial task but I'm goin insane..
> 

Bill's answer solves your problem very nicely but let me make some
comments on the why's of the strange (and very unclear) error message:

> Error: Illegal attempt to get a pointer to a :RGBCOLOR within a handle
> While executing: CCL::EXPAND-HANDLE-RECORD-GET

If you look at the source code of CCL::EXPAND-HANDLE-RECORD-GET and the
record definition of :GRAFVARS, you will understand that what MCL is doing
is preventing you from getting a pointer into a handle memory block. Such
a pointer could become invalid if the memory block pointed to by the handle
was moved (the macintosh memory manager can decide to move unlocked
handle memory blocks almost any time it wants).

If your needs for the hilite color are of dynamic extent, you could also do
it in the following way:

;; with-dereferenced-handles locks the handle...
(with-dereferenced-handles ((ptr (pref (wptr w) :cwindowrecord.port.grafvars)))
  (let ((my-hilite-color (pref ptr :grafvars.rgbhilitecolor)))
    ;; do some stuff with it, but not after exiting
    ;; the with-dereferenced-handles!
    ))

-- 
Guillaume Cartier
cartier@math.uqam.ca
LACIM, Universite du Quebec a Montreal.