[comp.sys.mac.programmer] XCMD windoids for 2.0

hughson@CIS.OHIO-STATE.EDU (Jerry R Hughson) (03/04/91)

Hello,
	How can I tell if my windoid has already been opened by HyperCard?
I would rather just bring my existing windoid to the front than to open 
another.  I guess that I need to store some data between calls of the XCMD,
I could use the refcon of the window as a handle, (macTutor Feb, 91) but this
just gives me a new window record as I open a second copy of the windoid.

Any code or pointers to manuals would be helpful.

thanks in advance  (feel free to e-mail or post)
J.R.
or just R for short
hughson@cis.ohio-state.edu
jhugshon@magnus.acs.ohio-state.edu

wdh@well.sf.ca.us (Bill Hofmann) (03/06/91)

In article <9103040200.AA02230@linguine.cis.ohio-state.edu> hughson@CIS.OHIO-STATE.EDU (Jerry R Hughson) writes:
>
>Hello,
>	How can I tell if my windoid has already been opened by HyperCard?
>I would rather just bring my existing windoid to the front than to open 
>another.  I guess that I need to store some data between calls of the XCMD,
>I could use the refcon of the window as a handle, (macTutor Feb, 91) but this
>just gives me a new window record as I open a second copy of the windoid.

There are two things I think you're trying to do here.  One is to maintain
information for a particular window, in which case using the refcon is the
way to go.  The other is determining whether you've opened one of your windows.
There are several ways to do it, and one way not to.  First, the way not to.
DO NOT use the windowKind field, it's used by Hypercard.  Oops, not documented.
If your window will always have the same title, I guess you could walk the
window list and look for your window title.  The other, better (??) way is to
create a Hypercard global which could have the window title, or a boolean,
or whatever.  Pick a name that is obscure.  I have a global which is a list of
window titles, and I named it something like ___<XCMDName>WindowList.  It's
polite to get rid of your global when you're done with it.

-Bill Hofmann