Path: utzoo!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!pasteur!agate!violet.berkeley.edu!mwm From: mwm@violet.berkeley.edu (Mike (I'll think of something yet) Meyer) Newsgroups: comp.sys.amiga Subject: Another minor window hack Message-ID: <18995@agate.BERKELEY.EDU> Date: 12 Jan 89 02:51:57 GMT Sender: usenet@agate.BERKELEY.EDU Reply-To: mwm@violet.berkeley.edu (Mike (I'll think of something yet) Meyer) Organization: Missionaria Phonibalonica Lines: 114 The following is the other half of placewindow (for those who remember that). It will print out the location/size of any (or all) windows on the system, upon request. Use is to place a window the way you want it to be, and then dumpwindow it to get the nubers to plug into whatever startup mechanism it has for placement - or placewindow if it has no such mechanism. Output is suitable for handing to con: or placewindow or etc. with editing. One thing - I'm not sure about printf()'ing while IntuitionBase is Locked. Don't think it should be a problem, and it hasn' yet. But doing window manipulations while dumpwindow is working could cause troubles. Then again, you should run dumpwindow unless everything is stable anyway. Compile with Lattice 5.01. Use short ints, and line with cres.o. All works fine. #include #include #include #include #include #include #include #include #include #include /* * Declare names for the error returns. */ #define OK 0 #define NO_INTUITION 20 extern struct IntuitionBase *IntuitionBase ; void main(argc, argv) char **argv; { register struct Window *w ; register struct Screen *s ; register short length, i ; long lock ; /* * Setup - see if we need to fake a second argument. This works with Lattice * 5.0, and should work with all ANSI compilers, as argv[argc] is * supposed to be a NULL pointer. */ if (argc == 1) argc = 2 ; /* * Now, get IntuitionBase so we can find the window we need. */ if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0)) == NULL) { fprintf(stderr, "%s: Can't open intuition\n", argv[0]) ; exit(NO_INTUITION) ; } /* * We need to know how much of the window title to check. */ length = strlen(argv[1]) ; /* * Now, for each argument search through all windows to see if they're the * one we want. */ lock = LockIBase(0L) ; for (i = 1; i < argc; i++) for (s = IntuitionBase -> FirstScreen; s; s = s -> NextScreen) for (w = s -> FirstWindow; w; w = w -> NextWindow) if (strncmp(w -> Title, argv[i], length) == 0) printf("%d/%d/%d/%d/%s\n", w -> LeftEdge, w -> TopEdge, w -> Width, w -> Height, w -> Title) ; /* * Done with Intuition - free the lock, and then close the library and exit. */ UnlockIBase(lock) ; CloseLibrary((struct Library *) IntuitionBase) ; exit(OK) ; } -- Tell me how d'you get to be Mike Meyer As beautiful as that? mwm@berkeley.edu How did you get your mind ucbvax!mwm To tilt like your hat? mwm@ucbjade.BITNET