1
1

CQL_FIND_UI.frm 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. VERSION 5.00
  2. Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} CQL_FIND_UI
  3. ClientHeight = 7830
  4. ClientLeft = 45
  5. ClientTop = 330
  6. ClientWidth = 11610
  7. OleObjectBlob = "CQL_FIND_UI.frx":0000
  8. StartUpPosition = 1 'CenterOwner
  9. End
  10. Attribute VB_Name = "CQL_FIND_UI"
  11. Attribute VB_GlobalNameSpace = False
  12. Attribute VB_Creatable = False
  13. Attribute VB_PredeclaredId = True
  14. Attribute VB_Exposed = False
  15. '// This is free and unencumbered software released into the public domain.
  16. '// For more information, please refer to https://github.com/hongwenjun
  17. #If VBA7 Then
  18. Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
  19. Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  20. Private Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  21. Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  22. Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  23. #Else
  24. Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
  25. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
  26. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  27. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  28. Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
  29. #End If
  30. Private Const GWL_STYLE As Long = (-16)
  31. Private Const GWL_EXSTYLE = (-20)
  32. Private Const WS_CAPTION As Long = &HC00000
  33. Private Const WS_EX_DLGMODALFRAME = &H1&
  34. Private Sub UserForm_Initialize()
  35. Dim IStyle As Long
  36. Dim hwnd As Long
  37. hwnd = FindWindow("ThunderDFrame", Me.Caption)
  38. IStyle = GetWindowLong(hwnd, GWL_STYLE)
  39. IStyle = IStyle And Not WS_CAPTION
  40. SetWindowLong hwnd, GWL_STYLE, IStyle
  41. DrawMenuBar hwnd
  42. IStyle = GetWindowLong(hwnd, GWL_EXSTYLE) And Not WS_EX_DLGMODALFRAME
  43. SetWindowLong hwnd, GWL_EXSTYLE, IStyle
  44. With Me
  45. ' .StartUpPosition = 0
  46. ' .Left = 500
  47. ' .Top = 200
  48. .width = 378
  49. .Height = 228
  50. End With
  51. txtInfo.text = "Usage: A->Left B->Right C->Ctrl"
  52. End Sub
  53. Private Sub LOGO_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  54. If Button Then
  55. mx = X
  56. my = Y
  57. End If
  58. End Sub
  59. Private Sub LOGO_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  60. If Button Then
  61. '// Debug.Print X, Y
  62. Me.Left = Me.Left - mx + X
  63. Me.Top = Me.Top - my + Y
  64. End If
  65. End Sub
  66. Private Sub Image1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  67. Dim pos_x As Variant
  68. Dim pos_y As Variant
  69. pos_x = Array(307, 27)
  70. pos_y = Array(64, 126, 188, 200)
  71. If Abs(X - pos_x(0)) < 30 And Abs(Y - pos_y(0)) < 30 Then
  72. Call CQLSameUniformColor
  73. ElseIf Abs(X - pos_x(0)) < 30 And Abs(Y - pos_y(1)) < 30 Then
  74. Call CQLSameOutlineColor
  75. ElseIf Abs(X - pos_x(0)) < 30 And Abs(Y - pos_y(2)) < 30 Then
  76. Call CQLSameSize
  77. ElseIf Abs(X - pos_x(1)) < 30 And Abs(Y - pos_y(3)) < 30 Then
  78. '// WebHelp "https://262235.xyz/index.php/tag/vba/"
  79. End If
  80. '// 预置颜色轮廓选择 和 '// 彩蛋功能
  81. If Abs(X - 178) < 30 And Abs(Y - 118) < 30 = True Then
  82. Image1.Visible = False
  83. Close_Icon.Visible = False
  84. X_EXIT.Visible = True
  85. With CQL_FIND_UI
  86. .StartUpPosition = 0
  87. .Left = Val(GetSetting("LYVBA", "Settings", "Left", "400")) + 318
  88. .Top = Val(GetSetting("LYVBA", "Settings", "Top", "55")) - 2
  89. .Height = 30
  90. .width = .width - 20
  91. End With
  92. If OptBt.value Then
  93. frmSelectSame.Show 0
  94. Else
  95. CQLFindSame.CQLline_CM100
  96. End If
  97. Exit Sub
  98. End If
  99. CQL_FIND_UI.Hide
  100. End Sub
  101. Private Sub MADD_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  102. If Button = 2 Then
  103. Store_Instruction 2, "add"
  104. ElseIf Shift = fmCtrlMask Then
  105. Store_Instruction 1, "add"
  106. Else
  107. Store_Instruction 3, "add"
  108. End If
  109. txtInfo.text = StoreCount
  110. End Sub
  111. Private Sub MSUB_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  112. If Button = 2 Then
  113. Store_Instruction 2, "sub"
  114. ElseIf Shift = fmCtrlMask Then
  115. Store_Instruction 1, "sub"
  116. Else
  117. Store_Instruction 3, "sub"
  118. End If
  119. txtInfo.text = StoreCount
  120. End Sub
  121. Private Sub MRLW_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  122. If Button = 2 Then
  123. Store_Instruction 2, "lw"
  124. ElseIf Shift = fmCtrlMask Then
  125. Store_Instruction 1, "lw"
  126. Else
  127. Store_Instruction 3, "lw"
  128. End If
  129. txtInfo.text = StoreCount
  130. End Sub
  131. Private Sub MZERO_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
  132. If Button = 2 Then
  133. Store_Instruction 2, "zero"
  134. ElseIf Shift = fmCtrlMask Then
  135. Store_Instruction 1, "zero"
  136. Else
  137. Store_Instruction 3, "zero"
  138. End If
  139. txtInfo.text = StoreCount
  140. End Sub
  141. Private Sub CQLSameSize()
  142. ActiveDocument.Unit = cdrMillimeter
  143. Dim s As Shape
  144. Set s = ActiveShape
  145. If s Is Nothing Then Exit Sub
  146. If OptBt.value = True Then
  147. ActiveDocument.ClearSelection
  148. OptBt.value = 0
  149. CQL_FIND_UI.Hide
  150. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  151. Dim Shift As Long
  152. Dim box As Boolean
  153. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  154. If Not b Then
  155. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  156. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  157. sh.Shapes.FindShapes(Query:="@width = {" & s.SizeWidth & " mm} and @height ={" & s.SizeHeight & "mm}").CreateSelection
  158. End If
  159. Else
  160. ActivePage.Shapes.FindShapes(Query:="@width = {" & s.SizeWidth & " mm} and @height ={" & s.SizeHeight & "mm}").CreateSelection
  161. End If
  162. End Sub
  163. Private Sub CQLSameOutlineColor()
  164. On Error GoTo err
  165. Dim colr As New Color, s As Shape
  166. Set s = ActiveShape
  167. If s Is Nothing Then Exit Sub
  168. colr.CopyAssign s.Outline.Color
  169. colr.ConvertToRGB
  170. ' 查找对象
  171. r = colr.RGBRed
  172. G = colr.RGBGreen
  173. b = colr.RGBBlue
  174. If OptBt.value = True Then
  175. ActiveDocument.ClearSelection
  176. OptBt.value = 0
  177. CQL_FIND_UI.Hide
  178. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  179. Dim Shift As Long
  180. Dim box As Boolean
  181. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  182. If Not b Then
  183. ' MsgBox "选区范围: " & x1 & y1 & x2 & y2
  184. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  185. sh.Shapes.FindShapes(Query:="@Outline.Color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  186. End If
  187. Else
  188. ActivePage.Shapes.FindShapes(Query:="@Outline.Color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  189. End If
  190. Exit Sub
  191. err:
  192. MsgBox "对象轮廓为空。"
  193. End Sub
  194. Private Sub CQLSameUniformColor()
  195. On Error GoTo err
  196. Dim colr As New Color, s As Shape
  197. Set s = ActiveShape
  198. If s Is Nothing Then Exit Sub
  199. If s.Fill.Type = cdrFountainFill Then MsgBox "不支持渐变色。": Exit Sub
  200. colr.CopyAssign s.Fill.UniformColor
  201. colr.ConvertToRGB
  202. ' 查找对象
  203. r = colr.RGBRed
  204. G = colr.RGBGreen
  205. b = colr.RGBBlue
  206. If OptBt.value = True Then
  207. ActiveDocument.ClearSelection
  208. OptBt.value = 0
  209. CQL_FIND_UI.Hide
  210. Dim x1 As Double, y1 As Double, x2 As Double, y2 As Double
  211. Dim Shift As Long
  212. Dim box As Boolean
  213. box = ActiveDocument.GetUserArea(x1, y1, x2, y2, Shift, 10, False, cdrCursorWeldSingle)
  214. If Not b Then
  215. '// MsgBox "选区范围: " & x1 & y1 & x2 & y2
  216. Set sh = ActivePage.SelectShapesFromRectangle(x1, y1, x2, y2, False)
  217. sh.Shapes.FindShapes(Query:="@fill.color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  218. End If
  219. Else
  220. ActivePage.Shapes.FindShapes(Query:="@fill.color.rgb[.r='" & r & "' And .g='" & G & "' And .b='" & b & "']").CreateSelection
  221. End If
  222. Exit Sub
  223. err:
  224. MsgBox "对象填充为空。"
  225. End Sub
  226. Private Sub X_EXIT_Click()
  227. Unload Me '// 关闭
  228. End Sub
  229. Private Sub Close_Icon_Click()
  230. Unload Me '// 关闭
  231. End Sub