home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PRIMAR.ZIP / TEST.C < prev    next >
Text File  |  1991-10-25  |  10KB  |  263 lines

  1.  
  2. /*----------------------------------------------------------------------------*/
  3. /*----------------------------------------------------------------------------*/
  4. /*            Test Environment for the testing of Object X                    */
  5. /* (C) Copyright SES GmbH Berlin, SE Int.,1990,1991. All rights reserved.     */
  6. /*----------------------------------------------------------------------------*/
  7. /*----------------------------------------------------------------------------*/
  8.  
  9. /***********************************/
  10. /* C and PM definitions            */
  11. /***********************************/
  12. #define INCL_WINFRAMEMGR
  13. #define INCL_WINWINDOWMGR
  14. #define INCL_WINATOM
  15. #define INCL_WINDDE 
  16. #define INCL_WINSYS
  17. #define INCL_WINSTDDRAG
  18. #define INCL_DOSMODULEMGR
  19. #define INCL_WINHELP
  20. #include <os2.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23.  
  24. /*---------------------------------*/
  25. /* Interface file for Object DUMMY */
  26. /*---------------------------------*/
  27. #include <dummy.h>
  28.  
  29. /*---------------------------------*/
  30. /* Interface file to SEIDLG2       */
  31. /*---------------------------------*/
  32. #include <seidlg2.h>
  33.  
  34. /*----------------------*/
  35. /* Internal header file */
  36. /*----------------------*/
  37. #include "testi.h"
  38.  
  39. /***************************/
  40. /* PROTOTYPE DEFINITIONS   */
  41. /***************************/
  42.  
  43. MRESULT EXPENTRY WorkplaceWinProc( HWND hwnd, USHORT usMsgID,
  44.                                    MPARAM mp1, MPARAM mp2 );
  45.  
  46.  
  47. HWND cdecl  CreateWorkplace(HAB hAB);
  48.  
  49. MRESULT EXPENTRY DlgWinProc( HWND hwnd, USHORT usMsgID,
  50.                              MPARAM mp1, MPARAM mp2 );
  51.  
  52. /*----------------------------------------------------------------------------*/
  53. /*                                                                            */
  54. /*   PROCEDURE:   main()                                                      */
  55. /*                                                                            */
  56. /*   DESCRIPTION: The main procedure is initiated by the operating            */
  57. /*                system and just calls the initialization routine            */
  58. /*                SEIAPP with the name of the start function and              */
  59. /*                argc and argv (optional).                                   */
  60. /*                                                                            */
  61. /*----------------------------------------------------------------------------*/
  62. void cdecl main(USHORT argc, PSZ argv[])
  63. {
  64.    SeiApp(CreateWorkplace, argc, argv);
  65.    DosExit (EXIT_THREAD, 0);
  66. }
  67.  
  68.  
  69.  
  70. /*============================================================================*/
  71. /*=======================     CreateWorkplace    =============================*/
  72. /*============================================================================*/
  73. HWND cdecl  CreateWorkplace (HAB hAB) {
  74.  
  75. /*--------------------*/
  76. /* Internal variables */
  77. /*--------------------*/
  78. HWND        hFrame, hClient;                       /* Frame and client handle */
  79. BOOL        bResult;
  80. FRAMECDATA  fcdata;
  81. HWND        hwndHelpInstance;
  82.  
  83.    /*----------------------------------------------*/
  84.    /* Now we want to create the frame control data */
  85.    /* to create the frame window                   */
  86.    /*----------------------------------------------*/
  87.    fcdata.cb            = sizeof(FRAMECDATA);
  88.    fcdata.flCreateFlags =  FCF_STANDARD;
  89.    fcdata.hmodResources = NULL;
  90.    fcdata.idResources   = WIN_WORKPLACE;
  91.  
  92.    /*--------------------------*/
  93.    /* Create the frame window  */
  94.    /*--------------------------*/
  95.    hFrame = WinCreateWindow(HWND_DESKTOP,     /* Parent                */
  96.            WC_FRAME,                          /* Window class          */
  97.            "",                                /* No window title       */
  98.            NULL,                              /* No window style       */
  99.            0,0,0,0,                           /* position/size         */
  100.            HWND_DESKTOP,                      /* Owner                 */
  101.            HWND_TOP,                          /* behind                */
  102.            WIN_WORKPLACE,                     /* resource              */
  103.            &fcdata,                           /* frame ctldata         */
  104.            NULL);                             /* No presentation parms */
  105.    if (hFrame == NULL) {
  106.       DosBeep (1000,1000);
  107.       return (NULL);
  108.    }
  109.  
  110.    /*-----------------------------------------------------*/
  111.    /* After the successful creation of the frame window   */
  112.    /* we create the control data structure for the client */
  113.    /* window and register the client window class         */
  114.    /*-----------------------------------------------------*/
  115.    bResult = WinRegisterClass(hAB,
  116.                               "WORKPLACE",
  117.                               WorkplaceWinProc,
  118.                               CS_SIZEREDRAW,
  119.                               sizeof (PVOID));
  120.    if (!bResult){
  121.       DosBeep (1000,500);
  122.       return(0);
  123.    }
  124.  
  125.   /* -------------------------------------*/
  126.   /* Now the client window can be created */
  127.   /* -------------------------------------*/
  128.    hClient = WinCreateWindow(hFrame,        /* Parent window            */
  129.              "WORKPLACE",              /* Window class name        */
  130.              NULL,                          /* Window title             */
  131.              NULL,                          /* window style             */
  132.              0,0,0,0,                       /* position and size        */
  133.              hFrame,                        /* Owner                    */
  134.              HWND_TOP,                      /* Behind                   */
  135.              FID_CLIENT,                    /* window id                */
  136.              NULL,                          /* client control data      */
  137.              NULL);                         /* Presentation parameter   */
  138.   if (hClient == NULL) {
  139.       DosBeep (1000, 100);
  140.       return (0);
  141.   }
  142.  
  143.   /*--------------------------*/
  144.   /* Create the help instance */
  145.   /*--------------------------*/
  146.   hwndHelpInstance = SeiCreateHelpInstance (hFrame,
  147.                                             NULL,
  148.                                             TEST_HELPTABLE,
  149.                                             "Application's Help Title",
  150.                                             "TEST.HLP");
  151.  
  152.   /*---------------------------------------------*/
  153.   /* It is now about time to position and size   */
  154.   /* the frame window. For this we have to       */
  155.   /* calculate the size of the frame based on    */
  156.   /* the size of the client area in the template */
  157.   /*---------------------------------------------*/
  158.   WinSetWindowPos(hFrame,
  159.                   HWND_TOP,
  160.                   20,
  161.                   20,
  162.                   400,
  163.                   400,
  164.                   SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER);
  165.  return (hFrame);
  166.  
  167. }/* end of CreateWorkplace */
  168.  
  169.  
  170.  
  171.  
  172. /*============================================================================*/
  173. /*============================     WorkplaceWinProc    =======================*/
  174. /*============================================================================*/
  175. /*                                                                            */
  176. /*   PROCEDURE:   WorkplaceWinProc (HWND, USHORT, ULONG, ULONG)               */
  177. /*                                                                            */
  178. /*   DESCRIPTION: Window handling procedure for main client window            */
  179. /*                                                                            */
  180. /*   STARTED BY:  main                                                        */
  181. /*                                                                            */
  182. /*----------------------------------------------------------------------------*/
  183. MRESULT EXPENTRY WorkplaceWinProc( HWND hwnd, USHORT usMsgID,
  184.                                    MPARAM mp1, MPARAM mp2 )
  185. {
  186.   /*--------------------*/
  187.   /* Internal variables */
  188.   /*--------------------*/
  189.  
  190.   switch (usMsgID) {
  191.  
  192.     case WM_CREATE: {
  193.     } break;
  194.  
  195.     case WM_ACTIVATE: {
  196.          /*-----------------------------------------------*/
  197.          /* Wheever the window will be activated, it must */
  198.          /* reset or set its help table                   */
  199.          /*-----------------------------------------------*/
  200.          SeiChangeHelpTable (WinQueryWindow (hwnd, QW_PARENT, TRUE),
  201.                              NULL, TEST_HELPTABLE, HELP_LIB,
  202.                              SHORT1FROMMP (mp1));
  203.          } break;
  204.  
  205.     case WM_COMMAND: {
  206.       switch (SHORT1FROMMP(mp1)) {
  207.  
  208.         case MN_FILEOPEN: {
  209.              HWND      hwndDummy;
  210.              /*--------------------------------------*/
  211.              /* Create a primary or secondary window */
  212.              /*--------------------------------------*/
  213.              hwndDummy = CreateDummy (hwnd, "Charly Brown");
  214.         } break;
  215.  
  216.         case MN_FILEEXIT: {
  217.              WinPostMsg (hwnd, WM_QUIT, 0L, 0L);
  218.         } break;
  219.  
  220.         case MN_ABOUT: {
  221.              WinDlgBox (HWND_DESKTOP, hwnd, WinDefDlgProc, NULL,
  222.                         DLG_ABOUT, NULL);
  223.         } break;
  224.  
  225.  
  226.         default: {
  227.         } break;
  228.  
  229.       } /* end WM_COMMAND switch */
  230.  
  231.     } break; /* end of WM_COMMAND */
  232.  
  233.     case WM_PAINT: {
  234.          HPS    hPS;
  235.          RECTL  rect;
  236.       /*------------------------------------------------------------*/
  237.       /* Get a presentation space handle for the window's rectangle */
  238.       /*------------------------------------------------------------*/
  239.       hPS=WinBeginPaint(hwnd,
  240.                         NULL,
  241.                         &rect);
  242.       /*---------------------------------*/
  243.       /* Fill the rectangle with a color */
  244.       /*---------------------------------*/
  245.       WinFillRect(hPS,
  246.                   &rect,
  247.                   SYSCLR_WINDOW);
  248.  
  249.       /*----------------------------------------*/
  250.       /* End painting in the presentation space */
  251.       /*----------------------------------------*/
  252.       WinEndPaint(hPS);
  253.       } break;
  254.  
  255.     default: {
  256.       break;
  257.     }
  258.   } /* end switch */
  259.  
  260.   return((MRESULT)WinDefWindowProc(hwnd, usMsgID, mp1, mp2));
  261.  
  262. }/* end of WinProc */
  263.