Path: utzoo!utgpu!water!watmath!clyde!rutgers!lll-lcc!well!ewhac From: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Newsgroups: comp.sys.amiga Subject: Re: ActivateGadget Use (Does it work?) Message-ID: <4695@well.UUCP> Date: 11 Dec 87 00:45:25 GMT References: <1861@cup.portal.com> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Organization: Wonka Reality Factory Lines: 157 In article <1861@cup.portal.com> Steve_A_Hales@cup.portal.com writes: >I want to *activate* a string gadget upon entry to a dialog box. I am using >Aztec 3.4b's ActivateGadget for Version 1.2 of Kickstart But it don't seem >to work. > Another poster mentioned that the cause may be HeliosMouse. However, since the original poster (quoted above) didn't say if he was using it, have a code fragment. Note: This is an *extremely* cheesy file requestor, and I don't recommend using it unless you're writing user-hostile programs. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab -- The Guy in The Cape ihnp4!ptsfa -\ \_ -_ Recumbent Bikes: dual ---> !{well,unicom}!ewhac O----^o The Only Way To Fly. hplabs / (pronounced "AE-wack") "Work FOR? I don't work FOR anybody! I'm just having fun." -- The Doctor _-_-_-_-_-_-_-_-_-_-_-_ Cut here! Cut, I say!! _-_-_-_-_-_-_-_-_-_-_-_-_-_-_ /* :ts=8 bk=0 * * file.c: Code and structures for super-cheesy file requestor. * [USENET Note: This was part of a larger program I wrote. * You must #define BACKFILL, REQLEFT, and REQTOP to something, * and there has to be a valid window somwehere.] * * Leo L. Schwab 8709.8 */ #include#include #define REQWIDE 320 #define REQHIGH 45 /* * Remeber to define these! */ /* #define BACKFILL something */ /* #define REQLEFT somethingelse */ /* #define REQTOP snark */ /* * Bounding box for filename gadget. */ static SHORT filebox[] = { -2, -2, -2, 9, 289, 9, 289, -2, -2, -2 }; static struct Border bord = { /* Border for gadget */ 0, 0, 0, 0, JAM1, 5, filebox, NULL }; /* * Filename gadget special info. */ static UBYTE filename[256], ufilename[256]; static struct StringInfo filenamegad = { filename, ufilename, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* * Gadget for filename requestor */ static struct Gadget file = { NULL, 16, REQHIGH-20, 36*8, 10, GADGHCOMP, RELVERIFY | ENDGADGET, STRGADGET | REQGADGET, (APTR) &bord, NULL, NULL, 0, (APTR) &filenamegad, 0, 0 }; /* * IntuiText for requestor itself. */ static struct IntuiText reqtext = { 0, 0, JAM1, 16, 10, NULL, (UBYTE *) "Please enter a filename.", NULL }; /* * The requester */ static struct Requester filerequester; /* * Code to initialize the file requester */ setupfilereq () { InitRequester (&filerequester); filerequester.LeftEdge = REQLEFT; filerequester.TopEdge = REQTOP; filerequester.Width = REQWIDE; filerequester.Height = REQHIGH; filerequester.ReqGadget = &file; filerequester.ReqText = &reqtext; filerequester.BackFill = BACKFILL; } /* * Phew! Now to write some real code. */ char * getfile () { extern struct Window *win; /* Make sure this is real! */ register struct IntuiMessage *msg; register struct Gadget *gad; long class; /* * In order to do ActivateGadget() properly, we have to officially * wait for the requester to get posted. Thus, the following * mish-mash. Note: Your window must have the REQSET IDCMP flag * set. Otherwise, this will break. */ Request (&filerequester, win); while (1) { WaitPort (win -> UserPort); msg = GetMsg (win -> UserPort); class = msg -> Class; ReplyMsg (msg); if (class == REQSET) break; } /* ActivateGadget (GADGET_POINTER, WINDOW_POINTER, REQUESTOR_POINTER) */ ActivateGadget (&file, win, &filerequester); while (1) { WaitPort (win -> UserPort); msg = GetMsg (win -> UserPort); class = msg -> Class; gad = (struct Gadget *) msg -> IAddress; ReplyMsg (msg); if (class == GADGETUP && gad == &file) return ((char *) filename); } }