home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d4xx / d494 / vscreen.lha / vScreen / Utilities / Source / wMax.c < prev    next >
C/C++ Source or Header  |  1991-06-06  |  3KB  |  120 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.  
  7. #define INTUITION_REV   0L
  8. extern struct IntuitionBase *IntuitionBase;
  9. extern struct IntuitionBase *OpenLibrary();
  10.  
  11.  
  12. static void ShowUsage()
  13. {
  14.    printf("Usage:  WMAX x y [window [screen]]\n");
  15.    exit(10L);
  16. }
  17.  
  18.  
  19. static void GetInt(i,s)
  20. long *i;
  21. char *s;
  22. {
  23.    if (sscanf(s,"%ld",i) != 1) ShowUsage();
  24. }
  25.  
  26. static struct Screen *FindScreen(ScreenName)
  27. char *ScreenName;
  28. {
  29.    struct Screen *theScreen;
  30.  
  31.    if (ScreenName && ScreenName[0])
  32.    {
  33.       theScreen = IntuitionBase->FirstScreen;
  34.       while (theScreen && (theScreen->Title == NULL ||
  35.              stricmp(theScreen->Title,ScreenName) != 0))
  36.                 theScreen = theScreen->NextScreen;
  37.    } else {
  38.       theScreen = IntuitionBase->ActiveScreen;
  39.    }
  40.  
  41.    if (theScreen == NULL)
  42.    {
  43.       Permit();
  44.       printf("Can't find screen '%s'\n",ScreenName);
  45.       exit(10L);
  46.    }
  47.    return(theScreen);
  48. }
  49.  
  50.  
  51. static struct Window *FindWindow(WindowName,theScreen)
  52. char *WindowName;
  53. struct Screen *theScreen;
  54. {
  55.    struct Window *theWindow;
  56.  
  57.    if (WindowName && WindowName[0])
  58.    {
  59.       theWindow = theScreen->FirstWindow;
  60.       while (theWindow && (theWindow->Title == NULL ||
  61.              stricmp(theWindow->Title,WindowName) != 0))
  62.                 theWindow = theWindow->NextWindow;
  63.    } else {
  64.       theWindow = IntuitionBase->ActiveWindow;
  65.    }
  66.  
  67.    if (theWindow == NULL)
  68.    {
  69.       Permit();
  70.       printf("Can't find window '%s' on screen '%s'\n",
  71.          WindowName,theScreen->Title);
  72.       exit(10L);
  73.    }
  74.    Permit();
  75.    return(theWindow);
  76. }
  77.  
  78.  
  79. void main(argc,argv)
  80. int argc;
  81. char *argv[];
  82. {
  83.    char *WindowName = NULL;
  84.    char *ScreenName = NULL;
  85.    long x,y;
  86.    struct Window *theWindow;
  87.    struct Screen *theScreen;
  88.  
  89.    if (argc < 3 || argc > 5) ShowUsage();
  90.    GetInt(&x,argv[1]);
  91.    GetInt(&y,argv[2]);
  92.    if (argc > 3 && argv[3] && argv[3][0] != '\0') WindowName = argv[3];
  93.    if (argc > 4 && argv[4] && argv[4][0] != '\0') ScreenName = argv[4];
  94.    
  95.    IntuitionBase = OpenLibrary("intuition.library",INTUITION_REV);
  96.    if (IntuitionBase)
  97.    {
  98.       Forbid();
  99.       theScreen = FindScreen(ScreenName);
  100.       theWindow = FindWindow(WindowName,theScreen);
  101.       Permit();
  102.  
  103.       printf("\nWindow '%s' on Screen '%s'\n",
  104.          theWindow->Title,theWindow->WScreen->Title);
  105.       printf("   Old Max:  (%d,%d)    Old Min:  (%d,%d)\n",
  106.          theWindow->MaxWidth,theWindow->MaxHeight,
  107.          theWindow->MinWidth,theWindow->MinHeight);
  108.       if (x || y)
  109.       {
  110.          Forbid();
  111.          theWindow->MaxWidth  = x;
  112.          theWindow->MaxHeight = y;
  113.          Permit();
  114.          printf("   New Max:  (%d,%d)\n\n",
  115.             theWindow->MaxWidth,theWindow->MaxHeight);
  116.       }
  117.       CloseLibrary(IntuitionBase);
  118.    }
  119. }
  120.