CQL_FIND_UI.bas 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #If VBA7 Then
  2. Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal Hwnd As Long) As Long
  3. Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long) As Long
  4. Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  5. Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  6. Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  7. #Else
  8. Private Declare Function DrawMenuBar Lib "user32" (ByVal Hwnd As Long) As Long
  9. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long) As Long
  10. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal Hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  11. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  12. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  13. #End If
  14. Private Const GWL_STYLE As Long = (-16)
  15. Private Const GWL_EXSTYLE = (-20)
  16. Private Const WS_CAPTION As Long = &HC00000
  17. Private Const WS_EX_DLGMODALFRAME = &H1&
  18. Private Sub Close_Icon_Click()
  19. Unload Me ' 关闭
  20. End Sub
  21. Private Sub UserForm_Initialize()
  22. Dim IStyle As Long
  23. Dim Hwnd As Long
  24. Hwnd = FindWindow("ThunderDFrame", Me.Caption)
  25. IStyle = GetWindowLong(Hwnd, GWL_STYLE)
  26. IStyle = IStyle And Not WS_CAPTION
  27. SetWindowLong Hwnd, GWL_STYLE, IStyle
  28. DrawMenuBar Hwnd
  29. IStyle = GetWindowLong(Hwnd, GWL_EXSTYLE) And Not WS_EX_DLGMODALFRAME
  30. SetWindowLong Hwnd, GWL_EXSTYLE, IStyle
  31. With Me
  32. ' .StartUpPosition = 0
  33. ' .Left = 500
  34. ' .Top = 200
  35. .Width = 378
  36. .Height = 228
  37. End With
  38. End Sub
  39. Private Sub LOGO_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
  40. If Button Then
  41. mX = x
  42. mY = y
  43. End If
  44. End Sub
  45. Private Sub LOGO_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
  46. If Button Then
  47. Me.Left = Me.Left - mx + x
  48. Me.Top = Me.Top - my + y
  49. End If
  50. End Sub
  51. Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)
  52. Dim pos_x As Variant
  53. Dim pos_y As Variant
  54. pos_x = Array(307, 27)
  55. pos_y = Array(64, 126, 188, 200)
  56. If Abs(x - pos_x(0)) < 30 And Abs(y - pos_y(0)) < 30 Then
  57. Call CQLSameUniformColor
  58. ElseIf Abs(x - pos_x(0)) < 30 And Abs(y - pos_y(1)) < 30 Then
  59. Call CQLSameOutlineColor
  60. ElseIf Abs(x - pos_x(0)) < 30 And Abs(y - pos_y(2)) < 30 Then
  61. Call CQLSameSize
  62. ElseIf Abs(x - pos_x(1)) < 30 And Abs(y - pos_y(3)) < 30 Then
  63. CorelVBA.WebHelp "https://262235.xyz/index.php/tag/vba/"
  64. End If
  65. '// 预置颜色轮廓选择
  66. If Abs(x - 178) < 30 And Abs(y - 118) < 30 Then
  67. Debug.Print "选择图标: " & x & " , " & y
  68. CQL查找相同.CQLline_CM100
  69. End If
  70. CQL_FIND_UI.Hide
  71. End Sub
  72. Private Sub CQLSameSize()
  73. ActiveDocument.Unit = cdrMillimeter
  74. Dim s As Shape
  75. Set s = ActiveShape
  76. If s Is Nothing Then Exit Sub
  77. If OptBt.value = True Then
  78. ActiveDocument.ClearSelection
  79. OptBt.value = 0
  80. CQL_FIND_UI.Hide
  81. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  82. Dim Shift As Long
  83. Dim box As Boolean
  84. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  85. If Not b Then
  86. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  87. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  88. sh.Shapes.FindShapes(Query:="@width = {" & s.SizeWidth & " mm} and @height ={" & s.SizeHeight & "mm}").CreateSelection
  89. End If
  90. Else
  91. ActivePage.Shapes.FindShapes(Query:="@width = {" & s.SizeWidth & " mm} and @height ={" & s.SizeHeight & "mm}").CreateSelection
  92. End If
  93. End Sub
  94. Private Sub CQLSameOutlineColor()
  95. On Error GoTo err
  96. Dim colr As New Color, s As Shape
  97. Set s = ActiveShape
  98. If s Is Nothing Then Exit Sub
  99. colr.CopyAssign s.Outline.Color
  100. colr.ConvertToRGB
  101. ' 查找对象
  102. r = colr.RGBRed
  103. G = colr.RGBGreen
  104. b = colr.RGBBlue
  105. If OptBt.value = True Then
  106. ActiveDocument.ClearSelection
  107. OptBt.value = 0
  108. CQL_FIND_UI.Hide
  109. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  110. Dim Shift As Long
  111. Dim box As Boolean
  112. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  113. If Not b Then
  114. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  115. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  116. sh.Shapes.FindShapes(Query:="@Outline.Color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  117. End If
  118. Else
  119. ActivePage.Shapes.FindShapes(Query:="@Outline.Color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  120. End If
  121. Exit Sub
  122. err:
  123. MsgBox "对象轮廓为空。"
  124. End Sub
  125. Private Sub CQLSameUniformColor()
  126. On Error GoTo err
  127. Dim colr As New Color, s As Shape
  128. Set s = ActiveShape
  129. If s Is Nothing Then Exit Sub
  130. If s.Fill.Type = cdrFountainFill Then MsgBox "不支持渐变色。": Exit Sub
  131. colr.CopyAssign s.Fill.UniformColor
  132. colr.ConvertToRGB
  133. ' 查找对象
  134. r = colr.RGBRed
  135. G = colr.RGBGreen
  136. b = colr.RGBBlue
  137. If OptBt.value = True Then
  138. ActiveDocument.ClearSelection
  139. OptBt.value = 0
  140. CQL_FIND_UI.Hide
  141. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  142. Dim Shift As Long
  143. Dim box As Boolean
  144. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  145. If Not b Then
  146. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  147. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  148. sh.Shapes.FindShapes(Query:="@fill.color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  149. End If
  150. Else
  151. ActivePage.Shapes.FindShapes(Query:="@fill.color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  152. End If
  153. Exit Sub
  154. err:
  155. MsgBox "对象填充为空。"
  156. End Sub