home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Delphi / PolarDraw / data1.cab / Samples / Visual_Basic / VBDraw / frmShadowLens.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-08-31  |  6.8 KB  |  220 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
  3. Begin VB.Form frmShadowLens 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Shadow lens settings"
  6.    ClientHeight    =   2295
  7.    ClientLeft      =   1905
  8.    ClientTop       =   2010
  9.    ClientWidth     =   3735
  10.    FillColor       =   &H00400000&
  11.    Icon            =   "frmShadowLens.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   2295
  16.    ScaleWidth      =   3735
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.CommandButton btnCancel 
  19.       Caption         =   "Cancel"
  20.       Height          =   360
  21.       Left            =   2745
  22.       TabIndex        =   7
  23.       Top             =   525
  24.       Width           =   930
  25.    End
  26.    Begin VB.ComboBox cmbLensType 
  27.       Height          =   315
  28.       Left            =   135
  29.       Style           =   2  'Dropdown List
  30.       TabIndex        =   5
  31.       Top             =   480
  32.       Width           =   2130
  33.    End
  34.    Begin VB.CommandButton btnStartColor 
  35.       Caption         =   "Start Color"
  36.       Enabled         =   0   'False
  37.       Height          =   345
  38.       Left            =   135
  39.       TabIndex        =   0
  40.       Top             =   1860
  41.       Width           =   1065
  42.    End
  43.    Begin VB.CommandButton btnEndColor 
  44.       Caption         =   "End Color"
  45.       Enabled         =   0   'False
  46.       Height          =   345
  47.       Left            =   1260
  48.       TabIndex        =   1
  49.       Top             =   1860
  50.       Width           =   1065
  51.    End
  52.    Begin VB.CommandButton btnOK 
  53.       Caption         =   "OK"
  54.       Height          =   360
  55.       Left            =   2745
  56.       TabIndex        =   2
  57.       Top             =   135
  58.       Width           =   930
  59.    End
  60.    Begin ComctlLib.Slider sldPercentage 
  61.       Height          =   210
  62.       Left            =   30
  63.       TabIndex        =   4
  64.       Top             =   1530
  65.       Width           =   2145
  66.       _ExtentX        =   3784
  67.       _ExtentY        =   370
  68.       _Version        =   327682
  69.       Enabled         =   -1  'True
  70.       LargeChange     =   10
  71.       Min             =   -100
  72.       Max             =   100
  73.       TickStyle       =   3
  74.    End
  75.    Begin VB.Label Label1 
  76.       Caption         =   "Choose lens type:"
  77.       Height          =   255
  78.       Left            =   135
  79.       TabIndex        =   6
  80.       Top             =   210
  81.       Width           =   2130
  82.    End
  83.    Begin VB.Label lblPercentage 
  84.       Caption         =   "Effect percentage:"
  85.       Height          =   285
  86.       Left            =   105
  87.       TabIndex        =   3
  88.       Top             =   1125
  89.       Width           =   2250
  90.    End
  91. Attribute VB_Name = "frmShadowLens"
  92. Attribute VB_GlobalNameSpace = False
  93. Attribute VB_Creatable = False
  94. Attribute VB_PredeclaredId = True
  95. Attribute VB_Exposed = False
  96. Dim pd_ShadowLens As POLARDRAW20Lib.Lens
  97. Const polNothing = -1
  98. Dim LensType As Variant
  99. Dim crStartColor As OLE_COLOR, crEndColor As OLE_COLOR
  100. Dim lPercentage As Long, lType As Long
  101. Dim fHasLens As Boolean
  102. Private Sub btnCancel_Click()
  103.  'if user cancels, set back to initial values
  104.    With pd_ShadowLens
  105.       .Type = lType
  106.       .Percent = lPercentage
  107.       .BackColor = crEndColor
  108.       .Color = crStartColor
  109.    End With
  110.    pd_Selection.ShapeRange.Shadow.HasLens = fHasLens
  111.    Unload Me
  112. End Sub
  113. Private Sub btnOK_Click()
  114.     Unload Me
  115. End Sub
  116. Private Sub btnStartColor_Click()
  117.     'Displays dialogbox showing colors
  118.     With pd_ShadowLens
  119.         .Color = SetColor(.Color)
  120.     End With
  121. End Sub
  122. Private Sub btnEndColor_Click()
  123.     With pd_ShadowLens
  124.         .BackColor = SetColor(.BackColor)
  125.     End With
  126. End Sub
  127. Private Sub cmbLensType_Click()
  128.    With cmbLensType
  129.       If .ItemData(.ListIndex) = -1 Then
  130.          pd_Selection.ShapeRange.Shadow.HasLens = False
  131.       Else
  132.          pd_Selection.ShapeRange.Shadow.HasLens = True
  133.          pd_ShadowLens.Type = .ItemData(.ListIndex)
  134.          SetControls pd_ShadowLens.Type
  135.       End If
  136.    End With
  137. End Sub
  138. Private Sub Form_Load()
  139.    Set pd_ShadowLens = Nothing
  140.    Set pd_ShadowLens = pd_Selection.ShapeRange.Shadow.Lens
  141.   'saving initial values
  142.    With pd_ShadowLens
  143.       lType = .Type
  144.       lPercentage = .Percent
  145.       crEndColor = .BackColor
  146.       crStartColor = .Color
  147.    End With
  148.    fHasLens = pd_Selection.ShapeRange.Shadow.HasLens
  149.    LensType = Array(polTransparency, polBrighten, polColorAdd, polColorLimit, polCustomPalette, polInvert, polTintedGrayscale, polHeatmapPalette, polNothing)
  150.    Dim strLensName As Variant
  151.    strLensName = Array("Transparency", "Brighten/Darken", "Add Color", "Limit Color", "Custom Palette", "Invert", "Tinted Grayscale", "Heatmap Palette", "Nothing")
  152.    'setting values to combo box
  153.    With cmbLensType
  154.       .Clear
  155.       For i = 0 To 8
  156.          .AddItem strLensName(i), i
  157.          .ItemData(i) = LensType(i)
  158.       Next
  159.       If False = pd_Selection.ShapeRange.Shadow.HasLens Then
  160.          .ListIndex = .NewIndex
  161.       Else
  162.          j = 0
  163.          Do While .ItemData(j) <> pd_ShadowLens.Type
  164.             j = j + 1
  165.          Loop
  166.          .ListIndex = j
  167.        
  168.       End If
  169.       SetControls .ItemData(.ListIndex)
  170.    End With
  171.    lblPercentage.Caption = "Effect percentage: " + CStr(sldPercentage.Value) + "%"
  172. End Sub
  173. Private Sub Form_Unload(Cancel As Integer)
  174.    Set pd_ShadowLens = Nothing
  175. End Sub
  176. Private Sub sldPercentage_Scroll()
  177.    pd_ShadowLens.Percent = sldPercentage.Value
  178.    lblPercentage.Caption = "Effect percentage: " + CStr(pd_ShadowLens.Percent) + "%"
  179. End Sub
  180. Sub SetControls(LensType As polLensType)
  181.    Select Case LensType
  182.    Case polNothing
  183.       sldPercentage.Enabled = False
  184.       btnStartColor.Enabled = False
  185.       btnEndColor = False
  186.    Case polTransparency
  187.       sldPercentage.Enabled = True
  188.       btnStartColor.Enabled = False
  189.       btnEndColor = False
  190.    Case polBrighten
  191.       sldPercentage.Enabled = True
  192.       btnStartColor.Enabled = False
  193.       btnEndColor = False
  194.    Case polColorAdd
  195.       sldPercentage.Enabled = True
  196.       btnStartColor.Enabled = True
  197.       btnEndColor = False
  198.    Case polColorLimit
  199.       sldPercentage.Enabled = True
  200.       btnStartColor.Enabled = True
  201.       btnEndColor = False
  202.    Case polCustomPalette
  203.       sldPercentage.Enabled = False
  204.       btnStartColor.Enabled = True
  205.       btnEndColor = True
  206.    Case polInvert
  207.       sldPercentage.Enabled = False
  208.       btnStartColor.Enabled = False
  209.       btnEndColor = False
  210.    Case polTintedGrayscale
  211.       sldPercentage.Enabled = False
  212.       btnStartColor.Enabled = True
  213.       btnEndColor = False
  214.    Case polHeatmapPalette
  215.       sldPercentage.Enabled = False
  216.       btnStartColor.Enabled = False
  217.       btnEndColor = False
  218.    End Select
  219. End Sub
  220.