Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!caen!ox.com!tbomb!time Newsgroups: comp.sys.mac.programmer Subject: Re: ICONs as buttons in a dialog. Message-ID: <1CE00001.or5i24@tbomb.ice.com> Date: 15 Feb 91 15:07:10 GMT Reply-To: time@ice.com Organization: ICE Engineering, Inc. Lines: 54 X-Mailer: uAccess - Mac Release: 1.0.5+ In article <1392@gertie.osc.edu>, spencer@cgrg.ohio-state.edu (Stephen N. Spencer) writes: > I've created a dialog box which has the standard 'Cancel' and 'OK' buttons, > and have five ICON resources that I'd like to use as buttons. I can display > them in the dialog box, and I get dialog events when I click on them (it's a > modeless dialog box...) but they don't invert or anything like that. > > Will I have to handle the inversion of the appropriate area of the screen > (the clicked-upon ICON) myself or is there some other method for doing this? You need to use ICN# resources, with the icon mask data. Example: DrawIcon(myWindow, myIcon) WindowPtr myWindow; ICONCtl *myIcon; { /* Cut "hole" into gray (or other) background for icon transfer... */ CopyBits(&myIcon->maskbits, &myWindow->portBits, &myIcon->maskbits.bounds, &myIcon->bounds, srcBic, NULL); /* Copyt the icon */ CopyBits(&myIcon->iconbits, &myWindow->portBits, &myIcon->iconbits.bounds, &myIcon->bounds, srcOr, NULL); /* Check for "dim" icon. */ if (icon_list->active == 0) { PenMode(patBic); PenPat(qd.gray); PaintRect(&icon_list->bounds); PenNormal(); } } HiliteICON(myWindow, theicon) WindowPtr myWindow; ICONCtl *theicon; { if (theicon != NULL) { if (theicon->showing) { /* Invert the icon using it's mask. */ CopyBits(&theicon->maskbits, &myWindow->portBits, &theicon->maskbits.bounds, &theicon->bounds, srcXor, NULL); } } } Ignore my silly data structures. The iconbits are the first 128 bytes of the ICN# resource and the maskbits are the second 128 bytes. tim. ------------------------------------------------------------- Tim Endres | time@ice.com ICE Engineering | uupsi!ice.com!time 8840 Main Street | Voice FAX Whitmore Lake MI. 48189 | (313) 449 8288 (313) 449 9208