Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!munnari.oz.au!uniwa!fennel.cc.uwa.oz.au!a_dent From: a_dent@fennel.cc.uwa.oz.au Newsgroups: comp.sys.mac.programmer Subject: Re: Novice Think C Class Questions Message-ID: <1991Mar16.122957.3082@fennel.cc.uwa.oz.au> Date: 16 Mar 91 04:29:57 GMT References: <3895.27D0636D@stjhmc.fidonet.org> <15953@hoptoad.uucp> Organization: University of Western Australia Lines: 73 Kevin Brewer writes in a message to All KB> 1) I have an appliction that should have three or four windows. KB> My (mis?)understanding of the Document Class is that the Doc KB> Class should control the windows, yet you can only have one KB> window associated with each doc instance. How do you create KB> more than one window - say a drawing pane and a text edit pane KB> - for each doc? Obviously, I'm confused. I would appreciate KB> any direction on this. I implemented a program which allows multiple windows (a magazine layout program - a page per window) and so had to be able to change the main pane - sounds like what you're doing. I wrote a subclass of CWindow, as shown below, and added a method to the normal (overridden, from the sample application) Document class: procedure CREIWAPrintDoc.changeMainPane (newMain: CREIWAPrintPane; newWindow: CWindow); begin itsMainPane := newMain; itsGopher := newMain; gGopher := newMain; itsWindow := newWindow; end; --------------------------------------------------------------------------- procedure CREIWAPrintWindow.makeMyPaneMain; var thePane: CREIWAPrintPane; itsScrollPane: CScrollPane; function isREIWAPane (theObject: CObject): boolean; begin isREIWAPane := member(theObject, CREIWAPrintPane); end; { isREIWAPAne} begin { makeMyPaneMain } CObject(itsScrollPane) := itsSubviews.FirstItem; CObject(thePane) := itsScrollPane.itsSubviews.FirstSuccess(isREIWAPane); CREIWAPrintDoc(itsSupervisor).changeMainPane(thePane, SELF); end; { makeMyPaneMain } procedure CREIWAPrintWindow.select; begin { select } SELF.makeMyPaneMain; inherited select; end; { select } procedure CREIWAPrintWindow.Activate; begin { Activate } SELF.makeMyPaneMain; inherited Activate; end; { Activate } -------------------------------------------------------------------------------- The following fragment of code goes in the Document's DoCommand method and lets you have a menu of all the windows: if (theCommand < 1) & (hiWord(thecommand) = -(PageMenuID + 1)) then begin { selection from Page menu } thePageIndex := -loWord(theCommand); { note the sign change!! } CObject(theWindow) := itsWindowList.NthItem(thePageIndex); theWindow.Select; end; Hope this helps. Andy Dent A.D. Software phone 09 249 2719 Mac & VAX programmer 94 Bermuda Dve, Ballajura a_dent@fennel.cc.uwa.oz Western Australia 6066 a_dent@fennel.cc.uwa.oz.AU (international)