Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!hsdndev!dartvax!ascutney!kurash From: kurash@ascutney.dartmouth.edu (Mark Valence) Newsgroups: comp.sys.mac.programmer Subject: Re: ModalDialog question Summary: refCon nullEvent Filter=true Keywords: foo bar Message-ID: <1991Mar18.204423.10887@dartvax.dartmouth.edu> Date: 18 Mar 91 20:44:23 GMT References: <1235@gagme.chi.il.us> Sender: news@dartvax.dartmouth.edu (The News Manager) Reply-To: kurash@ascutney (Mark Valence) Organization: Dartmouth College Lines: 35 >essam@gagme.chi.il.us (Essam Khairullah) writes: > I have a modal dialog that pops up at a given time (installed with an INIT) > and I want to be able to dismiss the dialog if the user doesn't do it > himself after a half an hour. How can I get ModalDialog to report null > events (or in my filterProc) so that I can tell how much time has passed > without the user having to cause an event? As long as the dialog is "yours" (you're the one who called GetNewDialog or NewDialog), you can use the "refCon" field of the DialogRecord for the dialog (you can access this field with calls to GetWRefCon and SetWRefCon). Set the refCon of your DialogRecord to the time "one half hour" from when you first display the dialog (use GetDateTime from pascal or C to get the current time in seconds). Then, every time your filter proc gets an event (null or otherwise, if you like), check the value in the refCon with the current time. If the current time is ever greater than what's in the refCon, set itemHit (passed as a var parameter to the filter proc) to "ok" or "cancel", or whatever item you want to be hit by your ghost user, and return "true" from the filter proc. Yup. That'll do it. Alternately, you could store a pointer to the "deadline" and other stuff in the refCon. More indirection, but you can then have access to all of your INIT's global variables. BTW, your INIT might crash under 7.0b1 and b2, but the bug (in the Finder) that causes this crash is fixed in the b3 and b4 releases. Also, just to emphasize the point, if you are not the one who called GetNewDialog or NewDialog to post the dialog, you cannot use this scheme and claim to be bug-free. The "owner" of the dialog might be using its refCon for its own purposes. Sorry I had to post, but mail just bounced. Mark.