CQL_FIND_UI.bas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  2. Dim pos_x As Variant
  3. Dim pos_Y As Variant
  4. pos_x = Array(307, 27)
  5. pos_Y = Array(64, 126, 188, 200)
  6. If Abs(X - pos_x(0)) < 30 And Abs(Y - pos_Y(0)) < 30 Then
  7. Call CQLSameUniformColor
  8. ElseIf Abs(X - pos_x(0)) < 30 And Abs(Y - pos_Y(1)) < 30 Then
  9. Call CQLSameOutlineColor
  10. ElseIf Abs(X - pos_x(0)) < 30 And Abs(Y - pos_Y(2)) < 30 Then
  11. Call CQLSameSize
  12. ElseIf Abs(X - pos_x(1)) < 30 And Abs(Y - pos_Y(3)) < 30 Then
  13. CorelVBA.WebHelp "https://262235.xyz/index.php/tag/vba/"
  14. End If
  15. CQL_FIND_UI.Hide ' show
  16. End Sub
  17. Private Sub CQLSameSize()
  18. ActiveDocument.Unit = cdrMillimeter
  19. Dim s As Shape
  20. Set s = ActiveShape
  21. If s Is Nothing Then Exit Sub
  22. If OptBt.Value = True Then
  23. ActiveDocument.ClearSelection
  24. OptBt.Value = 0
  25. CQL_FIND_UI.Hide
  26. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  27. Dim Shift As Long
  28. Dim box As Boolean
  29. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  30. If Not b Then
  31. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  32. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  33. sh.Shapes.FindShapes(Query:="@width = {" & s.SizeWidth & " mm} and @height ={" & s.SizeHeight & "mm}").CreateSelection
  34. End If
  35. Else
  36. ActivePage.Shapes.FindShapes(Query:="@width = {" & s.SizeWidth & " mm} and @height ={" & s.SizeHeight & "mm}").CreateSelection
  37. End If
  38. End Sub
  39. Private Sub CQLSameOutlineColor()
  40. On Error GoTo err
  41. Dim colr As New Color, s As Shape
  42. Set s = ActiveShape
  43. If s Is Nothing Then Exit Sub
  44. colr.CopyAssign s.Outline.Color
  45. colr.ConvertToRGB
  46. ' 查找对象
  47. r = colr.RGBRed
  48. G = colr.RGBGreen
  49. b = colr.RGBBlue
  50. If OptBt.Value = True Then
  51. ActiveDocument.ClearSelection
  52. OptBt.Value = 0
  53. CQL_FIND_UI.Hide
  54. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  55. Dim Shift As Long
  56. Dim box As Boolean
  57. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  58. If Not b Then
  59. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  60. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  61. sh.Shapes.FindShapes(Query:="@Outline.Color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  62. End If
  63. Else
  64. ActivePage.Shapes.FindShapes(Query:="@Outline.Color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  65. End If
  66. Exit Sub
  67. err:
  68. MsgBox "对象轮廓为空。"
  69. End Sub
  70. Private Sub CQLSameUniformColor()
  71. On Error GoTo err
  72. Dim colr As New Color, s As Shape
  73. Set s = ActiveShape
  74. If s Is Nothing Then Exit Sub
  75. If s.Fill.Type = cdrFountainFill Then MsgBox "不支持渐变色。": Exit Sub
  76. colr.CopyAssign s.Fill.UniformColor
  77. colr.ConvertToRGB
  78. ' 查找对象
  79. r = colr.RGBRed
  80. G = colr.RGBGreen
  81. b = colr.RGBBlue
  82. If OptBt.Value = True Then
  83. ActiveDocument.ClearSelection
  84. OptBt.Value = 0
  85. CQL_FIND_UI.Hide
  86. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  87. Dim Shift As Long
  88. Dim box As Boolean
  89. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  90. If Not b Then
  91. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  92. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  93. sh.Shapes.FindShapes(Query:="@fill.color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  94. End If
  95. Else
  96. ActivePage.Shapes.FindShapes(Query:="@fill.color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  97. End If
  98. Exit Sub
  99. err:
  100. MsgBox "对象填充为空。"
  101. End Sub