home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 144.lha / VScreen_Src / wMax.c < prev    next >
C/C++ Source or Header  |  1986-11-21  |  3KB  |  105 lines

  1. #include <exec/types.h>
  2. #include <intuition/intuitionbase.h>
  3. #include <intuition/screens.h>
  4. #include <proto/intuition.h>
  5. #include <proto/exec.h>
  6. #define INTUITION_REV   0L
  7. extern struct IntuitionBase *IntuitionBase;
  8. extern struct IntuitionBase *OpenLibrary();
  9. static void ShowUsage()
  10. {
  11.    printf("Usage:  WMAX x y [window [screen]]\n");
  12.    exit(10L);
  13. }
  14. --MORE--(77%)static void GetInt(i,s)
  15. long *i;
  16. char *s;
  17. {
  18.    if (sscanf(s,"%ld",i) != 1) ShowUsage();
  19. }
  20. static struct Screen *FindScreen(ScreenName)
  21. char *ScreenName;
  22. {
  23.    struct Screen *theScreen;
  24.    if (ScreenName && ScreenName[0])
  25.    {
  26.       theScreen = IntuitionBase->FirstScreen;
  27.       while (theScreen && (theScreen->Title == NULL ||
  28.              stricmp(theScreen->Title,ScreenName) != 0))
  29.                 theScreen = theScreen->NextScreen;
  30.    } else {
  31.       theScreen = IntuitionBase->ActiveScreen;
  32.    }
  33.    if (theScreen == NULL)
  34. --MORE--(78%)   {
  35.       Permit();
  36.       printf("Can't find screen '%s'\n",ScreenName);
  37.       exit(10L);
  38.    }
  39.    return(theScreen);
  40. }
  41. static struct Window *FindWindow(WindowName,theScreen)
  42. char *WindowName;
  43. struct Screen *theScreen;
  44. {
  45.    struct Window *theWindow;
  46.    if (WindowName && WindowName[0])
  47.    {
  48.       theWindow = theScreen->FirstWindow;
  49.       while (theWindow && (theWindow->Title == NULL ||
  50.              stricmp(theWindow->Title,WindowName) != 0))
  51.                 theWindow = theWindow->NextWindow;
  52.    } else {
  53.       theWindow = IntuitionBase->ActiveWindow;
  54. --MORE--(79%)   }
  55.    if (theWindow == NULL)
  56.    {
  57.       Permit();
  58.       printf("Can't find window '%s' on screen '%s'\n",
  59.          WindowName,theScreen->Title);
  60.       exit(10L);
  61.    }
  62.    Permit();
  63.    return(theWindow);
  64. }
  65. void main(argc,argv)
  66. int argc;
  67. char *argv[];
  68. {
  69.    char *WindowName = NULL;
  70.    char *ScreenName = NULL;
  71.    long x,y;
  72.    struct Window *theWindow;
  73.    struct Screen *theScreen;
  74. --MORE--(80%)
  75.    if (argc < 3 || argc > 5) ShowUsage();
  76.    GetInt(&x,argv[1]);
  77.    GetInt(&y,argv[2]);
  78.    if (argc > 3 && argv[3] && argv[3][0] != '\0') WindowName = argv[3];
  79.    if (argc > 4 && argv[4] && argv[4][0] != '\0') ScreenName = argv[4];
  80.    
  81.    IntuitionBase = OpenLibrary("intuition.library",INTUITION_REV);
  82.    if (IntuitionBase)
  83.    {
  84.       Forbid();
  85.       theScreen = FindScreen(ScreenName);
  86.       theWindow = FindWindow(WindowName,theScreen);
  87.       Permit();
  88.       printf("\nWindow '%s' on Screen '%s'\n",
  89.          theWindow->Title,theWindow->WScreen->Title);
  90.       printf("   Old Max:  (%d,%d)    Old Min:  (%d,%d)\n",
  91.          theWindow->MaxWidth,theWindow->MaxHeight,
  92.          theWindow->MinWidth,theWindow->MinHeight);
  93.       if (x || y)
  94.       {
  95.          Forbid();
  96. --MORE--(82%)         theWindow->MaxWidth  = x;
  97.          theWindow->MaxHeight = y;
  98.          Permit();
  99.          printf("   New Max:  (%d,%d)\n\n",
  100.             theWindow->MaxWidth,theWindow->MaxHeight);
  101.       }
  102.       CloseLibrary(IntuitionBase);
  103.    }
  104. }
  105.