CQL_FIND_UI.bas 6.7 KB

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