FunctionPackage: cgToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version

default-init-function

Arguments: nil

default-init-function is the default on-initialization function for a project. It creates and displays the running window for the main form of the project, and then returns that window so that the application will exit when the main window is closed.

Below is the complete code for this function, which an application may model after if it needs to use a custom on-initialization function.

(defun default-init-function ()
  (let* ((maker (main-window-maker (app *system*)))
         window)
    
    ;; This default project on-initialization function expects
    ;; the project to have a main form to run.  For a project
    ;; that uses no windows at all, you would need to substitute 
    ;; a different on-initialization function.
    (unless maker
      (error "The project has no main form to run.  Either add a form ~
                 to the project or give the project a different ~
                 on-initialization function."))
    
    ;; Call the main form module's maker-function to create its window.
    (setq window (funcall maker
                          
                          ;; When in a Run Project in the IDE,
                          ;; run the main form on the screen (rather
                          ;; than on the IDE owner window where
                          ;; individual forms are run) to more completely
                          ;; emulate the standalone application.
                          ;; (The preferred initarg is now :owner, but
                          ;; :parent also works with maker-functions
                          ;; that were generated in pre-6.0 versions.)
                          :parent (screen *system*)))
    
    ;; Cache the main window so that its finder function will
    ;; find it later.
    (when window
      (add-application-window window)
      
      ;; Select the window if needed so that the end user sees it.
      ;; A custom on-initialization function might want to customize
      ;; the window contents in some way before revealing it here.
      (select-window window)
      
      ;; This call may be needed especially in Windows 2000 to
      ;; ensure that the app comes to the front.
      (set-foreground-window window))
    
    ;; Return the main window of the application, to tell
    ;; do-default-restart to call event-loop for us, passing the
    ;; window so that event-loop exits when the window has been closed.
    ;; Alternately, we could call event-loop ourselves with a
    ;; custom exit-test, and return anything but a window when
    ;; it returns.
    window))

Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.

ToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 8.2
Unrevised from 8.1 to 8.2.
8.1 version