home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / STYLE.ZIP / STY_EDIT.C < prev    next >
C/C++ Source or Header  |  1992-03-30  |  6KB  |  197 lines

  1. /*************************************************************************
  2. *
  3. *  File Name   : STY_EDIT.C
  4. *
  5. *  Description : This module contains the code for the WM_COMMAND
  6. *                messages posted by the standard edit menu.
  7. *
  8. *  Concepts    : Demonstrates the cut, paste, copy, undo, and
  9. *                clear features of an MLE control.
  10. *
  11. *  API's       : WinSendMsg
  12. *
  13. *  Copyright (C) 1992 IBM Corporation
  14. *
  15. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  16. *      sample code created by IBM Corporation. This sample code is not
  17. *      part of any standard or IBM product and is provided to you solely
  18. *      for  the purpose of assisting you in the development of your
  19. *      applications.  The code is provided "AS IS", without
  20. *      warranty of any kind.  IBM shall not be liable for any damages
  21. *      arising out of your use of the sample code, even if they have been
  22. *      advised of the possibility of such damages.                                                    *
  23. *
  24. ************************************************************************/
  25.  
  26. /*  Include files, macros, defined constants, and externs               */
  27.  
  28. #define INCL_WINMLE
  29.  
  30. #include <os2.h>
  31. #include "sty_main.h"
  32. #include "sty_xtrn.h"
  33.  
  34. extern LONG lClrForeground;                         /* color for window text */
  35. extern LONG lClrBackground;                          /* color for background */
  36.  
  37. /*********************************************************************
  38.  *  Name: EditUndo
  39.  *
  40.  *  Description : Processes the Edit menu's Undo item.
  41.  *
  42.  *  Concepts : Called whenever Undo from the Edit menu is selected
  43.  *             Sends a MLM_UNDO message to the MLE control.
  44.  *
  45.  *  API's : WinSendMsg
  46.  *
  47.  *  Parameters : mp2 - Message parameter
  48.  *
  49.  *  Returns: Void
  50.  *
  51.  ****************************************************************/
  52. VOID EditUndo(MPARAM mp2)
  53. {
  54.  ULONG undoFlag;
  55.   /*
  56.    *   Tell MLE to undo last operation
  57.    */
  58.    if(!WinSendMsg(hwndMLE, MLM_UNDO, NULL, NULL))
  59.         MessageBox(hwndMLE, IDMSG_UNDOFAILED, MB_OK | MB_ERROR, FALSE);
  60.  
  61.   /*
  62.    *   Get the MLE's colors in case he just changed them back
  63.    *   We're just using the hi-ushort (operation) regardless of the
  64.    *   value of the lo-ushort (boolean) undo-redo flag.
  65.    */
  66.    undoFlag=(ULONG)WinSendMsg(hwndMLE, MLM_QUERYUNDO, NULL, NULL) ;
  67.    if (undoFlag)
  68.    {
  69.       switch (HIUSHORT(undoFlag))
  70.       {
  71.          case MLM_SETTEXTCOLOR:
  72.          case MLM_SETBACKCOLOR:
  73.             lClrForeground =
  74.                (ULONG)WinSendMsg(hwndMLE,MLM_QUERYTEXTCOLOR, NULL, NULL);
  75.             lClrBackground =
  76.                (ULONG)WinSendMsg(hwndMLE,MLM_QUERYBACKCOLOR, NULL, NULL);
  77.             WinInvalidateRect(hwndMLE, NULL, TRUE);
  78.             break;
  79.          default:
  80.             break;
  81.       }    /* endswitch HIUSHORT(undoFlag) */
  82.  
  83.    } /* end if (UndoFlag) */
  84.  
  85.   /*
  86.    * This routine currently doesn't use the mp2 parameter but
  87.    * it is referenced here to prevent an 'Unreferenced Parameter'
  88.    * warning at compile time.
  89.    */
  90.    mp2;
  91.  
  92. }   /*  End of EditUndo()                                               */
  93.  
  94. /*********************************************************************
  95.  *  Name: EditCut
  96.  *
  97.  *  Description : Processes the Edit menu's Cut item.
  98.  *
  99.  *  Concepts : Called whenever Cut from the Edit menu is selected
  100.  *             Sends a MLM_CUT message to the MLE control.
  101.  *
  102.  *  API's : WinSendMsg
  103.  *
  104.  *  Parameters : mp2 - Message parameter
  105.  *
  106.  *  Returns: Void
  107.  *
  108.  ****************************************************************/
  109. VOID EditCut(MPARAM mp2)
  110. {
  111.    WinSendMsg(hwndMLE, MLM_CUT, NULL, NULL);
  112.  /*
  113.   * This routine currently doesn't use the mp2 parameter but
  114.   * it is referenced here to prevent an 'Unreferenced Parameter'
  115.   * warning at compile time.
  116.   */
  117.    mp2;
  118. }   /*  End of EditCut()                                                */
  119.  
  120. /*********************************************************************
  121.  *  Name: EditCopy
  122.  *
  123.  *  Description : Processes the Edit menu's Copy item.
  124.  *
  125.  *  Concepts : Called whenever Copy from the Edit menu is selected
  126.  *             Sends a MLM_COPY message to the MLE control.
  127.  *
  128.  *  API's : WinSendMsg
  129.  *
  130.  *  Parameters : mp2 - Message parameter
  131.  *
  132.  *  Returns: Void
  133.  *
  134.  ****************************************************************/
  135. VOID EditCopy(MPARAM mp2)
  136. {
  137.    WinSendMsg(hwndMLE, MLM_COPY, NULL, NULL);
  138.  /*
  139.   * This routine currently doesn't use the mp2 parameter but
  140.   * it is referenced here to prevent an 'Unreferenced Parameter'
  141.   * warning at compile time.
  142.   */
  143.    mp2;
  144. }   /*   End of EditCopy()                                              */
  145.  
  146. /*********************************************************************
  147.  *  Name: EditPaste
  148.  *
  149.  *  Description : Processes the Edit menu's Paste item.
  150.  *
  151.  *  Concepts : Called whenever Paste from the Edit menu is selected
  152.  *             Sends a MLM_PASTE message to the MLE control.
  153.  *
  154.  *  API's : WinSendMsg
  155.  *
  156.  *  Parameters : mp2 - Message parameter
  157.  *
  158.  *  Returns: Void
  159.  *
  160.  ****************************************************************/
  161. VOID EditPaste(MPARAM mp2)
  162. {
  163.    WinSendMsg(hwndMLE, MLM_PASTE, NULL, NULL);
  164.  /*
  165.   * This routine currently doesn't use the mp2 parameter but
  166.   * it is referenced here to prevent an 'Unreferenced Parameter'
  167.   * warning at compile time.
  168.   */
  169.    mp2;
  170. }   /* End of EditPaste()                                               */
  171.  
  172. /*********************************************************************
  173.  *  Name: EditClear
  174.  *
  175.  *  Description : Processes the Edit menu's Clear item.
  176.  *
  177.  *  Concepts : Called whenever Clear from the Edit menu is selected
  178.  *             Sends a MLM_CLEAR message to the MLE control.
  179.  *
  180.  *  API's : WinSendMsg
  181.  *
  182.  *  Parameters : mp2 - Message parameter
  183.  *
  184.  *  Returns: Void
  185.  *
  186.  ****************************************************************/
  187. VOID EditClear(MPARAM mp2)
  188. {
  189.    WinSendMsg(hwndMLE, MLM_CLEAR, NULL, NULL);
  190.  /*
  191.   * This routine currently doesn't use the mp2 parameter but
  192.   * it is referenced here to prevent an 'Unreferenced Parameter'
  193.   * warning at compile time.
  194.   */
  195.    mp2;
  196. }   /* End of EditClear()                                               */
  197.