home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / MDI-15.ZIP / TEST.C < prev    next >
Text File  |  1990-08-30  |  26KB  |  684 lines

  1. // Includes
  2. // --------
  3.    #define INCL_WIN
  4.    #define INCL_GPI
  5.  
  6.    #include <malloc.h>
  7.    #include <stdio.h>
  8.    #include <os2.h>
  9.  
  10.    #include "Test.H"
  11.    #include "MDI.H"
  12.  
  13.  
  14. // Function Declarations
  15. // ---------------------
  16.    MRESULT EXPENTRY DesktopWndProc (HWND, USHORT, MPARAM, MPARAM);
  17.    MRESULT EXPENTRY WhiteWndProc   (HWND, USHORT, MPARAM, MPARAM);
  18.    MRESULT EXPENTRY BlueWndProc    (HWND, USHORT, MPARAM, MPARAM);
  19.    MRESULT EXPENTRY RedWndProc     (HWND, USHORT, MPARAM, MPARAM);
  20.    MRESULT EXPENTRY PinkWndProc    (HWND, USHORT, MPARAM, MPARAM);
  21.    MRESULT EXPENTRY GreenWndProc   (HWND, USHORT, MPARAM, MPARAM);
  22.    MRESULT EXPENTRY CyanWndProc    (HWND, USHORT, MPARAM, MPARAM);
  23.    MRESULT EXPENTRY YellowWndProc  (HWND, USHORT, MPARAM, MPARAM);
  24.  
  25.    MRESULT          ReportError    (HAB, PCHAR, USHORT);
  26.  
  27.  
  28. // Function: main -- Main message loop
  29. // -----------------------------------
  30.    VOID main (VOID)
  31.  
  32.    // Define function data
  33.  
  34.      {HAB hab ;
  35.       HMQ hmq;
  36.       QMSG qmsg ;
  37.       HWND hwndDesktop;
  38.  
  39.       ULONG flCreateFlags = (FCF_STANDARD | FCF_NOBYTEALIGN) & ~FCF_TASKLIST;
  40.  
  41.       ULONG flOptions = (MDI_KEEP_WINDOWS_MENU | MDI_INITIAL_MAX_DESKTOP | MDI_INITIAL_TILE_ALWAYS
  42.                            | MDI_DISABLE_DESKTOP_POSITION | MDI_ALWAYS_ON_RESIZE | MDI_DISABLE_DOCUMENT_POSITION);
  43.  
  44.    // Initialize PM
  45.  
  46.       hab = WinInitialize (0) ;
  47.       hmq = WinCreateMsgQueue (hab, 0) ;
  48.  
  49.    // Initialize MDI
  50.  
  51.       MDIInitialize (hab);
  52.  
  53.    // Create MDI Desktop
  54.  
  55.       MDICreateDesktop (DesktopWndProc, flCreateFlags, "MDI Test Program",
  56.         (HMODULE) NULL, IDR_DESKTOP, &hwndDesktop, 100, 1, "Options", "Exit", "~Window", flOptions);
  57.  
  58.    // Main message loop
  59.  
  60.       while (WinGetMsg (hab, &qmsg, (HWND) NULL, 0, 0))
  61.          WinDispatchMsg (hab, &qmsg) ;
  62.  
  63.    // Terminate PM
  64.  
  65.       WinDestroyMsgQueue (hmq) ;
  66.       WinTerminate (hab) ;
  67.      }
  68.  
  69.  
  70. // Function: ReportError -- Show PM Errors
  71. // ---------------------------------------
  72.    MRESULT ReportError (hab, pszFileName, usLineNum)
  73.  
  74.       HAB hab;
  75.       PCHAR pszFileName;
  76.       USHORT usLineNum;
  77.  
  78.    // Define function data
  79.  
  80.      {PERRINFO perri;
  81.       CHAR szCaption[128];
  82.       PSZ pszMsg;
  83.       PUSHORT pusMsg;
  84.       MRESULT mrError = NULL;
  85.  
  86.    // Obtain error information
  87.  
  88.       if ((perri = WinGetErrorInfo (hab)) == NULL)
  89.          return mrError;
  90.  
  91.    // Display error information
  92.  
  93.       SELECTOROF (pusMsg) = SELECTOROF (perri);
  94.       SELECTOROF (pszMsg) = SELECTOROF (perri);
  95.       OFFSETOF (pusMsg) = perri->offaoffszMsg;
  96.       OFFSETOF (pszMsg) = *pusMsg;
  97.       mrError = perri->idError;
  98.       sprintf (szCaption, "Error %lX in %s at line %d", mrError,
  99.         (pszFileName == NULL)? "Unknown" : pszFileName, usLineNum);
  100.       if (WinMessageBox (HWND_DESKTOP, HWND_DESKTOP, pszMsg, szCaption,
  101.         0, MB_CUACRITICAL | MB_OKCANCEL) == MBID_CANCEL)
  102.          WinPostMsg (NULL, WM_QUIT, NULL, NULL);
  103.  
  104.    // Free error information and return
  105.  
  106.       WinFreeErrorInfo (perri);
  107.       return mrError;
  108.  
  109.      }
  110.  
  111.  
  112. // Function: DesktopWndProc -- MDI Desktop Window Procedure
  113. // --------------------------------------------------------
  114.    MRESULT EXPENTRY DesktopWndProc (hwndDesktop, msg, mp1, mp2)
  115.  
  116.       HWND hwndDesktop;                // Desktop window
  117.       USHORT msg;                      // PM message
  118.       MPARAM mp1;                      // Mesage parameter 1
  119.       MPARAM mp2;                      // Mesage parameter 2
  120.  
  121.    // Define function data
  122.  
  123.      {HWND hwndDocument;
  124.       ULONG flCreateFlags = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER
  125.         | FCF_MINMAX | FCF_ICON | FCF_SHELLPOSITION | FCF_NOBYTEALIGN
  126.         | FCF_VERTSCROLL | FCF_HORZSCROLL | FCF_MENU;
  127.  
  128.    // Create documents
  129.  
  130.       switch (msg)
  131.         {case WM_COMMAND:
  132.             switch (LOUSHORT (mp1))
  133.               {case IDM_WHITE:
  134.                   MDICreateDocument (WhiteWndProc, hwndDesktop, flCreateFlags,
  135.                     "White", (HMODULE) NULL, IDR_WHITE, &hwndDocument, 100, 100, 100);
  136.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_WHITE);
  137.                   return (MRESULT) NULL;
  138.                case IDM_BLUE:
  139.                   MDICreateDocument (BlueWndProc, hwndDesktop, flCreateFlags,
  140.                     "Blue", (HMODULE) NULL, IDR_BLUE, &hwndDocument, 0, 0, 200);
  141.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_BLUE);
  142.                   return (MRESULT) NULL;
  143.                case IDM_RED:
  144.                   MDICreateDocument (RedWndProc, hwndDesktop, flCreateFlags,
  145.                     "Red", (HMODULE) NULL, IDR_RED, &hwndDocument, 0, 0, 300);
  146.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_RED);
  147.                   return (MRESULT) NULL;
  148.                case IDM_PINK:
  149.                   MDICreateDocument (PinkWndProc, hwndDesktop, flCreateFlags,
  150.                     "Pink", (HMODULE) NULL, IDR_PINK, &hwndDocument, 0, 0, 400);
  151.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_PINK);
  152.                   return (MRESULT) NULL;
  153.                case IDM_GREEN:
  154.                   MDICreateDocument (GreenWndProc, hwndDesktop, flCreateFlags,
  155.                     "Green", (HMODULE) NULL, IDR_GREEN, &hwndDocument, 0, 0, 500);
  156.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_GREEN);
  157.                   return (MRESULT) NULL;
  158.                case IDM_CYAN:
  159.                   MDICreateDocument (CyanWndProc, hwndDesktop, flCreateFlags,
  160.                     "Cyan", (HMODULE) NULL, IDR_CYAN, &hwndDocument, 0, 0, 600);
  161.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_CYAN);
  162.                   return (MRESULT) NULL;
  163.                case IDM_YELLOW:
  164.                   MDICreateDocument (YellowWndProc, hwndDesktop, flCreateFlags,
  165.                     "Yellow", (HMODULE) NULL, IDR_YELLOW, &hwndDocument, 0, 0, 700);
  166.                   WinSetWindowULong (hwndDocument, QWL_USER, CLR_YELLOW);
  167.                   return (MRESULT) NULL;
  168.               }
  169.             break;
  170.  
  171.       // Respond to desktop notifications
  172.  
  173.          case WM_CONTROL:
  174.             switch (HIUSHORT (mp1))
  175.               {case MDI_INHIBIT_CLOSE_DESKTOP:
  176.                   return (MRESULT) (MBID_NO == WinMessageBox (HWND_DESKTOP, hwndDesktop,
  177.                     "Do you really want to terminate?", "MDI Desktop", 0, MB_ICONQUESTION | MB_YESNO));
  178.               }
  179.             break;
  180.         }
  181.  
  182.    // Allow MDI to process all other messages
  183.  
  184.       return MDIDesktopWndProc (hwndDesktop, msg, mp1, mp2) ;
  185.  
  186.      }
  187.  
  188.  
  189. // Function: WhiteWndProc -- "White" Document Window Procedure
  190. // -----------------------------------------------------------
  191.    MRESULT EXPENTRY WhiteWndProc (hwndDocument, msg, mp1, mp2)
  192.  
  193.       HWND hwndDocument;               // Document window
  194.       USHORT msg;                      // PM message
  195.       MPARAM mp1;                      // Mesage parameter 1
  196.       MPARAM mp2;                      // Mesage parameter 2
  197.  
  198.    // Define function data
  199.  
  200.      {HPS hps;
  201.       RECTL rcl;
  202.       COLOR clr;
  203.       PVOID pv;
  204.  
  205.       static BOOL fChecked;
  206.       static BOOL fGrayed;
  207.  
  208.    // Process PM messages
  209.  
  210.       switch (msg)
  211.  
  212.       // Process commands
  213.  
  214.         {case WM_COMMAND:
  215.             switch (LOUSHORT (mp1))
  216.               {case IDM_FOO:
  217.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "White", 0, MB_OK | MB_ICONEXCLAMATION);
  218.                   return (MRESULT) NULL;
  219.                case IDM_BAR:
  220.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "White", 0, MB_OK | MB_ICONEXCLAMATION);
  221.                   return (MRESULT) NULL;
  222.                case IDM_FOOBAR:
  223.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "White", 0, MB_OK | MB_ICONEXCLAMATION);
  224.                   return (MRESULT) NULL;
  225.                case IDM_DOTHIS:
  226.                   WinSendMsg (hwndDocument, MDI_MSG_SET_DESKTOP_TITLE, (MPARAM) "New Desktop Title", NULL);
  227.                   return (MRESULT) NULL;
  228.                case IDM_DOTHAT:
  229.                   WinSendMsg (hwndDocument, MDI_MSG_SET_INSTANCE_TITLE, (MPARAM) "New White Instance Title", NULL);
  230.                   return (MRESULT) NULL;
  231.                case IDM_DOTHEOTHER:
  232.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "White", 0, MB_OK | MB_ICONEXCLAMATION);
  233.                   return (MRESULT) NULL;
  234.               }
  235.             break;
  236.  
  237.       // Respond to document notifications
  238.  
  239.          case WM_CONTROL:
  240.             switch (HIUSHORT (mp1))
  241.               {case MDI_INHIBIT_CLOSE_INSTANCE:
  242.                   pv = (PVOID) WinSendMsg (hwndDocument, MDI_MSG_LOCATE_DESKTOP_DATA, (MPARAM) NULL, (MPARAM) NULL);
  243.                   if (pv == NULL)
  244.                      return (MRESULT) NULL;
  245.                   pv = (PVOID) WinSendMsg (hwndDocument, MDI_MSG_LOCATE_DOCUMENT_DATA, (MPARAM) NULL, (MPARAM) NULL);
  246.                   if (pv == NULL)
  247.                      return (MRESULT) NULL;
  248.                   pv = (PVOID) WinSendMsg (hwndDocument, MDI_MSG_LOCATE_INSTANCE_DATA, (MPARAM) NULL, (MPARAM) NULL);
  249.                   if (pv == NULL)
  250.                      return (MRESULT) NULL;
  251.                   return (MRESULT) NULL;
  252.                // return (MRESULT) (MBID_NO == WinMessageBox (HWND_DESKTOP, hwndDocument,
  253.                //   "Do you really want to close?", "MDI White Document Close", 0, MB_ICONQUESTION | MB_YESNO));
  254.                case MDI_INHIBIT_CLOSE_DESKTOP:
  255.                   pv = (PVOID) WinSendMsg (hwndDocument, MDI_MSG_LOCATE_DESKTOP_DATA, (MPARAM) NULL, (MPARAM) NULL);
  256.                   if (pv == NULL)
  257.                      return (MRESULT) NULL;
  258.                   pv = (PVOID) WinSendMsg (hwndDocument, MDI_MSG_LOCATE_DOCUMENT_DATA, (MPARAM) NULL, (MPARAM) NULL);
  259.                   if (pv == NULL)
  260.                      return (MRESULT) NULL;
  261.                   pv = (PVOID) WinSendMsg (hwndDocument, MDI_MSG_LOCATE_INSTANCE_DATA, (MPARAM) NULL, (MPARAM) NULL);
  262.                   if (pv == NULL)
  263.                      return (MRESULT) NULL;
  264.                   return (MRESULT) NULL;
  265.                // return (MRESULT) (MBID_NO == WinMessageBox (HWND_DESKTOP, hwndDocument,
  266.                //   "Do you really want to close?", "MDI White Desktop Close", 0, MB_ICONQUESTION | MB_YESNO));
  267.                case MDI_NOTIFY_CASCADE_INSTANCE:
  268.                   return (MRESULT) NULL;
  269.                case MDI_NOTIFY_TILE_INSTANCE:
  270.                   return (MRESULT) NULL;
  271.                case MDI_NOTIFY_ACTIVATE_INSTANCE:
  272.                   return (MRESULT) NULL;
  273.                case MDI_NOTIFY_DEACTIVATE_INSTANCE:
  274.                   return (MRESULT) NULL;
  275.               }
  276.             break;
  277.  
  278.       // Menu initialization
  279.  
  280.          case WM_INITMENU:
  281.             fChecked = ! fChecked;
  282.             WinSendMsg (HWNDFROMMP (mp2), MM_SETITEMATTR,
  283.               MPFROM2SHORT (IDM_DOTHAT, TRUE),
  284.               MPFROM2SHORT (MIA_CHECKED, (fChecked)? MIA_CHECKED : FALSE));
  285.             fGrayed = ! fGrayed;
  286.             WinSendMsg (HWNDFROMMP (mp2), MM_SETITEMATTR,
  287.               MPFROM2SHORT (IDM_DOTHEOTHER, TRUE),
  288.               MPFROM2SHORT (MIA_DISABLED, (fGrayed)? MIA_DISABLED : FALSE));
  289.             return (MRESULT) NULL;
  290.  
  291.       // Menu termination
  292.  
  293.          case WM_MENUEND:
  294.             return (MRESULT) NULL;
  295.  
  296.       // Paint window
  297.  
  298.          case WM_PAINT:
  299.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  300.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  301.             WinQueryWindowRect (hwndDocument, &rcl);
  302.             WinFillRect (hps, &rcl, clr);
  303.             WinEndPaint (hps);
  304.             return (MRESULT) NULL;
  305.         }
  306.  
  307.    // Allow MDI to process all other messages
  308.  
  309.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  310.  
  311.      }
  312.  
  313.  
  314. // Function: BlueWndProc -- "Blue" Document Window Procedure
  315. // ---------------------------------------------------------
  316.    MRESULT EXPENTRY BlueWndProc (hwndDocument, msg, mp1, mp2)
  317.  
  318.       HWND hwndDocument;               // Document window
  319.       USHORT msg;                      // PM message
  320.       MPARAM mp1;                      // Mesage parameter 1
  321.       MPARAM mp2;                      // Mesage parameter 2
  322.  
  323.    // Define function data
  324.  
  325.      {HPS hps;
  326.       RECTL rcl;
  327.       COLOR clr;
  328.  
  329.    // Process PM messages
  330.  
  331.       switch (msg)
  332.  
  333.       // Process commands
  334.  
  335.         {case WM_COMMAND:
  336.             switch (LOUSHORT (mp1))
  337.               {case IDM_FOO:
  338.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "Blue", 0, MB_OK | MB_ICONEXCLAMATION);
  339.                   return (MRESULT) NULL;
  340.                case IDM_BAR:
  341.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "Blue", 0, MB_OK | MB_ICONEXCLAMATION);
  342.                   return (MRESULT) NULL;
  343.                case IDM_FOOBAR:
  344.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "Blue", 0, MB_OK | MB_ICONEXCLAMATION);
  345.                   return (MRESULT) NULL;
  346.                case IDM_DOTHIS:
  347.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do This", "Blue", 0, MB_OK | MB_ICONEXCLAMATION);
  348.                   return (MRESULT) NULL;
  349.                case IDM_DOTHAT:
  350.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do That", "Blue", 0, MB_OK | MB_ICONEXCLAMATION);
  351.                   return (MRESULT) NULL;
  352.                case IDM_DOTHEOTHER:
  353.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "Blue", 0, MB_OK | MB_ICONEXCLAMATION);
  354.                   return (MRESULT) NULL;
  355.               }
  356.             break;
  357.  
  358.       // Paint window
  359.  
  360.          case WM_PAINT:
  361.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  362.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  363.             WinQueryWindowRect (hwndDocument, &rcl);
  364.             WinFillRect (hps, &rcl, clr);
  365.             WinEndPaint (hps);
  366.             return (MRESULT) NULL;
  367.         }
  368.  
  369.    // Allow MDI to process all other messages
  370.  
  371.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  372.  
  373.      }
  374.  
  375.  
  376. // Function: RedWndProc -- "Red" Document Window Procedure
  377. // -------------------------------------------------------
  378.    MRESULT EXPENTRY RedWndProc (hwndDocument, msg, mp1, mp2)
  379.  
  380.       HWND hwndDocument;               // Document window
  381.       USHORT msg;                      // PM message
  382.       MPARAM mp1;                      // Mesage parameter 1
  383.       MPARAM mp2;                      // Mesage parameter 2
  384.  
  385.    // Define function data
  386.  
  387.      {HPS hps;
  388.       RECTL rcl;
  389.       COLOR clr;
  390.  
  391.    // Process PM messages
  392.  
  393.       switch (msg)
  394.  
  395.       // Process commands
  396.  
  397.         {case WM_COMMAND:
  398.             switch (LOUSHORT (mp1))
  399.               {case IDM_FOO:
  400.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "Red", 0, MB_OK | MB_ICONEXCLAMATION);
  401.                   return (MRESULT) NULL;
  402.                case IDM_BAR:
  403.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "Red", 0, MB_OK | MB_ICONEXCLAMATION);
  404.                   return (MRESULT) NULL;
  405.                case IDM_FOOBAR:
  406.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "Red", 0, MB_OK | MB_ICONEXCLAMATION);
  407.                   return (MRESULT) NULL;
  408.                case IDM_DOTHIS:
  409.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do This", "Red", 0, MB_OK | MB_ICONEXCLAMATION);
  410.                   return (MRESULT) NULL;
  411.                case IDM_DOTHAT:
  412.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do That", "Red", 0, MB_OK | MB_ICONEXCLAMATION);
  413.                   return (MRESULT) NULL;
  414.                case IDM_DOTHEOTHER:
  415.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "Red", 0, MB_OK | MB_ICONEXCLAMATION);
  416.                   return (MRESULT) NULL;
  417.               }
  418.             break;
  419.  
  420.       // Paint window
  421.  
  422.          case WM_PAINT:
  423.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  424.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  425.             WinQueryWindowRect (hwndDocument, &rcl);
  426.             WinFillRect (hps, &rcl, clr);
  427.             WinEndPaint (hps);
  428.             return (MRESULT) NULL;
  429.         }
  430.  
  431.    // Allow MDI to process all other messages
  432.  
  433.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  434.  
  435.      }
  436.  
  437.  
  438. // Function: PinkWndProc -- "Pink" Document Window Procedure
  439. // ---------------------------------------------------------
  440.    MRESULT EXPENTRY PinkWndProc (hwndDocument, msg, mp1, mp2)
  441.  
  442.       HWND hwndDocument;               // Document window
  443.       USHORT msg;                      // PM message
  444.       MPARAM mp1;                      // Mesage parameter 1
  445.       MPARAM mp2;                      // Mesage parameter 2
  446.  
  447.    // Define function data
  448.  
  449.      {HPS hps;
  450.       RECTL rcl;
  451.       COLOR clr;
  452.  
  453.    // Process PM messages
  454.  
  455.       switch (msg)
  456.  
  457.       // Process commands
  458.  
  459.         {case WM_COMMAND:
  460.             switch (LOUSHORT (mp1))
  461.               {case IDM_FOO:
  462.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "Pink", 0, MB_OK | MB_ICONEXCLAMATION);
  463.                   return (MRESULT) NULL;
  464.                case IDM_BAR:
  465.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "Pink", 0, MB_OK | MB_ICONEXCLAMATION);
  466.                   return (MRESULT) NULL;
  467.                case IDM_FOOBAR:
  468.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "Pink", 0, MB_OK | MB_ICONEXCLAMATION);
  469.                   return (MRESULT) NULL;
  470.                case IDM_DOTHIS:
  471.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do This", "Pink", 0, MB_OK | MB_ICONEXCLAMATION);
  472.                   return (MRESULT) NULL;
  473.                case IDM_DOTHAT:
  474.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do That", "Pink", 0, MB_OK | MB_ICONEXCLAMATION);
  475.                   return (MRESULT) NULL;
  476.                case IDM_DOTHEOTHER:
  477.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "Pink", 0, MB_OK | MB_ICONEXCLAMATION);
  478.                   return (MRESULT) NULL;
  479.               }
  480.             break;
  481.  
  482.       // Paint window
  483.  
  484.          case WM_PAINT:
  485.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  486.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  487.             WinQueryWindowRect (hwndDocument, &rcl);
  488.             WinFillRect (hps, &rcl, clr);
  489.             WinEndPaint (hps);
  490.             return (MRESULT) NULL;
  491.         }
  492.  
  493.    // Allow MDI to process all other messages
  494.  
  495.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  496.  
  497.      }
  498.  
  499.  
  500. // Function: GreenWndProc -- "Green" Document Window Procedure
  501. // -----------------------------------------------------------
  502.    MRESULT EXPENTRY GreenWndProc (hwndDocument, msg, mp1, mp2)
  503.  
  504.       HWND hwndDocument;               // Document window
  505.       USHORT msg;                      // PM message
  506.       MPARAM mp1;                      // Mesage parameter 1
  507.       MPARAM mp2;                      // Mesage parameter 2
  508.  
  509.    // Define function data
  510.  
  511.      {HPS hps;
  512.       RECTL rcl;
  513.       COLOR clr;
  514.  
  515.    // Process PM messages
  516.  
  517.       switch (msg)
  518.  
  519.       // Process commands
  520.  
  521.         {case WM_COMMAND:
  522.             switch (LOUSHORT (mp1))
  523.               {case IDM_FOO:
  524.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "Green", 0, MB_OK | MB_ICONEXCLAMATION);
  525.                   return (MRESULT) NULL;
  526.                case IDM_BAR:
  527.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "Green", 0, MB_OK | MB_ICONEXCLAMATION);
  528.                   return (MRESULT) NULL;
  529.                case IDM_FOOBAR:
  530.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "Green", 0, MB_OK | MB_ICONEXCLAMATION);
  531.                   return (MRESULT) NULL;
  532.                case IDM_DOTHIS:
  533.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do This", "Green", 0, MB_OK | MB_ICONEXCLAMATION);
  534.                   return (MRESULT) NULL;
  535.                case IDM_DOTHAT:
  536.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do That", "Green", 0, MB_OK | MB_ICONEXCLAMATION);
  537.                   return (MRESULT) NULL;
  538.                case IDM_DOTHEOTHER:
  539.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "Green", 0, MB_OK | MB_ICONEXCLAMATION);
  540.                   return (MRESULT) NULL;
  541.               }
  542.             break;
  543.  
  544.       // Paint window
  545.  
  546.          case WM_PAINT:
  547.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  548.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  549.             WinQueryWindowRect (hwndDocument, &rcl);
  550.             WinFillRect (hps, &rcl, clr);
  551.             WinEndPaint (hps);
  552.             return (MRESULT) NULL;
  553.         }
  554.  
  555.    // Allow MDI to process all other messages
  556.  
  557.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  558.  
  559.      }
  560.  
  561.  
  562. // Function: CyanWndProc -- "Cyan" Document Window Procedure
  563. // ---------------------------------------------------------
  564.    MRESULT EXPENTRY CyanWndProc (hwndDocument, msg, mp1, mp2)
  565.  
  566.       HWND hwndDocument;               // Document window
  567.       USHORT msg;                      // PM message
  568.       MPARAM mp1;                      // Mesage parameter 1
  569.       MPARAM mp2;                      // Mesage parameter 2
  570.  
  571.    // Define function data
  572.  
  573.      {HPS hps;
  574.       RECTL rcl;
  575.       COLOR clr;
  576.  
  577.    // Process PM messages
  578.  
  579.       switch (msg)
  580.  
  581.       // Process commands
  582.  
  583.         {case WM_COMMAND:
  584.             switch (LOUSHORT (mp1))
  585.               {case IDM_FOO:
  586.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "Cyan", 0, MB_OK | MB_ICONEXCLAMATION);
  587.                   return (MRESULT) NULL;
  588.                case IDM_BAR:
  589.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "Cyan", 0, MB_OK | MB_ICONEXCLAMATION);
  590.                   return (MRESULT) NULL;
  591.                case IDM_FOOBAR:
  592.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "Cyan", 0, MB_OK | MB_ICONEXCLAMATION);
  593.                   return (MRESULT) NULL;
  594.                case IDM_DOTHIS:
  595.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do This", "Cyan", 0, MB_OK | MB_ICONEXCLAMATION);
  596.                   return (MRESULT) NULL;
  597.                case IDM_DOTHAT:
  598.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do That", "Cyan", 0, MB_OK | MB_ICONEXCLAMATION);
  599.                   return (MRESULT) NULL;
  600.                case IDM_DOTHEOTHER:
  601.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "Cyan", 0, MB_OK | MB_ICONEXCLAMATION);
  602.                   return (MRESULT) NULL;
  603.               }
  604.             break;
  605.  
  606.       // Paint window
  607.  
  608.          case WM_PAINT:
  609.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  610.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  611.             WinQueryWindowRect (hwndDocument, &rcl);
  612.             WinFillRect (hps, &rcl, clr);
  613.             WinEndPaint (hps);
  614.             return (MRESULT) NULL;
  615.         }
  616.  
  617.    // Allow MDI to process all other messages
  618.  
  619.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  620.  
  621.      }
  622.  
  623.  
  624. // Function: YellowWndProc -- "Yellow" Document Window Procedure
  625. // -------------------------------------------------------------
  626.    MRESULT EXPENTRY YellowWndProc (hwndDocument, msg, mp1, mp2)
  627.  
  628.       HWND hwndDocument;               // Document window
  629.       USHORT msg;                      // PM message
  630.       MPARAM mp1;                      // Mesage parameter 1
  631.       MPARAM mp2;                      // Mesage parameter 2
  632.  
  633.    // Define function data
  634.  
  635.      {HPS hps;
  636.       RECTL rcl;
  637.       COLOR clr;
  638.  
  639.    // Process PM messages
  640.  
  641.       switch (msg)
  642.  
  643.       // Process commands
  644.  
  645.         {case WM_COMMAND:
  646.             switch (LOUSHORT (mp1))
  647.               {case IDM_FOO:
  648.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo", "Yellow", 0, MB_OK | MB_ICONEXCLAMATION);
  649.                   return (MRESULT) NULL;
  650.                case IDM_BAR:
  651.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Bar", "Yellow", 0, MB_OK | MB_ICONEXCLAMATION);
  652.                   return (MRESULT) NULL;
  653.                case IDM_FOOBAR:
  654.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Foo Bar", "Yellow", 0, MB_OK | MB_ICONEXCLAMATION);
  655.                   return (MRESULT) NULL;
  656.                case IDM_DOTHIS:
  657.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do This", "Yellow", 0, MB_OK | MB_ICONEXCLAMATION);
  658.                   return (MRESULT) NULL;
  659.                case IDM_DOTHAT:
  660.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do That", "Yellow", 0, MB_OK | MB_ICONEXCLAMATION);
  661.                   return (MRESULT) NULL;
  662.                case IDM_DOTHEOTHER:
  663.                   WinMessageBox (HWND_DESKTOP, hwndDocument, "Do the Other", "Yellow", 0, MB_OK | MB_ICONEXCLAMATION);
  664.                   return (MRESULT) NULL;
  665.               }
  666.             break;
  667.  
  668.       // Paint window
  669.  
  670.          case WM_PAINT:
  671.             hps = WinBeginPaint (hwndDocument, (HPS) NULL, (PRECTL) NULL);
  672.             clr = WinQueryWindowULong (hwndDocument, QWL_USER);
  673.             WinQueryWindowRect (hwndDocument, &rcl);
  674.             WinFillRect (hps, &rcl, clr);
  675.             WinEndPaint (hps);
  676.             return (MRESULT) NULL;
  677.         }
  678.  
  679.    // Allow MDI to process all other messages
  680.  
  681.       return MDIDocumentWndProc (hwndDocument, msg, mp1, mp2) ;
  682.  
  683.      }
  684.