home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wpobj.zip / TESTAPP.C < prev    next >
C/C++ Source or Header  |  1993-10-28  |  4KB  |  142 lines

  1. /**************************************************************************\
  2.  * NAME: TESTAPP.C
  3.  *
  4.  * DESCRIPTION:
  5.  *     Test application that illustrates the use of the color sample control.
  6. \***************************************************************************/
  7.  
  8. #define INCL_WINWINDOWMGR
  9. #define INCL_WINMESSAGEMGR
  10. #define INCL_WINFRAMEMGR
  11. #define INCL_WINPROGRAMLIST
  12. #define INCL_WINSHELLDATA
  13. #define INCL_WININPUT
  14. #define INCL_WINSYS
  15. #define INCL_WINWORKPLACE
  16. #define INCL_WPCLASS
  17. #define INCL_WPFOLDER
  18. #define INCL_WIN
  19. #define INCL_GPI
  20. #define INCL_DOS
  21. #define    INCL_DOSEXCEPTIONS
  22. #define INCL_DOSEXCEPTIONS
  23. #define M_I86L
  24.  
  25. #include <stdio.h>
  26. #include <string.h>
  27. #include <os2.h>
  28. #include "clrsampl.h"
  29. #include "testapp.h"
  30.  
  31. /*----------------------------------------------------------------*/
  32. /* Function: main                                                 */
  33. /*                                                                */
  34. /* Description:                                                   */
  35. /*   Main line of program                                         */
  36. /*----------------------------------------------------------------*/
  37. int main(
  38.     int     argc,
  39.     char     *argv[] )
  40. {
  41.     HAB                hab;
  42.     HMQ                hmq;
  43.     QMSG               qmsg;
  44.  
  45.     DosBeep(100,100);
  46.     hab = WinInitialize( 0 );
  47.     hmq = WinCreateMsgQueue( hab, 0 );
  48.  
  49.     /* Register the color sample control class
  50.      */
  51.     RegisterColorSampleClass();
  52.     
  53.     /* Show our main dialog box...
  54.      */
  55.     if (hab && hmq)
  56.         WinDlgBox(HWND_DESKTOP,
  57.                   HWND_DESKTOP,
  58.                   TestAppDlgProc,
  59.                   NULLHANDLE,
  60.                   SAMPLE_DIALOG,
  61.                   NULL);
  62.  
  63.     /* Cleanup our resources
  64.      */
  65.     WinDestroyMsgQueue(hmq);
  66.     WinTerminate(hab);
  67.     return 0;
  68. }
  69.     
  70. /*----------------------------------------------------------------*/
  71. /* Function: TestAppDlgProc                                       */
  72. /*                                                                */
  73. /* Description:                                                   */
  74. /*   Test application dialog procedure.                           */
  75. /*----------------------------------------------------------------*/
  76. MRESULT EXPENTRY TestAppDlgProc(
  77.     HWND    hwnd,
  78.     ULONG   msg,
  79.     MPARAM  mp1,
  80.     MPARAM  mp2)
  81. {
  82.     MRESULT    mr            = (MRESULT)0;
  83.     USHORT    command;
  84.  
  85.     switch (msg)
  86.     {
  87.         /* Initialize our application dialog
  88.          */
  89.         case WM_INITDLG:
  90.              /* Set the initial colors in our sample controls
  91.              */        
  92.             WinSendDlgItemMsg(hwnd,DID_SAMPLE1,
  93.                               CSM_SETRGBCOLOR,
  94.                               MPFROMLONG(0x00FFFF),
  95.                               0);
  96.             WinSendDlgItemMsg(hwnd,DID_SAMPLE2,
  97.                               CSM_SETRGBCOLOR,
  98.                               MPFROMLONG(0xFFFF00),
  99.                               0);
  100.             break;        
  101.  
  102.         /* Process button pushes from our dialog
  103.          */
  104.         case WM_COMMAND:
  105.             command = SHORT1FROMMP(mp1);
  106.             switch (command)
  107.             {
  108.                 /* Allow DID_OK to go to WinDefDlgProc and dismiss our dialog
  109.                  */
  110.                 case DID_OK:
  111.                     mr    = WinDefDlgProc(hwnd,msg,mp1,mp2);
  112.                     break;
  113.  
  114.                 /* When the user presses the first "Edit color..." pushbutton
  115.                  * we wish to tell color sample 1 to go into editing mode
  116.                  */
  117.                 case DID_EDIT1:
  118.                     WinSendDlgItemMsg(hwnd,DID_SAMPLE1,
  119.                                       CSM_EDITRGBCOLOR,
  120.                                       0,
  121.                                       0);
  122.                     break;
  123.  
  124.                 /* When the user presses the second "Edit color..." pushbutton
  125.                  * we wish to tell color sample 2 to go into editing mode
  126.                  */
  127.                 case DID_EDIT2:
  128.                     WinSendDlgItemMsg(hwnd,DID_SAMPLE2,
  129.                                       CSM_EDITRGBCOLOR,
  130.                                       0,
  131.                                       0);
  132.                     break;
  133.             }
  134.             break;
  135.  
  136.         default:
  137.             mr    = WinDefDlgProc(hwnd,msg,mp1,mp2);
  138.     }
  139.     return mr;
  140. }
  141.  
  142.