/* This little utility was written by the German Softcracking Group 9 and intentionally left in the PUBLIC DOMAIN. Feel free to copy the program and this Lattice-C source file, but keep the name of the autor in it. G.S.G. 9 (Cewy) 10-May-87 If you'll do any changes (fix bugs or else) leave the new source (Lattice only !) at the BBS-BOX called 'Barrel-Burst-Box' and a message to me 'CEWY'. I'll check the box each week! Phone : (Germany) 06151/ 595240 (300 8N1 or 1200 8N1) */ /* executable (batch) file : .key name .def name MoveWindow stack 30000 lc -v BLink FROM LIB:c.o+.o TO LIBRARY LIB:lc.lib+LIB:amiga.lib NODEBUG */ /* -------------------------- include section ------------------------ */ #include #include /* -------------------------- define section ------------------------- */ #define DEFAULT_NAME "AmigaDOS" /* -------------------- global variable section ---------------------- */ struct IntuitionBase *IntuitionBase = NULL; struct Window *MyWindow; struct NewWindow MyWindowStruct = { 0,0,1,1,1,1,0,0, NULL, NULL, NULL, NULL, NULL,0,0,0,0,WBENCHSCREEN }; /* ---------------------- local function section --------------------- */ /* DESCRIPTION : print the usage of the program, so the user knows how to handle it. BUGS : none. COMMENT : uses puts instead of printf, cause puts is much shorter. */ void Usage() { puts ("Usage: MoveWindow NewXpos [NewYpos [NewXSize [NewYSize [WindowTitle]]]]"); puts ("written by G.S.G. 9 in May '87"); exit (20); } /* ----------------------- main program section ----------------------- */ /* DESCRIPTION : Find the WorkbenchScreen and search requested window by it's Title. If the window was found : Size and drag the window with care! BUGS : sometimes the borders of the windows get hurt. COMMENT : none. */ main (argc,argv) int argc; char *argv[]; { SHORT Xpos, Ypos, Xwide, Ywide; int DeltaPosX, DeltaPosY, DeltaSizeX, DeltaSizeY; struct Screen *WBenchPtr; struct Window *Wind; UBYTE *WindName; /* check the number of arguments */ if (argc <2 || argc >6 || *argv[1] == '?') Usage (); /* open the intuition for OpenWindow */ if (!(IntuitionBase = (struct IntuitionBase *) OpenLibrary ("intuition.library",0))) exit (100); /* open a New Window */ if (!(MyWindow = (struct Window *) OpenWindow (&MyWindowStruct))) exit (200); /* Now we got a pointer to the WorkbenchScreen */ WBenchPtr = MyWindow -> WScreen; /* we don't need this window any longer, so close it */ CloseWindow (MyWindow); /* if a title is given by the user, use it */ if (argc <6) WindName = DEFAULT_NAME; else WindName = argv[--argc]; /* decrement argc for later use */ /* get a pointer the the first window on the WBScreen */ Wind = WBenchPtr->FirstWindow; /* search the list of windows on the WBScreen for the one to be found */ while (Wind && (strcmp (WindName,Wind->Title))) Wind = Wind->NextWindow; /* if the window isn't there, Wind will point to NULL (=FALSE) */ if (Wind) { Ywide = Wind->Height; /* get the previous values */ Xwide = Wind->Width; Ypos = Wind->TopEdge; /* Xpos = Wind->LeftEdge; this one is changed each time */ /* change current settings */ switch (argc) { case 5: Ywide = (SHORT) atoi (argv[4]); /* remember that each */ case 4: Xwide = (SHORT) atoi (argv[3]); /* case lower will be */ case 3: Ypos = (SHORT) atoi (argv[2]); /* executed ! */ case 2: Xpos = (SHORT) atoi (argv[1]); } /* if the user does too big things, we don't care. I won't get the ScreenLimits (640,256 or 704,276 (mine) or ....) for checking boundaries */ /* This should be changed, anybody out there knows how? */ DeltaSizeY = Ywide - Wind->Height; /* calculate Delta Values */ DeltaSizeX = Xwide - Wind->Width; DeltaPosX = Xpos - Wind->LeftEdge; DeltaPosY = Ypos - Wind->TopEdge; /* it's a different thing to drag a big window down and size it before or after draging! */ if (DeltaSizeY < 0) { SizeWindow (Wind, 0, DeltaSizeY); MoveWindow (Wind, 0, DeltaPosY); } else { MoveWindow (Wind, 0, DeltaPosY); SizeWindow (Wind, 0, DeltaSizeY); } if (DeltaSizeX < 0) { SizeWindow (Wind, DeltaSizeX, 0); MoveWindow (Wind, DeltaPosX, 0); } else { MoveWindow (Wind, DeltaPosX, 0); SizeWindow (Wind, DeltaSizeX, 0); } } else { /* let the user know that he typed something wrong */ puts ("Sorry, didn't found that window\n"); } /* close the opened library */ CloseLibrary (IntuitionBase); /* say 'well done' the the system */ return (0); }