[comp.sys.mac.hypercard] Centering Modal Dialog

Glenn.Mcpherson@f421.n109.z1.fidonet.org (Glenn Mcpherson) (01/11/91)

> I'll bet this has been asked before.  Is there any way to cause
> HyperCard's modal dialogs to center themselves on the card window
> rather than on the physical screen?
 
Try the following Think C code:
 
  /* pp is the XCmdPtr that Hypercard gives you... */
 
  Rect   r;
  Handle res;
  int    h, v;
  int    wHor = 102, wVer = 50;   /* you set these! */
 
  theRes = EvalExpr(pp, "\pthe rect of card window");
  if(theRes == NIL)
    /* ERROR! */;
 
  HLock( theRes    );
  CtoPstr( *theRes );
  StrToRect( pp, *theRes, &r );
  HUnlock( theRes );
  DisposHandle( theRes );
    
  h = (r.right  - r.left - wHor) / 2 + r.left;
  v = (r.bottom - r.top  - wVer) / 2 + r.top;
  SetRect(&r, h, v, h + wHor, v + wVer);
 
  /* use "r" to open a window... */
 
Hope this helps...
 
Glenn McPherson
Somewhere on Fidonet!


--  

        Glenn Mcpherson, Glenn.Mcpherson@f421.n109.z1.fidonet.org
      via The Black Cat's Shack's FidoNet<->Usenet Gateway
          blkcat.fidonet.org   and   Fidonet 1:109/401