mwm@violet.berkeley.edu (Mike (I'll think of something yet) Meyer) (01/12/89)
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. <mike --------------- cut here, don't forget the .signature --------------- /* * dumpwindow - just dump the dimensions of a window. * * Copyright (c) 1989, Mike Meyer * * This program can be redistributed freely, under two conditions: * 1) The source must be part of the distribution. * 2) This copyright notice must stay attached to the source. * * usage: dumpwindow [windowname ...] * * the windownames are a proper prefix of the title for the * window that we're going to dump the size & coordinates * of. The dump format is suitable for use as a con: window * name. Easy editing will make it useful for placewindow * or conman: or other, similar things. You can get all * windows by using a windowname of "", or by using no * windowname at all (that feature may not work with all * compilers). */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dos.h> #include <ctype.h> #include <exec/types.h> #include <proto/dos.h> #include <proto/exec.h> #include <proto/intuition.h> #include <libraries/dos.h> #include <intuition/intuitionbase.h> /* * 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
packer@h.cs.wvu.wvnet.edu (Michael A Packer,318 Knapp,,2928607) (01/12/89)
From article <18995@agate.BERKELEY.EDU>, by mwm@violet.berkeley.edu (Mike (I'll think of something yet) Meyer): > > 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 > [...] How about when posting something like this, also posting an uuencoded version for people that do not have Lattice 5.01 or even a Lattice C compiler? Michael USMAIL: 318 Knapp Hall, WVU, Morgantown, WV 26506 PHONE: 304 293-3607 INTERNET : packer@a.cs.wvu.wvnet.edu USENET: {allegra,bellcore,ihpn4!cadre,decvax!idis,psuvax1}!pitt!wvucsa!packer