home *** CD-ROM | disk | FTP | other *** search
/ CorelDRAW! 10 / cd10_pgrm.iso / Corel / Graphics10 / Draw / Scripts / Misc / shadow.csc < prev   
Encoding:
Text File  |  1997-10-01  |  39.1 KB  |  1,068 lines

  1. REM Applies a drop shadow effect to
  2. REM the currently selected object(s).
  3.  
  4. '********************************************************************
  5. '   Script:    Shadow.csc
  6. '   Copyright 1996 Corel Corporation.  All rights reserved.
  7. '   Description: CorelDRAW script to apply a drop shadow to the
  8. '                currently selected object(s).
  9. '********************************************************************
  10.  
  11. #addfol  "..\..\..\Scripts"
  12. #include "ScpConst.csi"
  13. #include "DrwConst.csi"
  14.  
  15. '/////FUNCTION & SUBROUTINE DECLARATIONS/////////////////////////////
  16. DECLARE FUNCTION AnythingChanged() AS BOOLEAN
  17. DECLARE FUNCTION ValidateInput() AS BOOLEAN
  18. DECLARE FUNCTION CheckForSelection() AS BOOLEAN
  19. DECLARE FUNCTION RemoveObject( InCDRStaticID AS LONG ) AS BOOLEAN
  20. DECLARE SUB WarnUser()
  21. DECLARE SUB WarnUserComplete()
  22. DECLARE FUNCTION ApplyEffect( InID AS LONG, \\
  23.                               InRed AS INTEGER, \\
  24.                               InGreen AS INTEGER, \\
  25.                               InBlue AS INTEGER, \\
  26.                               InMakeTransparent AS BOOLEAN, \\
  27.                               InPercent AS INTEGER, \\
  28.                               InHorizOffset AS LONG, \\
  29.                               InVertOffset AS LONG, \\
  30.                               InHorizUnit AS INTEGER, \\
  31.                               InVertUnit AS INTEGER) AS LONG
  32. DECLARE FUNCTION StillThere( InCDRStaticID AS LONG ) AS BOOLEAN
  33.  
  34. '/////GLOBAL VARIABLES & CONSTANTS///////////////////////////////////
  35. GLOBAL CONST TITLE_ERRORBOX$      = "Drop Shadow Maker Error"
  36. GLOBAL CONST TITLE_INFOBOX$       = "Drop Shadow Maker Information"
  37. GLOBAL NL AS STRING         ' These must be declared as 
  38. GLOBAL NL2 AS STRING     ' variables, not constants, because
  39. NL$ = CHR(10) + CHR(13)    ' we cannot assign expressions
  40. NL2$ = NL + NL             ' to constants.
  41.  
  42. ' Constants for dialog return values.
  43. GLOBAL CONST DIALOG_RETURN_OK%     = 1
  44. GLOBAL CONST DIALOG_RETURN_CANCEL% = 2
  45.  
  46. ' The CDRStaticID of the selected object(s).
  47. GLOBAL IDOriginal AS LONG
  48.  
  49. ' The CDRStaticID of the duplicated object.
  50. GLOBAL IDDuplicate AS LONG
  51.  
  52. '/////CHECK FOR CORELDRAW/////////////////////////////////////////////
  53. ON ERROR GOTO ErrorNoDrawHandler
  54. WITHOBJECT OBJECT_DRAW    ' This will raise an error if Draw is not installed
  55.                     ' or not available because of an OLE problem.
  56. ON ERROR EXIT
  57.  
  58. '/////PARAMETERS DIALOG//////////////////////////////////////////////
  59.  
  60. ' The array of possible units the user may select from.
  61. GLOBAL UnitsArray(6) AS STRING
  62. UnitsArray(1) = "1 in."
  63. UnitsArray(2) = "1/36 in."
  64. UnitsArray(3) = "0.001 in."
  65. UnitsArray(4) = "1 cm."
  66. UnitsArray(5) = "0.001 cm."
  67. UnitsArray(6) = "1 pt."
  68.  
  69. ' Default constants for this dialog.
  70. GLOBAL CONST HorizDefaultOffset& = 60
  71. GLOBAL CONST HorizDefaultUnit& = 3
  72. GLOBAL CONST VertDefaultOffset& = -60
  73. GLOBAL CONST VertDefaultUnit& = 3
  74. GLOBAL CONST PercentDefault& = 50
  75. GLOBAL CONST RedDefault% = 0
  76. GLOBAL CONST GreenDefault% = 0
  77. GLOBAL CONST BlueDefault% = 0
  78. GLOBAL CONST Proportion& = 500000   ' Used for setting the default
  79.                              ' offset values.
  80.  
  81. ' Variables needed for this dialog.
  82. GLOBAL Red AS INTEGER    ' The selected color's red component.
  83. GLOBAL Green AS INTEGER    ' The selected color's green component.
  84. GLOBAL Blue AS INTEGER    ' The selected color's blue component.
  85. GLOBAL FirstTime AS BOOLEAN ' Whether the user has applied
  86.                     ' anything yet.
  87.  
  88. ' Variables needed to store the old values.
  89. GLOBAL OldRed AS INTEGER
  90. GLOBAL OldGreen AS INTEGER
  91. GLOBAL OldBlue AS INTEGER
  92. GLOBAL OldShadowCheck AS BOOLEAN
  93. GLOBAL OldPercent AS LONG
  94. GLOBAL OldHorizOffset AS LONG
  95. GLOBAL OldVertOffset AS LONG
  96. GLOBAL OldHorizUnit AS INTEGER
  97. GLOBAL OldVertUnit AS INTEGER
  98.  
  99. ' Set up the defaults.
  100. Red% = RedDefault%
  101. Green% = GreenDefault%
  102. Blue% = BlueDefault%
  103. FirstTime = TRUE
  104.  
  105. BEGIN DIALOG OBJECT ParamDialog 283, 179, "Drop Shadow Maker", SUB ParamDialogEventHandler
  106.     GROUPBOX  13, 109, 185, 61, .GroupBox1, "Special effects"
  107.     TEXT  12, 4, 271, 10, .Text1, "This tool automatically creates a drop shadow for the currently selected object."
  108.     GROUPBOX  13, 20, 256, 81, .GroupBox2, "Shadow location"
  109.     TEXT  24, 46, 65, 13, .Text2, "Horizontal"
  110.     TEXT  24, 64, 27, 8, .Text3, "Vertical"
  111.     SPINCONTROL  61, 45, 40, 12, .HorizSpin
  112.     DDLISTBOX  114, 45, 54, 197, .HorizListBox
  113.     SPINCONTROL  61, 63, 40, 12, .VertSpin
  114.     DDLISTBOX  114, 63, 54, 178, .VertListBox
  115.     TEXT  105, 46, 6, 11, .Text4, "x"
  116.     TEXT  105, 64, 6, 11, .Text5, "x"
  117.     CHECKBOX  25, 123, 58, 18, .ShadowCheck, "Make shadow "
  118.     SPINCONTROL  86, 126, 35, 12, .PercentSpin
  119.     TEXT  124, 127, 67, 12, .Text7, "percent transparent"
  120.     PUSHBUTTON  60, 147, 87, 13, .ShadowButton, "Choose shadow color"
  121.     PUSHBUTTON  214, 114, 50, 13, .ApplyButton, "&Apply"
  122.     PUSHBUTTON  214, 135, 50, 13, .OkButton, "&Ok"
  123.     PUSHBUTTON  214, 156, 50, 13, .CancelButton, "&Cancel"
  124.     PUSHBUTTON  182, 51, 25, 19, .LeftButton, "Left"
  125.     PUSHBUTTON  207, 32, 25, 19, .UpButton, "Up"
  126.     PUSHBUTTON  232, 51, 25, 19, .RightButton, "Right"
  127.     PUSHBUTTON  207, 70, 25, 19, .DownButton, "Down"
  128. END DIALOG
  129.  
  130. SUB ParamDialogEventHandler(BYVAL ControlID%, BYVAL Event%)
  131.  
  132.     DIM MsgReturn AS LONG
  133.  
  134.     IF Event% = EVENT_INITIALIZATION THEN
  135.         ' Set dialog defaults.
  136.         ParamDialog.HorizListBox.SetArray UnitsArray$
  137.         ParamDialog.VertListBox.SetArray UnitsArray$
  138.         ParamDialog.HorizListBox.SetSelect HorizDefaultUnit&
  139.         ParamDialog.VertListBox.SetSelect VertDefaultUnit&
  140.         ParamDialog.PercentSpin.SetValue PercentDefault&
  141.         ParamDialog.ShadowCheck.SetThreeState FALSE
  142.         ParamDialog.ShadowCheck.SetValue FALSE
  143.         ParamDialog.PercentSpin.Enable FALSE
  144.         
  145.         ' To set the offset defaults, use the size of the
  146.         ' selected object.
  147.         DIM XSize AS LONG
  148.         DIM YSize AS LONG
  149.         
  150.         .GetSize XSize&, YSize&
  151.         ParamDialog.HorizSpin.SetValue CLNG((XSize& * HorizDefaultOffset&) / Proportion&)
  152.         ParamDialog.VertSpin.SetValue CLNG((YSize& * VertDefaultOffset&) / Proportion&)
  153.         
  154.     ELSEIF Event% = EVENT_MOUSE_CLICK THEN     
  155.         SELECT CASE ControlID%
  156.             CASE ParamDialog.UpButton.GetID()
  157.                 ParamDialog.VertSpin.SetValue \\
  158.                        ParamDialog.VertSpin.GetValue() + 1
  159.                 IF (ParamDialog.VertSpin.GetValue() < -999) THEN
  160.                        MsgReturn& = MESSAGEBOX("Please enter a vertical offset " + \\
  161.                                                    "value between -999 and 999.", \\
  162.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  163.                     ParamDialog.VertSpin.SetValue -999
  164.                 ELSEIF (ParamDialog.VertSpin.GetValue() > 999) THEN
  165.                        MsgReturn& = MESSAGEBOX("Please enter a vertical offset " + \\
  166.                                                    "value between -999 and 999.", \\
  167.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  168.                     ParamDialog.VertSpin.SetValue 999
  169.                 ENDIF
  170.  
  171.             CASE ParamDialog.DownButton.GetID()
  172.                 ParamDialog.VertSpin.SetValue \\
  173.                    ParamDialog.VertSpin.GetValue() - 1
  174.                 IF (ParamDialog.VertSpin.GetValue() < -999) THEN
  175.                        MsgReturn& = MESSAGEBOX("Please enter a vertical offset " + \\
  176.                                                    "value between -999 and 999.", \\
  177.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  178.                     ParamDialog.VertSpin.SetValue -999
  179.                 ELSEIF (ParamDialog.VertSpin.GetValue() > 999) THEN
  180.                        MsgReturn& = MESSAGEBOX("Please enter a vertical offset " + \\
  181.                                                    "value between -999 and 999.", \\
  182.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  183.                     ParamDialog.VertSpin.SetValue 999
  184.                 ENDIF
  185.                 
  186.             CASE ParamDialog.LeftButton.GetID()
  187.                 ParamDialog.HorizSpin.SetValue \\
  188.                    ParamDialog.HorizSpin.GetValue() - 1
  189.                 IF (ParamDialog.HorizSpin.GetValue() < -999) THEN
  190.                        MsgReturn& = MESSAGEBOX("Please enter a horizontal offset " + \\
  191.                                                    "value between -999 and 999.", \\
  192.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  193.                     ParamDialog.HorizSpin.SetValue -999
  194.                 ELSEIF (ParamDialog.HorizSpin.GetValue() > 999) THEN
  195.                        MsgReturn& = MESSAGEBOX("Please enter a horizontal offset " + \\
  196.                                                    "value between -999 and 999.", \\
  197.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  198.                     ParamDialog.HorizSpin.SetValue 999
  199.                 ENDIF
  200.                 
  201.             CASE ParamDialog.RightButton.GetID()
  202.                 ParamDialog.HorizSpin.SetValue \\
  203.                    ParamDialog.HorizSpin.GetValue() + 1
  204.                 IF (ParamDialog.HorizSpin.GetValue() < -999) THEN
  205.                        MsgReturn& = MESSAGEBOX("Please enter a horizontal offset " + \\
  206.                                                    "value between -999 and 999.", \\
  207.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  208.                     ParamDialog.HorizSpin.SetValue -999
  209.                 ELSEIF (ParamDialog.HorizSpin.GetValue() > 999) THEN
  210.                        MsgReturn& = MESSAGEBOX("Please enter a horizontal offset " + \\
  211.                                                    "value between -999 and 999.", \\
  212.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  213.                     ParamDialog.HorizSpin.SetValue 999
  214.                 ENDIF
  215.  
  216.             CASE ParamDialog.ShadowCheck.GetID()
  217.                 IF ParamDialog.ShadowCheck.GetValue() THEN
  218.                     ParamDialog.PercentSpin.Enable TRUE
  219.                 ELSE
  220.                     ParamDialog.PercentSpin.Enable FALSE
  221.                 ENDIF    
  222.             CASE ParamDialog.ShadowButton.GetID()
  223.                 GETCOLOR Red%, Green%, Blue%
  224.             CASE ParamDialog.ApplyButton.GetID()
  225.                 IF ValidateInput() THEN
  226.                     IF FirstTime THEN
  227.                         FirstTime = FALSE
  228.                         IDDuplicate& = ApplyEffect( IDOriginal&, \\
  229.                                                           Red%, \\
  230.                                                           Green%, \\
  231.                                                           Blue%, \\
  232.                                                           CBOL(ParamDialog.ShadowCheck.GetValue()), \\
  233.                                                           CINT(ParamDialog.PercentSpin.GetValue()), \\
  234.                                                           CLNG(ParamDialog.HorizSpin.GetValue()), \\
  235.                                                           CLNG(ParamDialog.VertSpin.GetValue()), \\
  236.                                                           CINT(ParamDialog.HorizListBox.GetSelect()), \\
  237.                                                           CINT(ParamDialog.VertListBox.GetSelect()) )
  238.                     ELSE ' We will always perform an apply when
  239.                         ' the apply button is hit.  This
  240.                         ' is more reassuring for the user
  241.                         ' than not doing anything if nothing
  242.                         ' changed (though less efficient).
  243.                         ' For efficiency, use:
  244.                         '   ELSEIF AnythingChanged() THEN
  245.                         IF (NOT StillThere(IDOriginal&)) THEN
  246.                             WarnUserComplete
  247.                             STOP
  248.                         ENDIF
  249.                         IF NOT StillThere(IDDuplicate&) THEN
  250.                             WarnUser
  251.                         ELSEIF NOT RemoveObject(IDDuplicate&) THEN
  252.                             WarnUser
  253.                         ENDIF
  254.                         IDDuplicate& = ApplyEffect( IDOriginal&, \\
  255.                                                           Red%, \\
  256.                                                           Green%, \\
  257.                                                           Blue%, \\
  258.                                                           CBOL(ParamDialog.ShadowCheck.GetValue()), \\
  259.                                                           CINT(ParamDialog.PercentSpin.GetValue()), \\
  260.                                                           CLNG(ParamDialog.HorizSpin.GetValue()), \\
  261.                                                           CLNG(ParamDialog.VertSpin.GetValue()), \\
  262.                                                           CINT(ParamDialog.HorizListBox.GetSelect()), \\
  263.                                                           CINT(ParamDialog.VertListBox.GetSelect()) )
  264.                     ENDIF
  265.                 ENDIF
  266.             CASE ParamDialog.OkButton.GetID()
  267.                 IF ValidateInput() THEN
  268.                     IF FirstTime THEN
  269.                         FirstTime = FALSE
  270.                         IDDuplicate& = ApplyEffect( IDOriginal&, \\
  271.                                                           Red%, \\
  272.                                                           Green%, \\
  273.                                                           Blue%, \\
  274.                                                           CBOL(ParamDialog.ShadowCheck.GetValue()), \\
  275.                                                           CINT(ParamDialog.PercentSpin.GetValue()), \\
  276.                                                           CLNG(ParamDialog.HorizSpin.GetValue()), \\
  277.                                                           CLNG(ParamDialog.VertSpin.GetValue()), \\
  278.                                                           CINT(ParamDialog.HorizListBox.GetSelect()), \\
  279.                                                           CINT(ParamDialog.VertListBox.GetSelect()) )
  280.                     ELSEIF AnythingChanged() THEN
  281.                         IF (NOT StillThere(IDOriginal&)) THEN
  282.                             WarnUserComplete
  283.                             STOP
  284.                         ENDIF
  285.                         IF NOT StillThere(IDDuplicate&) THEN
  286.                             WarnUser                        
  287.                         ELSEIF NOT RemoveObject(IDDuplicate&) THEN
  288.                             WarnUser
  289.                         ENDIF
  290.                         IDDuplicate& = ApplyEffect( IDOriginal&, \\
  291.                                                           Red%, \\
  292.                                                           Green%, \\
  293.                                                           Blue%, \\
  294.                                                           CBOL(ParamDialog.ShadowCheck.GetValue()), \\
  295.                                                           CINT(ParamDialog.PercentSpin.GetValue()), \\
  296.                                                           CLNG(ParamDialog.HorizSpin.GetValue()), \\
  297.                                                           CLNG(ParamDialog.VertSpin.GetValue()), \\
  298.                                                           CINT(ParamDialog.HorizListBox.GetSelect()), \\
  299.                                                           CINT(ParamDialog.VertListBox.GetSelect()) )
  300.                     ENDIF
  301.                     ParamDialog.CloseDialog DIALOG_RETURN_OK%
  302.                 ENDIF
  303.             CASE ParamDialog.CancelButton.GetID()
  304.                 IF NOT FirstTime THEN
  305.                     IF (NOT StillThere(IDOriginal&)) THEN
  306.                         WarnUserComplete
  307.                         STOP
  308.                     ENDIF
  309.                     IF NOT StillThere(IDDuplicate&) THEN
  310.                         WarnUser
  311.                     ELSEIF NOT RemoveObject(IDDuplicate&) THEN
  312.                         WarnUser
  313.                     ENDIF
  314.                 ENDIF
  315.                 ParamDialog.CloseDialog DIALOG_RETURN_CANCEL%
  316.         END SELECT
  317.         
  318.     ELSEIF Event% = EVENT_CHANGE_IN_CONTENT THEN     
  319.         SELECT CASE ControlID%
  320.             CASE ParamDialog.PercentSpin.GetID()
  321.                 ' Do not let the user choose values less than 0 or
  322.                 ' more than 100.
  323.                 IF ParamDialog.PercentSpin.GetValue() < 0 THEN
  324.                        MsgReturn& = MESSAGEBOX("Please enter a percentage " + \\
  325.                                                    "between 0 and 100.", \\
  326.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  327.                     ParamDialog.PercentSpin.SetValue 0
  328.                 ELSEIF ParamDialog.PercentSpin.GetValue() > 100 THEN
  329.                        MsgReturn& = MESSAGEBOX("Please enter a percentage " + \\
  330.                                                    "between 0 and 100.", \\
  331.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  332.                     ParamDialog.PercentSpin.SetValue 100
  333.                 ENDIF
  334.                 
  335.             CASE ParamDialog.HorizSpin.GetID()
  336.                 IF (ParamDialog.HorizSpin.GetValue() < -999) THEN
  337.                        MsgReturn& = MESSAGEBOX("Please enter a horizontal offset " + \\
  338.                                                    "value between -999 and 999.", \\
  339.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  340.                     ParamDialog.HorizSpin.SetValue -999
  341.                 ELSEIF (ParamDialog.HorizSpin.GetValue() > 999) THEN
  342.                        MsgReturn& = MESSAGEBOX("Please enter a horizontal offset " + \\
  343.                                                    "value between -999 and 999.", \\
  344.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  345.                     ParamDialog.HorizSpin.SetValue 999
  346.                 ENDIF
  347.             
  348.             CASE ParamDialog.VertSpin.GetID()
  349.                 IF (ParamDialog.VertSpin.GetValue() < -999) THEN
  350.                        MsgReturn& = MESSAGEBOX("Please enter a vertical offset " + \\
  351.                                                    "value between -999 and 999.", \\
  352.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  353.                     ParamDialog.VertSpin.SetValue -999
  354.                 ELSEIF (ParamDialog.VertSpin.GetValue() > 999) THEN
  355.                        MsgReturn& = MESSAGEBOX("Please enter a vertical offset " + \\
  356.                                                    "value between -999 and 999.", \\
  357.                                                  TITLE_INFOBOX$, MB_INFORMATION_ICON&)
  358.                     ParamDialog.VertSpin.SetValue 999
  359.                 ENDIF
  360.             
  361.         END SELECT
  362.     
  363.     ENDIF
  364.  
  365. END SUB
  366.  
  367. '********************************************************************
  368. '
  369. '    Name:    AnythingChanged (dialog function)
  370. '
  371. '    Action:    Checks whether the user has changed any options
  372. '              since the last time a drop shadow was applied.
  373. '              If any options have indeed changed, update
  374. '              the bank of Old* variables.
  375. '
  376. '    Params:    None.  As this is intended to be a dialog function,
  377. '              it makes use of all variables global to ParamDialog.
  378. '
  379. '    Returns:    None.
  380. '
  381. '    Comments: None.
  382. '
  383. '********************************************************************
  384. FUNCTION AnythingChanged() AS BOOLEAN
  385.  
  386.     DIM AnyDifference AS BOOLEAN ' Any difference detected so far?
  387.  
  388.     ' Perform a quick check for debugging purposes.
  389.     IF FirstTime THEN
  390.         MESSAGE "Invalid calling context"
  391.     ENDIF
  392.  
  393.     ' Compare current dialog settings to previous ones.
  394.     IF OldRed% <> Red% THEN
  395.         AnyDifference = TRUE
  396.         OldRed% = Red%
  397.     ENDIF
  398.     IF OldGreen% <> Green% THEN
  399.         AnyDifference = TRUE
  400.         OldGreen% = Green%
  401.     ENDIF
  402.     IF OldBlue% <> Blue% THEN
  403.         AnyDifference = TRUE
  404.         OldBlue% = Blue%
  405.     ENDIF
  406.     IF OldShadowCheck <> ParamDialog.ShadowCheck.GetValue() THEN
  407.         AnyDifference = TRUE
  408.         OldShadowCheck = ParamDialog.ShadowCheck.GetValue()
  409.     ENDIF
  410.     IF OldPercent& <> ParamDialog.PercentSpin.GetValue() THEN
  411.         AnyDifference = TRUE
  412.         OldPercent& = ParamDialog.PercentSpin.GetValue()
  413.     ENDIF
  414.     IF OldHorizOffset& <> ParamDialog.HorizSpin.GetValue() THEN
  415.         AnyDifference = TRUE
  416.         OldHorizOffset& = ParamDialog.HorizSpin.GetValue()
  417.     ENDIF
  418.     IF OldVertOffset& <> ParamDialog.VertSpin.GetValue() THEN
  419.         AnyDifference = TRUE
  420.         OldVertOffset& = ParamDialog.VertSpin.GetValue()
  421.     ENDIF
  422.     IF OldHorizUnit% <> ParamDialog.HorizListBox.GetSelect() THEN
  423.         AnyDifference = TRUE
  424.         OldHorizUnit% = ParamDialog.HorizListBox.GetSelect()
  425.     ENDIF
  426.     IF OldVertUnit% <> ParamDialog.VertListBox.GetSelect() THEN
  427.         AnyDifference = TRUE
  428.         OldVertUnit% = ParamDialog.VertListBox.GetSelect()
  429.     ENDIF
  430.  
  431.     ' Return TRUE if anything changed.
  432.     AnythingChanged = AnyDifference
  433.  
  434. END FUNCTION
  435.  
  436. '********************************************************************
  437. '
  438. '    Name:    ValidateInput (dialog function)
  439. '
  440. '    Action:    Checks whether all fields in ParamDialog are valid.
  441. '              If one is found to be invalid, displays an error message.
  442. '
  443. '    Params:    None.  As this is intended to be a dialog function,
  444. '              it makes use of all variables global to ParamDialog.
  445. '
  446. '    Returns:    TRUE if all fields are valid.  FALSE otherwise,
  447. '              along with an error message.
  448. '
  449. '    Comments: None.
  450. '
  451. '********************************************************************
  452. FUNCTION ValidateInput() AS BOOLEAN
  453.  
  454.     DIM MsgReturn AS LONG    ' The result of a call to MESSAGEBOX.
  455.     DIM AvailableX AS LONG    ' The width of the page.
  456.     DIM AvailableY AS LONG    ' The height of the page.
  457.     DIM MoveX AS LONG        ' The size of the horizontal offset in Draw units.
  458.     DIM MoveY AS LONG        ' The size of the vertical offset in Draw units.
  459.     DIM HorizUnit AS INTEGER    ' The horizontal unit chosen by the user.
  460.     DIM VertUnit AS INTEGER    ' The vertical unit chosen by the user.
  461.     DIM HorizOffset AS LONG    ' The horizontal offset.
  462.     DIM VertOffset AS LONG    ' The vertical offset.
  463.  
  464.     ' Validate the shadow percentage.
  465.     IF ParamDialog.ShadowCheck.GetValue() THEN
  466.         IF (ParamDialog.PercentSpin.GetValue() < 0) OR \\
  467.              (ParamDialog.PercentSpin.GetValue() > 100) THEN
  468.             
  469.             MsgReturn& = MESSAGEBOX("Please enter a transparency " + \\
  470.                                        "percentage between 0 and 100.", \\
  471.                                        TITLE_ERRORBOX$, \\
  472.                                        MB_OK_ONLY&)
  473.             ValidateInput = FALSE
  474.             EXIT FUNCTION
  475.  
  476.         ENDIF
  477.     ENDIF
  478.  
  479.     ' Validate the offsets.
  480.     .GetPageSize AvailableX&, AvailableY&
  481.     HorizOffset& = ParamDialog.HorizSpin.GetValue()
  482.     VertOffset& = ParamDialog.VertSpin.GetValue()
  483.     HorizUnit% = ParamDialog.HorizListbox.GetSelect()
  484.     VertUnit% = ParamDialog.VertListbox.GetSelect() 
  485.     
  486.     SELECT CASE HorizUnit%
  487.     
  488.         CASE 1 ' 1 in.
  489.             MoveX& = HorizOffset& * 1 *                \\
  490.                     LENGTHCONVERT(LC_INCHES,            \\
  491.                                  LC_TENTHS_OFA_MICRON, \\
  492.                                  1)
  493.         CASE 2 ' 1/36 in.
  494.             MoveX& = HorizOffset& * (1/36) * \\
  495.                     LENGTHCONVERT(LC_INCHES,            \\
  496.                                  LC_TENTHS_OFA_MICRON, \\
  497.                                1)
  498.         CASE 3 ' 0.001 in.
  499.             MoveX& = HorizOffset& * 0.001 *            \\
  500.                     LENGTHCONVERT(LC_INCHES,            \\
  501.                                  LC_TENTHS_OFA_MICRON, \\
  502.                                  1)
  503.         CASE 4 ' 1 cm.
  504.             MoveX& = HorizOffset& * 1 *                \\
  505.                     LENGTHCONVERT(LC_CENTIMETERS,       \\
  506.                                 LC_TENTHS_OFA_MICRON, \\
  507.                                1)
  508.         CASE 5 ' 0.001 cm.
  509.             MoveX& = HorizOffset& * 0.001 *            \\
  510.                     LENGTHCONVERT(LC_CENTIMETERS,       \\
  511.                                LC_TENTHS_OFA_MICRON, \\
  512.                                1)
  513.         CASE 6 ' 1 pt.
  514.             MoveX& = HorizOffset& * 1 *                \\
  515.                     LENGTHCONVERT(LC_POINTS,            \\
  516.                                 LC_TENTHS_OFA_MICRON, \\
  517.                                1)
  518.  
  519.     END SELECT
  520.     SELECT CASE VertUnit%
  521.     
  522.         CASE 1 ' 1 in.
  523.             MoveY& = VertOffset& * 1 *                 \\
  524.                     LENGTHCONVERT(LC_INCHES,            \\
  525.                                  LC_TENTHS_OFA_MICRON, \\
  526.                                  1)
  527.         CASE 2 ' 1/36 in.
  528.             MoveY& = VertOffset& * (1/36) *            \\
  529.                     LENGTHCONVERT(LC_INCHES,            \\
  530.                                  LC_TENTHS_OFA_MICRON, \\
  531.                                1)
  532.         CASE 3 ' 0.001 in.
  533.             MoveY& = VertOffset& * 0.001 *             \\
  534.                     LENGTHCONVERT(LC_INCHES,            \\
  535.                                  LC_TENTHS_OFA_MICRON, \\
  536.                                1)
  537.         CASE 4 ' 1 cm.
  538.             MoveY& = VertOffset& * 1 *                 \\
  539.                     LENGTHCONVERT(LC_CENTIMETERS,       \\
  540.                                LC_TENTHS_OFA_MICRON, \\
  541.                                1)
  542.         CASE 5 ' 0.001 cm.
  543.             MoveY& = VertOffset& * 0.001 *             \\
  544.                     LENGTHCONVERT(LC_CENTIMETERS,       \\
  545.                                 LC_TENTHS_OFA_MICRON, \\
  546.                                1)
  547.         CASE 6 ' 1 pt.
  548.             MoveY& = VertOffset& * 1 *                 \\
  549.                     LENGTHCONVERT(LC_POINTS,            \\
  550.                                 LC_TENTHS_OFA_MICRON, \\
  551.                                1)
  552.  
  553.     END SELECT
  554.     
  555.     ' Complain if the shadow will be very far off the page.
  556.     ' (The legal area works out to be about twice the page size.)
  557.     IF (ABS(MoveX&) > (AvailableX& / 2)) OR (ABS(MoveY&) > (AvailableY& / 2)) THEN
  558.         MsgReturn& = MESSAGEBOX("You will go far off the page with the values you have chosen." + \\
  559.                                 NL2 + "Please choose smaller values for the offsets and try again.", \\
  560.                             TITLE_INFOBOX$, MB_EXCLAMATION_ICON%)
  561.         ValidateInput = FALSE
  562.         EXIT FUNCTION
  563.     ENDIF
  564.     
  565.     ' Return TRUE.
  566.     ValidateInput = TRUE
  567.  
  568. END FUNCTION
  569.  
  570. '********************************************************************
  571. ' MAIN
  572. '
  573. '
  574. '********************************************************************
  575.  
  576. '/////LOCAL VARIABLES////////////////////////////////////////////////
  577. DIM MessageText AS STRING    ' Text to use in a MESSAGEBOX.
  578. DIM GenReturn AS LONG        ' The return value of various routines.
  579. DIM Selection AS BOOLEAN        ' Whether any object is selected in draw.
  580. DIM Valid AS BOOLEAN        ' Whether the user's input was valid.
  581. DIM RememberToUngroup AS BOOLEAN    ' Whether we performed a group.
  582.  
  583. ' Set up a general error handler.
  584. ON ERROR GOTO MainErrorHandler
  585.  
  586. ' Check to see whether anything is selected in DRAW.
  587. IF NOT CheckForSelection() THEN
  588.     MessageText$ = "Please select an object (or several objects) in " + \\
  589.                     "CorelDRAW before running the Drop Shadow Maker." + \\
  590.                     NL2 + "The drop shadow effect will be applied to " + \\
  591.                     "the objects you select."
  592.     GenReturn& = MESSAGEBOX(MessageText$, TITLE_INFOBOX$, \\
  593.                             MB_OK_ONLY& OR MB_INFORMATION_ICON&)
  594.     STOP
  595. ENDIF
  596.  
  597. ' Prepare CorelDRAW for the shadowing operation by grouping
  598. ' the original selection.
  599. ON ERROR RESUME NEXT
  600. IF .GetObjectType() <> DRAW_OBJECT_TYPE_GROUP% THEN
  601.     ERRNUM = 0
  602.     .Group
  603.     RememberToUngroup = TRUE
  604. ELSE
  605.     ERRNUM = 0
  606.     RememberToUngroup = FALSE
  607. ENDIF
  608. ON ERROR GOTO MainErrorHandler
  609. IDOriginal& = .GetObjectsCDRStaticID()
  610.  
  611. ' Interact with the user.
  612. GenReturn& = DIALOG(ParamDialog)
  613.  
  614. ' Select the original object(s) and remove the grouping.
  615. ' If the user has deleted the original object(s), then do not complain.
  616. ON ERROR RESUME NEXT
  617. .SelectObjectOfCDRStaticID IDOriginal&
  618. ERRNUM = 0
  619. IF RememberToUngroup THEN
  620.     IF .GetObjectType() = DRAW_OBJECT_TYPE_GROUP% THEN
  621.         ERRNUM = 0
  622.         .Ungroup
  623.     ENDIF
  624. ENDIF
  625. ERRNUM = 0
  626.  
  627. VeryEnd:
  628.     STOP
  629.  
  630. MainErrorHandler:
  631.     ERRNUM = 0
  632.     MessageText$ = "A general error occurred during the "
  633.     MessageText$ = MessageText$ + "Drop Shadow Maker's processing." + NL2
  634.     MessageText$ = MessageText$ + "You may wish to try again."
  635.     GenReturn& = MESSAGEBOX(MessageText$, TITLE_ERRORBOX$, \\
  636.                             MB_OK_ONLY& OR MB_EXCLAMATION_ICON&)
  637.     RESUME AT VeryEnd
  638.     
  639. ErrorNoDrawHandler:
  640.     ' Failed to create the automation object.
  641.     ERRNUM = 0
  642.     GenReturn = MESSAGEBOX( "Could not find CorelDRAW."+NL2+\\
  643.                         "If this error persists, you "+ \\
  644.                         "may need to re-install "+      \\
  645.                         "CorelDRAW.",                 \\
  646.                            TITLE_ERRORBOX,                 \\
  647.                         MB_OK_ONLY& OR MB_STOP_ICON& )
  648.     RESUME AT VeryEnd
  649.  
  650. '********************************************************************
  651. '
  652. '    Name:    CheckForSelection (function)
  653. '
  654. '    Action:    Checks whether an object is currently selected
  655. '            in CorelDRAW.
  656. '
  657. '    Params:    None.
  658. '
  659. '    Returns:    TRUE if an object is currently selected;  FALSE
  660. '              otherwise.
  661. '
  662. '    Comments:    Never raises any errors. 
  663. '
  664. '********************************************************************
  665. FUNCTION CheckForSelection AS BOOLEAN
  666.  
  667.     DIM ObjType AS LONG     ' The currently selected object type.
  668.  
  669.     ON ERROR GOTO CFSNothingError
  670.         
  671.         ObjType& = .GetObjectType()
  672.         IF (ObjType& <= DRAW_OBJECT_TYPE_RESERVED) THEN
  673.             CheckForSelection = FALSE
  674.         ELSE
  675.             CheckForSelection = TRUE
  676.         ENDIF
  677.  
  678.     ExitPart:
  679.         EXIT FUNCTION
  680.  
  681. CFSNothingError:
  682.     ERRNUM = 0
  683.     CheckForSelection = FALSE
  684.     RESUME AT ExitPart
  685.  
  686. END FUNCTION
  687.  
  688. '********************************************************************
  689. '
  690. '    Name:    RemoveObject (function)
  691. '
  692. '    Action:    Removes a specific object in CorelDRAW given its
  693. '              CDRStaticID.
  694. '
  695. '    Params:    InCDRStaticID -- the ID of the object to remove
  696. '
  697. '    Returns:    If the object is found, deletes it and returns TRUE.
  698. '              Otherwise returns FALSE.
  699. '
  700. '    Comments: None.
  701. '
  702. '********************************************************************
  703. FUNCTION RemoveObject( InCDRStaticID AS LONG ) AS BOOLEAN
  704.     
  705.     ON ERROR GOTO RONotFoundError
  706.  
  707.     .SelectObjectOfCDRStaticID InCDRStaticID&
  708.     .DeleteObject
  709.  
  710.     RemoveObject = TRUE
  711.  
  712.     ExitPart:
  713.         EXIT FUNCTION
  714.  
  715. RONotFoundError:
  716.     ' The given object was not found.
  717.     ERRNUM = 0
  718.     RemoveObject = FALSE
  719.     RESUME AT ExitPart
  720.  
  721. END FUNCTION
  722.  
  723. '********************************************************************
  724. '
  725. '    Name:    StillThere (function)
  726. '
  727. '    Action:    Checks to see if an object still exists in Draw,
  728. '              given its CDRStaticID.
  729. '
  730. '    Params:    InCDRStaticID -- the ID of the object to look for.
  731. '
  732. '    Returns:    If the object is found, returns TRUE.
  733. '              Otherwise returns FALSE.
  734. '
  735. '    Comments: None.
  736. '
  737. '********************************************************************
  738. FUNCTION StillThere( InCDRStaticID AS LONG ) AS BOOLEAN
  739.     
  740.     
  741.     DIM CurSelectedID AS LONG
  742.     
  743.     ON ERROR RESUME NEXT
  744.     CurSelectedID& = .GetObjectsCDRStaticID()
  745.     IF ERRNUM <> 0 THEN
  746.         ERRNUM = 0
  747.         CurSelectedID& = 0
  748.     ENDIF
  749.         
  750.     ON ERROR GOTO STNotFoundError
  751.  
  752.     IF CurSelectedID = InCDRStaticID THEN
  753.         ' The desired object is already selected.
  754.     ELSE
  755.         ' We need to select the object.
  756.         .SelectObjectOfCDRStaticID InCDRStaticID&
  757.         CurSelectedID& = .GetObjectsCDRStaticID()
  758.         IF CurSelectedID& <> InCDRStaticID& THEN
  759.             StillThere = FALSE
  760.             EXIT FUNCTION
  761.         ENDIF
  762.     ENDIF
  763.  
  764.     StillThere = TRUE
  765.  
  766.     STExitPart:
  767.         EXIT FUNCTION
  768.  
  769. STNotFoundError:
  770.     ' The given object was not found.
  771.     ERRNUM = 0
  772.     StillThere = FALSE
  773.     RESUME AT STExitPart
  774.  
  775. END FUNCTION
  776.  
  777. '********************************************************************
  778. '
  779. '    Name:    WarnUser (subroutine)
  780. '
  781. '    Action:    Displays a message box warning the user not to
  782. '              interfere with this program's operation.
  783. '
  784. '    Params:    None.
  785. '
  786. '    Returns:    None.
  787. '
  788. '    Comments: None.
  789. '
  790. '********************************************************************
  791. SUB WarnUser()
  792.  
  793.     DIM MsgReturn AS LONG    ' The return value of MESSAGEBOX.
  794.     MsgReturn& = MESSAGEBOX( "Could not find the last shadow created." \\
  795.                               + NL2 + "Please do not interfere with " \\
  796.                               + "the operation of the Drop Shadow Maker " \\
  797.                               + "by deleting objects it creates."+ NL2 \\
  798.                               + "The Drop Shadow Maker will perform " \\
  799.                               + "all necessary steps on its own.", \\
  800.                               TITLE_INFOBOX$, \\
  801.                               MB_INFORMATION_ICON& )
  802.  
  803. END SUB
  804.  
  805. '********************************************************************
  806. '
  807. '    Name:    WarnUserOriginal (subroutine)
  808. '
  809. '    Action:    Displays a message box warning the user not to
  810. '              interfere with this program's operation.
  811. '
  812. '    Params:    None.
  813. '
  814. '    Returns:    None.
  815. '
  816. '    Comments: None.
  817. '
  818. '********************************************************************
  819. SUB WarnUserComplete()
  820.  
  821.     DIM MsgReturn AS LONG    ' The return value of MESSAGEBOX.
  822.     MsgReturn& = MESSAGEBOX( "Could not find the object that was " + \\
  823.                               "selected when you first started the " + \\
  824.                               "Drop Shadow Maker." + NL2 + \\
  825.                               "If you deleted the object or combined it with another " + \\
  826.                               "object using a tool such as the Weld tool," + NL + "please " + \\
  827.                               "refrain from doing this in the future, " +\\
  828.                               "since the Drop Shadow Maker takes " + \\
  829.                               "care of all" + NL + "necessary operations " + \\
  830.                               "automatically." + NL2 + \\
  831.                               "Drop Shadow Maker shutting down.", \\
  832.                               TITLE_ERRORBOX$, \\
  833.                               MB_STOP_ICON& )
  834.  
  835. END SUB
  836.  
  837. '********************************************************************
  838. '
  839. '    Name:    ApplyEffect (subroutine)
  840. '
  841. '    Action:    Duplicates the object that has a CDRStaticID of InID
  842. '              and places the duplicate behind the original.  
  843. '              Positions the duplicate relative to the original
  844. '              as determined by InHorizOffset, InVertOffset,
  845. '              InVertUnit, and InHorizUnit.  Applies a colour to
  846. '              the duplicate and optionally makes it transparent.
  847. '
  848. '    Params:    InID - the CDRStaticID of an object to duplicate
  849. '            InRed - the red component (RGB) of the color to apply
  850. '              InGreen - the green component (RGB) of the color to apply
  851. '              InBlue - the blue component (RGB) of the color to apply
  852. '              InMakeTransparent - should the shadow be transparent?
  853. '              InPercent - if transparent, by how much (0% is opaque,
  854. '                          and 100% is wholly transparent)
  855. '              InHorizOffset - the horizontal offset for the shadow
  856. '              InVertOffset - the vertical offset for the shadow
  857. '              InHorizUnit - what unit is specified by InHorizOffset?
  858. '              InVertUnit - what unit is specified by InVertUnit?
  859. '                           (the constants refer to the same units as
  860. '                            UnitsArray)
  861. '
  862. '    Returns:    The CDRStaticID of the duplicate object (the shadow).
  863. '
  864. '    Comments: If InID is not found, displays an error message and 
  865. '              stops the script.
  866. '
  867. '********************************************************************
  868. FUNCTION ApplyEffect( InID AS LONG, \\
  869.                       InRed AS INTEGER, \\
  870.                       InGreen AS INTEGER, \\
  871.                       InBlue AS INTEGER, \\
  872.                       InMakeTransparent AS BOOLEAN, \\
  873.                       InPercent AS INTEGER, \\
  874.                       InHorizOffset AS LONG, \\
  875.                       InVertOffset AS LONG, \\
  876.                       InHorizUnit AS INTEGER, \\
  877.                       InVertUnit AS INTEGER) AS LONG
  878.  
  879.     DIM IDCopied AS LONG    ' The CDRStaticID of the shadow group.
  880.     DIM InitialXPos AS LONG  ' The specified object's X coordinate.
  881.     DIM InitialYPos AS LONG  ' The specified object's Y coordinate.
  882.     DIM NewXPos AS LONG         ' The shadow group's X coordinate.
  883.     DIM NewYPos AS LONG         ' The shadow group's Y coordinate.
  884.     DIM Cyan AS LONG        ' The provided color converted to CMYK.
  885.     DIM Magenta AS LONG        ' The provided color converted to CMYK.
  886.     DIM Yellow AS LONG        ' The provided color converted to CMYK.
  887.     DIM Black AS LONG        ' The provided color converted to CMYK.
  888.     
  889.     ON ERROR GOTO AENotFoundError
  890.  
  891.     ' Make a duplicate of the specified object, remembering
  892.     ' the original position.
  893.     .SelectObjectOfCDRStaticID InID&
  894.     .GetPosition InitialXPos&, InitialYPos&
  895.     .DuplicateObject
  896.     
  897.     ' Store the duplicate's CDRStaticID.
  898.     IDCopied& = .GetObjectsCDRStaticID()
  899.     
  900.     ' Determine where the new object should go.
  901.     SELECT CASE InHorizUnit%
  902.     
  903.         CASE 1 ' 1 in.
  904.             NewXPos& = InitialXPos& +                      \\
  905.                                InHorizOffset& * 1 *                \\
  906.                      LENGTHCONVERT(LC_INCHES,            \\
  907.                                    LC_TENTHS_OFA_MICRON, \\
  908.                                 1)
  909.         CASE 2 ' 1/36 in.
  910.             NewXPos& = InitialXPos& +                      \\
  911.                                InHorizOffset& * (1/36) *           \\
  912.                      LENGTHCONVERT(LC_INCHES,            \\
  913.                                    LC_TENTHS_OFA_MICRON, \\
  914.                                 1)
  915.         CASE 3 ' 0.001 in.
  916.             NewXPos& = InitialXPos& +                      \\
  917.                                InHorizOffset& * 0.001 *            \\
  918.                      LENGTHCONVERT(LC_INCHES,            \\
  919.                                    LC_TENTHS_OFA_MICRON, \\
  920.                                 1)
  921.         CASE 4 ' 1 cm.
  922.             NewXPos& = InitialXPos& +                      \\
  923.                      InHorizOffset& * 1 *                \\
  924.                      LENGTHCONVERT(LC_CENTIMETERS,       \\
  925.                                 LC_TENTHS_OFA_MICRON, \\
  926.                                 1)
  927.         CASE 5 ' 0.001 cm.
  928.             NewXPos& = InitialXPos& +                       \\
  929.                      InHorizOffset& * 0.001 *            \\
  930.                      LENGTHCONVERT(LC_CENTIMETERS,       \\
  931.                                 LC_TENTHS_OFA_MICRON, \\
  932.                                 1)
  933.         CASE 6 ' 1 pt.
  934.             NewXPos& = InitialXPos& +                      \\
  935.                      InHorizOffset& * 1 *                \\
  936.                      LENGTHCONVERT(LC_POINTS,            \\
  937.                                 LC_TENTHS_OFA_MICRON, \\
  938.                                 1)
  939.  
  940.     END SELECT
  941.     SELECT CASE InVertUnit%
  942.     
  943.         CASE 1 ' 1 in.
  944.             NewYPos& = InitialYPos& +                      \\
  945.                                InVertOffset& * 1 *                 \\
  946.                      LENGTHCONVERT(LC_INCHES,            \\
  947.                                    LC_TENTHS_OFA_MICRON, \\
  948.                                 1)
  949.         CASE 2 ' 1/36 in.
  950.             NewYPos& = InitialYPos& +                      \\
  951.                                InVertOffset& * (1/36) *            \\
  952.                      LENGTHCONVERT(LC_INCHES,            \\
  953.                                    LC_TENTHS_OFA_MICRON, \\
  954.                                 1)
  955.         CASE 3 ' 0.001 in.
  956.             NewYPos& = InitialYPos& +                      \\
  957.                                InVertOffset& * 0.001 *             \\
  958.                      LENGTHCONVERT(LC_INCHES,            \\
  959.                                    LC_TENTHS_OFA_MICRON, \\
  960.                                 1)
  961.         CASE 4 ' 1 cm.
  962.             NewYPos& = InitialYPos& +                      \\
  963.                      InVertOffset& * 1 *                 \\
  964.                      LENGTHCONVERT(LC_CENTIMETERS,       \\
  965.                                 LC_TENTHS_OFA_MICRON, \\
  966.                                 1)
  967.         CASE 5 ' 0.001 cm.
  968.             NewYPos& = InitialYPos& +                      \\
  969.                      InVertOffset& * 0.001 *             \\
  970.                      LENGTHCONVERT(LC_CENTIMETERS,       \\
  971.                                 LC_TENTHS_OFA_MICRON, \\
  972.                                 1)
  973.         CASE 6 ' 1 pt.
  974.             NewYPos& = InitialYPos& +                      \\
  975.                      InVertOffset& * 1 *                 \\
  976.                      LENGTHCONVERT(LC_POINTS,            \\
  977.                                 LC_TENTHS_OFA_MICRON, \\
  978.                                 1)
  979.  
  980.     END SELECT
  981.  
  982.     ' Put the new object where it should go.
  983.     .SetPosition NewXPos&, NewYPos&
  984.     .OrderBackOne
  985.  
  986.     ' Apply the appropriate shadow color.
  987.     .StoreColor DRAW_COLORMODEL_RGB&, InRed%, InGreen%, InBlue%, 0
  988.     .ApplyUniformFillColor
  989.  
  990.     ' We do not want an outline on the shadow.
  991.     .ApplyOutline 0, \\
  992.                   DRAW_OUTLINE_TYPE_NONE&, \\
  993.                   DRAW_OUTLINE_CAPS_BUTT&, \\
  994.                   DRAW_OUTLINE_JOIN_MITER&, \\
  995.                   100, \\
  996.                   0, \\
  997.                   0, \\
  998.                   0, \\
  999.                   0, \\
  1000.                   FALSE
  1001.                         
  1002.     ' If the shadow should be transparent, make it so.
  1003.     IF InMakeTransparent THEN
  1004.         
  1005.         ' To illustrate the use of ConvertColor, we
  1006.         ' will convert our input colors to CMYK.
  1007.         .StoreColor DRAW_COLORMODEL_RGB&, \\
  1008.                     InRed%, \\
  1009.                     InGreen%, \\
  1010.                     InBlue%
  1011.         .ConvertColor DRAW_COLORMODEL_CMYK255&, \\
  1012.                       Cyan&, \\
  1013.                       Magenta&, \\
  1014.                       Yellow&, \\
  1015.                       Black&
  1016.     
  1017.         .StoreColor DRAW_COLORMODEL_CMYK255&, \\
  1018.                       Cyan&, Magenta&, Yellow&, Black&
  1019.         .ApplyLensEffect DRAW_TAB_AVERAGE&, \\
  1020.                            FALSE, \\
  1021.                            FALSE, \\
  1022.                            FALSE, \\
  1023.                            0, \\
  1024.                            0, \\
  1025.                            1000 - (InPercent% * 10)
  1026.                       
  1027.  
  1028.         ' Since we've already set the color, the
  1029.         ' other parameters of ApplyLensEffect do
  1030.         ' not need to be provided.            
  1031.  
  1032.     ENDIF
  1033.  
  1034.     ' Return the CDRStaticID of the shadow group.
  1035.     ApplyEffect& = IDCopied&
  1036.  
  1037.     ExitPart:
  1038.         EXIT FUNCTION
  1039.  
  1040.     StopPart:
  1041.         STOP
  1042.  
  1043. AENotFoundError:
  1044.     ' The given object was not found.
  1045.     ERRNUM = 0
  1046.     DIM MsgReturn AS LONG  ' The result of a MESSAGEBOX call.
  1047.     MsgReturn& = MESSAGEBOX( "Could not find the object that was " + \\
  1048.                               "selected when you first started the " + \\
  1049.                               "Drop Shadow Maker." + NL2 + \\
  1050.                               "If you deleted the object, please " + \\
  1051.                               "refrain from doing this in the future, " +\\
  1052.                               "since the Drop Shadow Maker takes " + \\
  1053.                               "care of all necessary object deletion " + \\
  1054.                               "automatically." + NL2 + \\
  1055.                               "Drop Shadow Maker shutting down.", \\
  1056.                               TITLE_ERRORBOX$, \\
  1057.                               MB_STOP_ICON& )
  1058.     RESUME AT StopPart
  1059.  
  1060. END FUNCTION
  1061.  
  1062. END WITHOBJECT
  1063.  
  1064.