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

Re: MCL images & resources ....



aron culich writes about saving an MCL image:
> I've been attempting to do a save-application for a project I'm 
> working on, but I have NO idea how to make the saved image
> use customized resources for document and fasl icons & such.
> 
> I've tried using res-edit to edit the resources and change
> the creator and all, but to no avail.  When I save a file
> it still saves it as an "MCL document" with the standard
> icons.
> 
> I can't find answers to this question in either the MCL faq
> or the MCL 2.0 manual.  In fact, here is what the manual says
> to do...

The best place to look is in the examples folder on the distribution disk.
There is a complete version in /Examples/binhex/binhex.lisp.  Here's part
of the relevant code that changes the icons to those associated with the file
binhex resources.rsrc. Perhaps the FAQ might be updated to point to this
example since this is not the first time the question has been asked.

; The resource file contains icon ("ICN#", "icl8", etc.) resources for the
; application (id #128) and for the documents that it creates (id #129)
; and appropriate "FREF" and "BNDL" resources.
; MCL contains a resource of type "CCL2" and icon and "FREF" resources for
; a larger set of document types (ids in the range 128-132).
    (with-open-resource-file (f "ccl:examples;binhex;binhex resources.rsrc")
      (do* ((id 128 (1+ id)))
           ((> id 132))
        (dolist (type '("FREF" "ics#" "ICN#" "icl4" "icl8" "ics4" "ics8"))
          (push (list (if (<= id 129) (load-and-detach type id)) type id) 
resources)))
      ; We don't want a "CCL2" resource ...
      (push (list nil "CCL2" 0) resources)
      ; We -do- want a resource of type binhex-file-creator ...
      (push (list (#_NewHandle 0) binhex-file-creator 0 "MCL Binhex Example") 
resources)
      ; Grab "BNDL"(128) from our resource file, replacing MCL's
      (push (list (load-and-detach "BNDL" 128) "BNDL" 128) resources))
    (catch-cancel
      (save-application path :init-file nil :toplevel-function #'binhex-startup
                        :creator binhex-file-creator :resources resources 
:excise-compiler T))
    ; in case the save is cancelled
    (set-menubar *default-menubar*)))