GuiEdit_En.au3 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  1. #include-once
  2. #include "EditConstants.au3"
  3. #include "GuiStatusBar.au3"
  4. #include "Memory.au3"
  5. #include "SendMessage.au3"
  6. #include "ToolTipConstants.au3" ; for _GUICtrlEdit_ShowBalloonTip()
  7. #include "UDFGlobalID.au3"
  8. #include "WinAPIConv.au3"
  9. #include "WinAPIHObj.au3"
  10. #include "WinAPISysInternals.au3"
  11. ; #INDEX# =======================================================================================================================
  12. ; Title .........: Edit
  13. ; AutoIt Version : 3.3.14.5
  14. ; Language ......: English
  15. ; Description ...: Functions that assist with Edit control management.
  16. ; An edit control is a rectangular control window typically used in a dialog box to permit the user to enter
  17. ; and edit text by typing on the keyboard.
  18. ; ===============================================================================================================================
  19. ; #VARIABLES# ===================================================================================================================
  20. Global $__g_hEditLastWnd
  21. ; ===============================================================================================================================
  22. ; #CONSTANTS# ===================================================================================================================
  23. Global Const $__EDITCONSTANT_ClassName = "Edit"
  24. Global Const $__EDITCONSTANT_GUI_CHECKED = 1
  25. Global Const $__EDITCONSTANT_GUI_HIDE = 32
  26. Global Const $__EDITCONSTANT_GUI_EVENT_CLOSE = -3
  27. Global Const $__EDITCONSTANT_GUI_ENABLE = 64
  28. Global Const $__EDITCONSTANT_GUI_DISABLE = 128
  29. Global Const $__EDITCONSTANT_SS_CENTER = 1
  30. Global Const $__EDITCONSTANT_WM_SETREDRAW = 0x000B
  31. Global Const $__EDITCONSTANT_WS_CAPTION = 0x00C00000
  32. Global Const $__EDITCONSTANT_WS_POPUP = 0x80000000
  33. Global Const $__EDITCONSTANT_WS_SYSMENU = 0x00080000
  34. Global Const $__EDITCONSTANT_WS_MINIMIZEBOX = 0x00020000
  35. Global Const $__EDITCONSTANT_DEFAULT_GUI_FONT = 17
  36. Global Const $__EDITCONSTANT_WM_SETFONT = 0x0030
  37. Global Const $__EDITCONSTANT_WM_GETTEXTLENGTH = 0x000E
  38. Global Const $__EDITCONSTANT_WM_GETTEXT = 0x000D
  39. Global Const $__EDITCONSTANT_WM_SETTEXT = 0x000C
  40. Global Const $__EDITCONSTANT_SB_LINEUP = 0
  41. Global Const $__EDITCONSTANT_SB_LINEDOWN = 1
  42. Global Const $__EDITCONSTANT_SB_PAGEDOWN = 3
  43. Global Const $__EDITCONSTANT_SB_PAGEUP = 2
  44. Global Const $__EDITCONSTANT_SB_SCROLLCARET = 4
  45. ; ===============================================================================================================================
  46. ; #NO_DOC_FUNCTION# =============================================================================================================
  47. ; Not working/documented/implemented at this time
  48. ;
  49. ; _GUICtrlEdit_GetHandle
  50. ; _GUICtrlEdit_GetIMEStatus
  51. ; _GUICtrlEdit_GetThumb
  52. ; _GUICtrlEdit_GetWordBreakProc
  53. ; _GUICtrlEdit_SetHandle
  54. ; _GUICtrlEdit_SetIMEStatus
  55. ; _GUICtrlEdit_SetWordBreakProc
  56. ; ===============================================================================================================================
  57. ; #CURRENT# =====================================================================================================================
  58. ; _GUICtrlEdit_AppendText
  59. ; _GUICtrlEdit_BeginUpdate
  60. ; _GUICtrlEdit_CanUndo
  61. ; _GUICtrlEdit_CharFromPos
  62. ; _GUICtrlEdit_Create
  63. ; _GUICtrlEdit_Destroy
  64. ; _GUICtrlEdit_EmptyUndoBuffer
  65. ; _GUICtrlEdit_EndUpdate
  66. ; _GUICtrlEdit_FmtLines
  67. ; _GUICtrlEdit_Find
  68. ; _GUICtrlEdit_GetCueBanner
  69. ; _GUICtrlEdit_GetFirstVisibleLine
  70. ; _GUICtrlEdit_GetLimitText
  71. ; _GUICtrlEdit_GetLine
  72. ; _GUICtrlEdit_GetLineCount
  73. ; _GUICtrlEdit_GetMargins
  74. ; _GUICtrlEdit_GetModify
  75. ; _GUICtrlEdit_GetPasswordChar
  76. ; _GUICtrlEdit_GetRECT
  77. ; _GUICtrlEdit_GetRECTEx
  78. ; _GUICtrlEdit_GetSel
  79. ; _GUICtrlEdit_GetText
  80. ; _GUICtrlEdit_GetTextLen
  81. ; _GUICtrlEdit_HideBalloonTip
  82. ; _GUICtrlEdit_InsertText
  83. ; _GUICtrlEdit_LineFromChar
  84. ; _GUICtrlEdit_LineIndex
  85. ; _GUICtrlEdit_LineLength
  86. ; _GUICtrlEdit_LineScroll
  87. ; _GUICtrlEdit_PosFromChar
  88. ; _GUICtrlEdit_ReplaceSel
  89. ; _GUICtrlEdit_Scroll
  90. ; _GUICtrlEdit_SetCueBanner
  91. ; _GUICtrlEdit_SetLimitText
  92. ; _GUICtrlEdit_SetMargins
  93. ; _GUICtrlEdit_SetModify
  94. ; _GUICtrlEdit_SetPasswordChar
  95. ; _GUICtrlEdit_SetReadOnly
  96. ; _GUICtrlEdit_SetRECT
  97. ; _GUICtrlEdit_SetRECTEx
  98. ; _GUICtrlEdit_SetRECTNP
  99. ; _GUICtrlEdit_SetRectNPEx
  100. ; _GUICtrlEdit_SetSel
  101. ; _GUICtrlEdit_SetTabStops
  102. ; _GUICtrlEdit_SetText
  103. ; _GUICtrlEdit_ShowBalloonTip
  104. ; _GUICtrlEdit_Undo
  105. ; ===============================================================================================================================
  106. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  107. ; $__tagEDITBALLOONTIP
  108. ; __GUICtrlEdit_FindText
  109. ; ===============================================================================================================================
  110. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  111. ; Name...........: $tagEDITBALLOONTIP
  112. ; Description ...: Contains information about a balloon tip
  113. ; Fields ........: Size - Size of this structure, in bytes
  114. ; Title - Pointer to the buffer that holds Title of the ToolTip
  115. ; Text - Pointer to the buffer that holds Text of the ToolTip
  116. ; Icon - Type of Icon. This can be one of the following values:
  117. ; |$TTI_ERROR - Use the error icon
  118. ; |$TTI_INFO - Use the information icon
  119. ; |$TTI_NONE - Use no icon
  120. ; |$TTI_WARNING - Use the warning icon
  121. ; Author ........: Gary Frost (gafrost)
  122. ; Remarks .......: For use with Edit control (minimum O.S. Win XP)
  123. ; ===============================================================================================================================
  124. Global Const $__tagEDITBALLOONTIP = "dword Size;ptr Title;ptr Text;int Icon"
  125. ; #FUNCTION# ====================================================================================================================
  126. ; Author ........: Gary Frost (gafrost)
  127. ; Modified.......:
  128. ; ===============================================================================================================================
  129. Func _GUICtrlEdit_AppendText($hWnd, $sText)
  130. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  131. Local $iLength = _GUICtrlEdit_GetTextLen($hWnd)
  132. _GUICtrlEdit_SetSel($hWnd, $iLength, $iLength)
  133. _SendMessage($hWnd, $EM_REPLACESEL, True, $sText, 0, "wparam", "wstr")
  134. EndFunc ;==>_GUICtrlEdit_AppendText
  135. ; #FUNCTION# ====================================================================================================================
  136. ; Author ........: Gary Frost (gafrost)
  137. ; Modified.......:
  138. ; ===============================================================================================================================
  139. Func _GUICtrlEdit_BeginUpdate($hWnd)
  140. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  141. Return _SendMessage($hWnd, $__EDITCONSTANT_WM_SETREDRAW, False) = 0
  142. EndFunc ;==>_GUICtrlEdit_BeginUpdate
  143. ; #FUNCTION# ====================================================================================================================
  144. ; Author ........: Gary Frost (gafrost)
  145. ; Modified.......:
  146. ; ===============================================================================================================================
  147. Func _GUICtrlEdit_CanUndo($hWnd)
  148. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  149. Return _SendMessage($hWnd, $EM_CANUNDO) <> 0
  150. EndFunc ;==>_GUICtrlEdit_CanUndo
  151. ; #FUNCTION# ====================================================================================================================
  152. ; Author ........: Gary Frost (gafrost)
  153. ; Modified.......:
  154. ; ===============================================================================================================================
  155. Func _GUICtrlEdit_CharFromPos($hWnd, $iX, $iY)
  156. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  157. Local $aReturn[2]
  158. Local $iRet = _SendMessage($hWnd, $EM_CHARFROMPOS, 0, _WinAPI_MakeLong($iX, $iY))
  159. $aReturn[0] = _WinAPI_LoWord($iRet)
  160. $aReturn[1] = _WinAPI_HiWord($iRet)
  161. Return $aReturn
  162. EndFunc ;==>_GUICtrlEdit_CharFromPos
  163. ; #FUNCTION# ====================================================================================================================
  164. ; Author ........: Gary Frost
  165. ; Modified.......:
  166. ; ===============================================================================================================================
  167. Func _GUICtrlEdit_Create($hWnd, $sText, $iX, $iY, $iWidth = 150, $iHeight = 150, $iStyle = 0x003010C4, $iExStyle = 0x00000200)
  168. If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ; Invalid Window handle for _GUICtrlEdit_Create 1st parameter
  169. If Not IsString($sText) Then Return SetError(2, 0, 0) ; 2nd parameter not a string for _GUICtrlEdit_Create
  170. If $iWidth = -1 Then $iWidth = 150
  171. If $iHeight = -1 Then $iHeight = 150
  172. If $iStyle = -1 Then $iStyle = 0x003010C4
  173. If $iExStyle = -1 Then $iExStyle = 0x00000200
  174. If BitAND($iStyle, $ES_READONLY) = $ES_READONLY Then
  175. $iStyle = BitOR($__UDFGUICONSTANT_WS_CHILD, $__UDFGUICONSTANT_WS_VISIBLE, $iStyle)
  176. Else
  177. $iStyle = BitOR($__UDFGUICONSTANT_WS_CHILD, $__UDFGUICONSTANT_WS_VISIBLE, $__UDFGUICONSTANT_WS_TABSTOP, $iStyle)
  178. EndIf
  179. ;=========================================================================================================
  180. Local $nCtrlID = __UDF_GetNextGlobalID($hWnd)
  181. If @error Then Return SetError(@error, @extended, 0)
  182. Local $hEdit = _WinAPI_CreateWindowEx($iExStyle, $__EDITCONSTANT_ClassName, "", $iStyle, $iX, $iY, $iWidth, $iHeight, $hWnd, $nCtrlID)
  183. _SendMessage($hEdit, $__EDITCONSTANT_WM_SETFONT, _WinAPI_GetStockObject($__EDITCONSTANT_DEFAULT_GUI_FONT), True)
  184. _GUICtrlEdit_SetText($hEdit, $sText)
  185. _GUICtrlEdit_SetLimitText($hEdit, 0)
  186. Return $hEdit
  187. EndFunc ;==>_GUICtrlEdit_Create
  188. ; #FUNCTION# ====================================================================================================================
  189. ; Author ........: Gary Frost (gafrost)
  190. ; Modified.......:
  191. ; ===============================================================================================================================
  192. Func _GUICtrlEdit_Destroy(ByRef $hWnd)
  193. If Not _WinAPI_IsClassName($hWnd, $__EDITCONSTANT_ClassName) Then Return SetError(2, 2, False)
  194. Local $iDestroyed = 0
  195. If IsHWnd($hWnd) Then
  196. If _WinAPI_InProcess($hWnd, $__g_hEditLastWnd) Then
  197. Local $nCtrlID = _WinAPI_GetDlgCtrlID($hWnd)
  198. Local $hParent = _WinAPI_GetParent($hWnd)
  199. $iDestroyed = _WinAPI_DestroyWindow($hWnd)
  200. Local $iRet = __UDF_FreeGlobalID($hParent, $nCtrlID)
  201. If Not $iRet Then
  202. ; can check for errors here if needed, for debug
  203. EndIf
  204. Else
  205. ; Not Allowed to Destroy Other Applications Control(s)
  206. Return SetError(1, 1, False)
  207. EndIf
  208. Else
  209. $iDestroyed = GUICtrlDelete($hWnd)
  210. EndIf
  211. If $iDestroyed Then $hWnd = 0
  212. Return $iDestroyed <> 0
  213. EndFunc ;==>_GUICtrlEdit_Destroy
  214. ; #FUNCTION# ====================================================================================================================
  215. ; Author ........: Gary Frost (gafrost)
  216. ; Modified.......:
  217. ; ===============================================================================================================================
  218. Func _GUICtrlEdit_EmptyUndoBuffer($hWnd)
  219. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  220. _SendMessage($hWnd, $EM_EMPTYUNDOBUFFER)
  221. EndFunc ;==>_GUICtrlEdit_EmptyUndoBuffer
  222. ; #FUNCTION# ====================================================================================================================
  223. ; Author ........: Gary Frost (gafrost)
  224. ; Modified.......:
  225. ; ===============================================================================================================================
  226. Func _GUICtrlEdit_EndUpdate($hWnd)
  227. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  228. Return _SendMessage($hWnd, $__EDITCONSTANT_WM_SETREDRAW, True) = 0
  229. EndFunc ;==>_GUICtrlEdit_EndUpdate
  230. ; #FUNCTION# ====================================================================================================================
  231. ; Author ........: Gary Frost
  232. ; Modified.......:
  233. ; ===============================================================================================================================
  234. Func _GUICtrlEdit_FmtLines($hWnd, $bSoftBreak = False)
  235. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  236. Return _SendMessage($hWnd, $EM_FMTLINES, $bSoftBreak)
  237. EndFunc ;==>_GUICtrlEdit_FmtLines
  238. ; #FUNCTION# ====================================================================================================================
  239. ; Author ........: Gary Frost (gafrost)
  240. ; Modified.......:
  241. ; ===============================================================================================================================
  242. Func _GUICtrlEdit_Find($hWnd, $bReplace = False)
  243. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  244. Local $iPos = 0, $iCase, $iOccurance = 0, $iReplacements = 0
  245. Local $aPartsRightEdge[3] = [125, 225, -1]
  246. Local $iOldMode = Opt("GUIOnEventMode", 0)
  247. Local $aSel = _GUICtrlEdit_GetSel($hWnd)
  248. Local $sText = _GUICtrlEdit_GetText($hWnd)
  249. Local $hGuiSearch = GUICreate("Find", 349, 177, -1, -1, BitOR($__UDFGUICONSTANT_WS_CHILD, $__EDITCONSTANT_WS_MINIMIZEBOX, $__EDITCONSTANT_WS_CAPTION, $__EDITCONSTANT_WS_POPUP, $__EDITCONSTANT_WS_SYSMENU))
  250. Local $idStatusBar1 = _GUICtrlStatusBar_Create($hGuiSearch, $aPartsRightEdge)
  251. _GUICtrlStatusBar_SetText($idStatusBar1, "Find: ")
  252. GUISetIcon(@SystemDir & "\shell32.dll", 22, $hGuiSearch)
  253. GUICtrlCreateLabel("Find what:", 9, 10, 53, 16, $__EDITCONSTANT_SS_CENTER)
  254. Local $idInputSearch = GUICtrlCreateInput("", 80, 8, 257, 21)
  255. Local $idLblReplace = GUICtrlCreateLabel("Replace with:", 9, 42, 69, 17, $__EDITCONSTANT_SS_CENTER)
  256. Local $idInputReplace = GUICtrlCreateInput("", 80, 40, 257, 21)
  257. Local $idChkWholeOnly = GUICtrlCreateCheckbox("Match whole word only", 9, 72, 145, 17)
  258. Local $idChkMatchCase = GUICtrlCreateCheckbox("Match case", 9, 96, 145, 17)
  259. Local $idBtnFindNext = GUICtrlCreateButton("Find Next", 168, 72, 161, 21, 0)
  260. Local $idBtnReplace = GUICtrlCreateButton("Replace", 168, 96, 161, 21, 0)
  261. Local $idBtnClose = GUICtrlCreateButton("Close", 104, 130, 161, 21, 0)
  262. If (IsArray($aSel) And $aSel <> $EC_ERR) Then
  263. GUICtrlSetData($idInputSearch, StringMid($sText, $aSel[0] + 1, $aSel[1] - $aSel[0]))
  264. If $aSel[0] <> $aSel[1] Then ; text was selected when function was invoked
  265. $iPos = $aSel[0]
  266. If BitAND(GUICtrlRead($idChkMatchCase), $__EDITCONSTANT_GUI_CHECKED) = $__EDITCONSTANT_GUI_CHECKED Then $iCase = 1
  267. $iOccurance = 1
  268. Local $iTPose
  269. While 1 ; set the current occurance so search starts from here
  270. $iTPose = StringInStr($sText, GUICtrlRead($idInputSearch), $iCase, $iOccurance)
  271. If Not $iTPose Then ; this should never happen, but just in case
  272. $iOccurance = 0
  273. ExitLoop
  274. ElseIf $iTPose = $iPos + 1 Then ; found the occurance
  275. ExitLoop
  276. EndIf
  277. $iOccurance += 1
  278. WEnd
  279. EndIf
  280. _GUICtrlStatusBar_SetText($idStatusBar1, "Find: " & GUICtrlRead($idInputSearch))
  281. EndIf
  282. If $bReplace = False Then
  283. GUICtrlSetState($idLblReplace, $__EDITCONSTANT_GUI_HIDE)
  284. GUICtrlSetState($idInputReplace, $__EDITCONSTANT_GUI_HIDE)
  285. GUICtrlSetState($idBtnReplace, $__EDITCONSTANT_GUI_HIDE)
  286. Else
  287. _GUICtrlStatusBar_SetText($idStatusBar1, "Replacements: " & $iReplacements, 1)
  288. _GUICtrlStatusBar_SetText($idStatusBar1, "With: ", 2)
  289. EndIf
  290. GUISetState(@SW_SHOW)
  291. Local $iMsgFind
  292. While 1
  293. $iMsgFind = GUIGetMsg()
  294. Select
  295. Case $iMsgFind = $__EDITCONSTANT_GUI_EVENT_CLOSE Or $iMsgFind = $idBtnClose
  296. ExitLoop
  297. Case $iMsgFind = $idBtnFindNext
  298. GUICtrlSetState($idBtnFindNext, $__EDITCONSTANT_GUI_DISABLE)
  299. GUICtrlSetCursor($idBtnFindNext, 15)
  300. Sleep(100)
  301. _GUICtrlStatusBar_SetText($idStatusBar1, "Find: " & GUICtrlRead($idInputSearch))
  302. If $bReplace = True Then
  303. _GUICtrlStatusBar_SetText($idStatusBar1, "Find: " & GUICtrlRead($idInputSearch))
  304. _GUICtrlStatusBar_SetText($idStatusBar1, "With: " & GUICtrlRead($idInputReplace), 2)
  305. EndIf
  306. __GUICtrlEdit_FindText($hWnd, $idInputSearch, $idChkMatchCase, $idChkWholeOnly, $iPos, $iOccurance, $iReplacements)
  307. Sleep(100)
  308. GUICtrlSetState($idBtnFindNext, $__EDITCONSTANT_GUI_ENABLE)
  309. GUICtrlSetCursor($idBtnFindNext, 2)
  310. Case $iMsgFind = $idBtnReplace
  311. GUICtrlSetState($idBtnReplace, $__EDITCONSTANT_GUI_DISABLE)
  312. GUICtrlSetCursor($idBtnReplace, 15)
  313. Sleep(100)
  314. _GUICtrlStatusBar_SetText($idStatusBar1, "Find: " & GUICtrlRead($idInputSearch))
  315. _GUICtrlStatusBar_SetText($idStatusBar1, "With: " & GUICtrlRead($idInputReplace), 2)
  316. If $iPos Then
  317. _GUICtrlEdit_ReplaceSel($hWnd, GUICtrlRead($idInputReplace))
  318. $iReplacements += 1
  319. $iOccurance -= 1
  320. _GUICtrlStatusBar_SetText($idStatusBar1, "Replacements: " & $iReplacements, 1)
  321. EndIf
  322. __GUICtrlEdit_FindText($hWnd, $idInputSearch, $idChkMatchCase, $idChkWholeOnly, $iPos, $iOccurance, $iReplacements)
  323. Sleep(100)
  324. GUICtrlSetState($idBtnReplace, $__EDITCONSTANT_GUI_ENABLE)
  325. GUICtrlSetCursor($idBtnReplace, 2)
  326. EndSelect
  327. WEnd
  328. GUIDelete($hGuiSearch)
  329. Opt("GUIOnEventMode", $iOldMode)
  330. EndFunc ;==>_GUICtrlEdit_Find
  331. ; #FUNCTION# ====================================================================================================================
  332. ; Author ........: Guinness
  333. ; Modified.......:
  334. ; ===============================================================================================================================
  335. Func _GUICtrlEdit_GetCueBanner($hWnd)
  336. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  337. Local $tText = DllStructCreate("wchar[4096]")
  338. If _SendMessage($hWnd, $EM_GETCUEBANNER, $tText, 4096, 0, "struct*") <> 1 Then Return SetError(-1, 0, "")
  339. Return _WinAPI_WideCharToMultiByte($tText)
  340. EndFunc ;==>_GUICtrlEdit_GetCueBanner
  341. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  342. ; Name...........: __GUICtrlEdit_FindText
  343. ; Description ...:
  344. ; Syntax.........: __GUICtrlEdit_FindText ( $hWnd, $idInputSearch, $idChkMatchCase, $idChkWholeOnly, ByRef $iPos, ByRef $iOccurance, ByRef $iReplacements )
  345. ; Parameters ....: $hWnd - Handle to the control
  346. ; $idInputSearch - controlID
  347. ; $idChkMatchCase - controlID
  348. ; $idChkWholeOnly - controlID
  349. ; $iPos - position of text found
  350. ; $iOccurance - occurance to find
  351. ; $iReplacements - # of occurances replaced
  352. ; Return values .:
  353. ; Author ........: Gary Frost (gafrost)
  354. ; Modified.......:
  355. ; Remarks .......:
  356. ; Related .......: _GUICtrlEdit_Find
  357. ; Link ..........:
  358. ; Example .......:
  359. ; ===============================================================================================================================
  360. Func __GUICtrlEdit_FindText($hWnd, $idInputSearch, $idChkMatchCase, $idChkWholeOnly, ByRef $iPos, ByRef $iOccurance, ByRef $iReplacements)
  361. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  362. Local $iCase = 0, $iWhole = 0
  363. Local $bExact = False
  364. Local $sFind = GUICtrlRead($idInputSearch)
  365. Local $sText = _GUICtrlEdit_GetText($hWnd)
  366. If BitAND(GUICtrlRead($idChkMatchCase), $__EDITCONSTANT_GUI_CHECKED) = $__EDITCONSTANT_GUI_CHECKED Then $iCase = 1
  367. If BitAND(GUICtrlRead($idChkWholeOnly), $__EDITCONSTANT_GUI_CHECKED) = $__EDITCONSTANT_GUI_CHECKED Then $iWhole = 1
  368. If $sFind <> "" Then
  369. $iOccurance += 1
  370. $iPos = StringInStr($sText, $sFind, $iCase, $iOccurance)
  371. If $iWhole And $iPos Then
  372. Local $s_Compare2 = StringMid($sText, $iPos + StringLen($sFind), 1)
  373. If $iPos = 1 Then
  374. If ($iPos + StringLen($sFind)) - 1 = StringLen($sText) Or _
  375. ($s_Compare2 = " " Or $s_Compare2 = @LF Or $s_Compare2 = @CR Or _
  376. $s_Compare2 = @CRLF Or $s_Compare2 = @TAB) Then $bExact = True
  377. Else
  378. Local $s_Compare1 = StringMid($sText, $iPos - 1, 1)
  379. If ($iPos + StringLen($sFind)) - 1 = StringLen($sText) Then
  380. If ($s_Compare1 = " " Or $s_Compare1 = @LF Or $s_Compare1 = @CR Or _
  381. $s_Compare1 = @CRLF Or $s_Compare1 = @TAB) Then $bExact = True
  382. Else
  383. If ($s_Compare1 = " " Or $s_Compare1 = @LF Or $s_Compare1 = @CR Or _
  384. $s_Compare1 = @CRLF Or $s_Compare1 = @TAB) And _
  385. ($s_Compare2 = " " Or $s_Compare2 = @LF Or $s_Compare2 = @CR Or _
  386. $s_Compare2 = @CRLF Or $s_Compare2 = @TAB) Then $bExact = True
  387. EndIf
  388. EndIf
  389. If $bExact = False Then ; found word, but as part of another word, so search again
  390. __GUICtrlEdit_FindText($hWnd, $idInputSearch, $idChkMatchCase, $idChkWholeOnly, $iPos, $iOccurance, $iReplacements)
  391. Else ; found it
  392. _GUICtrlEdit_SetSel($hWnd, $iPos - 1, ($iPos + StringLen($sFind)) - 1)
  393. _GUICtrlEdit_Scroll($hWnd, $__EDITCONSTANT_SB_SCROLLCARET)
  394. EndIf
  395. ElseIf $iWhole And Not $iPos Then ; no more to find
  396. $iOccurance = 0
  397. MsgBox($MB_SYSTEMMODAL, "Find", "Reached End of document, Can not find the string '" & $sFind & "'")
  398. ElseIf Not $iWhole Then
  399. If Not $iPos Then ; wrap around search and select
  400. $iOccurance = 1
  401. _GUICtrlEdit_SetSel($hWnd, -1, 0)
  402. _GUICtrlEdit_Scroll($hWnd, $__EDITCONSTANT_SB_SCROLLCARET)
  403. $iPos = StringInStr($sText, $sFind, $iCase, $iOccurance)
  404. If Not $iPos Then ; no more to find
  405. $iOccurance = 0
  406. MsgBox($MB_SYSTEMMODAL, "Find", "Reached End of document, Can not find the string '" & $sFind & "'")
  407. Else ; found it
  408. _GUICtrlEdit_SetSel($hWnd, $iPos - 1, ($iPos + StringLen($sFind)) - 1)
  409. _GUICtrlEdit_Scroll($hWnd, $__EDITCONSTANT_SB_SCROLLCARET)
  410. EndIf
  411. Else ; set selection
  412. _GUICtrlEdit_SetSel($hWnd, $iPos - 1, ($iPos + StringLen($sFind)) - 1)
  413. _GUICtrlEdit_Scroll($hWnd, $__EDITCONSTANT_SB_SCROLLCARET)
  414. EndIf
  415. EndIf
  416. EndIf
  417. EndFunc ;==>__GUICtrlEdit_FindText
  418. ; #FUNCTION# ====================================================================================================================
  419. ; Author ........: Gary Frost (gafrost)
  420. ; Modified.......:
  421. ; ===============================================================================================================================
  422. Func _GUICtrlEdit_GetFirstVisibleLine($hWnd)
  423. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  424. Return _SendMessage($hWnd, $EM_GETFIRSTVISIBLELINE)
  425. EndFunc ;==>_GUICtrlEdit_GetFirstVisibleLine
  426. ; #NO_DOC_FUNCTION# =============================================================================================================
  427. ; Name...........: _GUICtrlEdit_GetHandle
  428. ; Description ...: Gets a handle of the memory currently allocated for a multiline edit control's text
  429. ; Syntax.........: _GUICtrlEdit_GetHandle ( $hWnd )
  430. ; Parameters ....: $hWnd - Handle to the control
  431. ; Return values .: Success - Memory handle identifying the buffer that holds the content of the edit control
  432. ; Failure - 0
  433. ; Author ........: Gary Frost (gafrost)
  434. ; Modified.......:
  435. ; Remarks .......: If the function succeeds, the application can access the contents of the edit control by casting the
  436. ; return value to HLOCAL and passing it to LocalLock. LocalLock returns a pointer to a buffer that is a
  437. ; null-terminated array of CHARs or WCHARs, depending on whether an ANSI or Unicode function created the control.
  438. ; For example, if CreateWindowExA was used the buffer is an array of CHARs, but if CreateWindowExW was used the
  439. ; buffer is an array of WCHARs. The application may not change the contents of the buffer. To unlock the buffer,
  440. ; the application calls LocalUnlock before allowing the edit control to receive new messages.
  441. ; +
  442. ; If your application cannot abide by the restrictions imposed by EM_GETHANDLE, use the GetWindowTextLength and
  443. ; GetWindowText functions to copy the contents of the edit control into an application-provided buffer.
  444. ; Related .......: _GUICtrlEdit_SetHandle
  445. ; Link ..........:
  446. ; Example .......:
  447. ; ===============================================================================================================================
  448. Func _GUICtrlEdit_GetHandle($hWnd)
  449. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  450. Return Ptr(_SendMessage($hWnd, $EM_GETHANDLE))
  451. EndFunc ;==>_GUICtrlEdit_GetHandle
  452. ; #NO_DOC_FUNCTION# =============================================================================================================
  453. ; Name...........: _GUICtrlEdit_GetIMEStatus
  454. ; Description ...: Gets a set of status flags that indicate how the edit control interacts with the Input Method Editor (IME)
  455. ; Syntax.........: _GUICtrlEdit_GetIMEStatus ( $hWnd )
  456. ; Parameters ....: $hWnd - Handle to the control
  457. ; Return values .: Success - One or More of the Following Flags
  458. ; |$EIMES_GETCOMPSTRATONCE - The edit control hooks the WM_IME_COMPOSITION message
  459. ; |$EIMES_CANCELCOMPSTRINFOCUS - The edit control cancels the composition string when it receives the WM_SETFOCUS message
  460. ; |$EIMES_COMPLETECOMPSTRKILLFOCUS - The edit control completes the composition string upon receiving the WM_KILLFOCUS message
  461. ; Author ........: Gary Frost (gafrost)
  462. ; Modified.......:
  463. ; Remarks .......:
  464. ; Related .......:
  465. ; Link ..........:
  466. ; Example .......:
  467. ; ===============================================================================================================================
  468. Func _GUICtrlEdit_GetIMEStatus($hWnd)
  469. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  470. Return _SendMessage($hWnd, $EM_GETIMESTATUS, $EMSIS_COMPOSITIONSTRING)
  471. EndFunc ;==>_GUICtrlEdit_GetIMEStatus
  472. ; #FUNCTION# ====================================================================================================================
  473. ; Author ........: Gary Frost (gafrost)
  474. ; Modified.......:
  475. ; ===============================================================================================================================
  476. Func _GUICtrlEdit_GetLimitText($hWnd)
  477. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  478. Return _SendMessage($hWnd, $EM_GETLIMITTEXT)
  479. EndFunc ;==>_GUICtrlEdit_GetLimitText
  480. ; #FUNCTION# ====================================================================================================================
  481. ; Author ........: Gary Frost (gafrost), Jos van der Zande <jdeb at autoitscript com >
  482. ; Modified.......: Gary Frost (gafrost)
  483. ; ===============================================================================================================================
  484. Func _GUICtrlEdit_GetLine($hWnd, $iLine)
  485. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  486. Local $iLength = _GUICtrlEdit_LineLength($hWnd, $iLine)
  487. If $iLength = 0 Then Return ""
  488. Local $tBuffer = DllStructCreate("short Len;wchar Text[" & $iLength & "]")
  489. DllStructSetData($tBuffer, "Len", $iLength + 1)
  490. Local $iRet = _SendMessage($hWnd, $EM_GETLINE, $iLine, $tBuffer, 0, "wparam", "struct*")
  491. If $iRet = 0 Then Return SetError($EC_ERR, $EC_ERR, "")
  492. Local $tText = DllStructCreate("wchar Text[" & $iLength & "]", DllStructGetPtr($tBuffer))
  493. Return DllStructGetData($tText, "Text")
  494. EndFunc ;==>_GUICtrlEdit_GetLine
  495. ; #FUNCTION# ====================================================================================================================
  496. ; Author ........: Gary Frost (gafrost)
  497. ; Modified.......:
  498. ; ===============================================================================================================================
  499. Func _GUICtrlEdit_GetLineCount($hWnd)
  500. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  501. Return _SendMessage($hWnd, $EM_GETLINECOUNT)
  502. EndFunc ;==>_GUICtrlEdit_GetLineCount
  503. ; #FUNCTION# ====================================================================================================================
  504. ; Author ........: Gary Frost (gafrost)
  505. ; Modified.......:
  506. ; ===============================================================================================================================
  507. Func _GUICtrlEdit_GetMargins($hWnd)
  508. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  509. Local $aMargins[2]
  510. Local $iMargins = _SendMessage($hWnd, $EM_GETMARGINS)
  511. $aMargins[0] = _WinAPI_LoWord($iMargins) ; Left Margin
  512. $aMargins[1] = _WinAPI_HiWord($iMargins) ; Right Margin
  513. Return $aMargins
  514. EndFunc ;==>_GUICtrlEdit_GetMargins
  515. ; #FUNCTION# ====================================================================================================================
  516. ; Author ........: Gary Frost (gafrost)
  517. ; Modified.......:
  518. ; ===============================================================================================================================
  519. Func _GUICtrlEdit_GetModify($hWnd)
  520. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  521. Return _SendMessage($hWnd, $EM_GETMODIFY) <> 0
  522. EndFunc ;==>_GUICtrlEdit_GetModify
  523. ; #FUNCTION# ====================================================================================================================
  524. ; Author ........: Gary Frost
  525. ; Modified.......:
  526. ; ===============================================================================================================================
  527. Func _GUICtrlEdit_GetPasswordChar($hWnd)
  528. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  529. Return _SendMessage($hWnd, $EM_GETPASSWORDCHAR)
  530. EndFunc ;==>_GUICtrlEdit_GetPasswordChar
  531. ; #FUNCTION# ====================================================================================================================
  532. ; Author ........: Gary Frost (gafrost)
  533. ; Modified.......:
  534. ; ===============================================================================================================================
  535. Func _GUICtrlEdit_GetRECT($hWnd)
  536. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  537. Local $aRect[4]
  538. Local $tRECT = _GUICtrlEdit_GetRECTEx($hWnd)
  539. $aRect[0] = DllStructGetData($tRECT, "Left")
  540. $aRect[1] = DllStructGetData($tRECT, "Top")
  541. $aRect[2] = DllStructGetData($tRECT, "Right")
  542. $aRect[3] = DllStructGetData($tRECT, "Bottom")
  543. Return $aRect
  544. EndFunc ;==>_GUICtrlEdit_GetRECT
  545. ; #FUNCTION# ====================================================================================================================
  546. ; Author ........: Gary Frost (gafrost)
  547. ; Modified.......:
  548. ; ===============================================================================================================================
  549. Func _GUICtrlEdit_GetRECTEx($hWnd)
  550. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  551. Local $tRECT = DllStructCreate($tagRECT)
  552. _SendMessage($hWnd, $EM_GETRECT, 0, $tRECT, 0, "wparam", "struct*")
  553. Return $tRECT
  554. EndFunc ;==>_GUICtrlEdit_GetRECTEx
  555. ; #FUNCTION# ====================================================================================================================
  556. ; Author ........: Gary Frost (gafrost)
  557. ; Modified.......:
  558. ; ===============================================================================================================================
  559. Func _GUICtrlEdit_GetSel($hWnd)
  560. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  561. Local $aSel[2]
  562. Local $tStart = DllStructCreate("uint Start")
  563. Local $tEnd = DllStructCreate("uint End")
  564. _SendMessage($hWnd, $EM_GETSEL, $tStart, $tEnd, 0, "struct*", "struct*")
  565. $aSel[0] = DllStructGetData($tStart, "Start")
  566. $aSel[1] = DllStructGetData($tEnd, "End")
  567. Return $aSel
  568. EndFunc ;==>_GUICtrlEdit_GetSel
  569. ; #FUNCTION# ====================================================================================================================
  570. ; Author ........: Gary Frost (gafrost)
  571. ; Modified.......:
  572. ; ===============================================================================================================================
  573. Func _GUICtrlEdit_GetText($hWnd)
  574. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  575. Local $iTextLen = _GUICtrlEdit_GetTextLen($hWnd) + 1
  576. Local $tText = DllStructCreate("wchar Text[" & $iTextLen & "]")
  577. _SendMessage($hWnd, $__EDITCONSTANT_WM_GETTEXT, $iTextLen, $tText, 0, "wparam", "struct*")
  578. Return DllStructGetData($tText, "Text")
  579. EndFunc ;==>_GUICtrlEdit_GetText
  580. ; #FUNCTION# ====================================================================================================================
  581. ; Author ........: Gary Frost (gafrost)
  582. ; Modified.......:
  583. ; ===============================================================================================================================
  584. Func _GUICtrlEdit_GetTextLen($hWnd)
  585. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  586. Return _SendMessage($hWnd, $__EDITCONSTANT_WM_GETTEXTLENGTH)
  587. EndFunc ;==>_GUICtrlEdit_GetTextLen
  588. ; #NO_DOC_FUNCTION# =============================================================================================================
  589. ; Name...........: _GUICtrlEdit_GetThumb
  590. ; Description ...: Retrieves the position of the scroll box (thumb) in the vertical scroll
  591. ; Syntax.........: _GUICtrlEdit_GetThumb ( $hWnd )
  592. ; Parameters ....: $hWnd - Handle to the control
  593. ; Return values .: Success - The position of the scroll box
  594. ; Author ........: Gary Frost (gafrost)
  595. ; Modified.......:
  596. ; Remarks .......: I think WM_VSCROLL events probably work better
  597. ; Related .......:
  598. ; Link ..........:
  599. ; Example .......:
  600. ; ===============================================================================================================================
  601. Func _GUICtrlEdit_GetThumb($hWnd)
  602. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  603. Return _SendMessage($hWnd, $EM_GETTHUMB)
  604. EndFunc ;==>_GUICtrlEdit_GetThumb
  605. ; #NO_DOC_FUNCTION# =============================================================================================================
  606. ; Name...........: _GUICtrlEdit_GetWordBreakProc
  607. ; Description ...: Retrieves the address of the current Wordwrap function
  608. ; Syntax.........: _GUICtrlEdit_GetWordBreakProc ( $hWnd )
  609. ; Parameters ....: $hWnd - Handle to the control
  610. ; Return values .: Success - The address of the application-defined Wordwrap function
  611. ; Failure - 0
  612. ; Author ........: Gary Frost (gafrost)
  613. ; Modified.......:
  614. ; Remarks .......:
  615. ; Related .......: _GUICtrlEdit_SetWordBreakProc
  616. ; Link ..........:
  617. ; Example .......:
  618. ; ===============================================================================================================================
  619. Func _GUICtrlEdit_GetWordBreakProc($hWnd)
  620. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  621. Return _SendMessage($hWnd, $EM_GETWORDBREAKPROC)
  622. EndFunc ;==>_GUICtrlEdit_GetWordBreakProc
  623. ; #FUNCTION# ====================================================================================================================
  624. ; Author ........: Gary Frost
  625. ; Modified.......:
  626. ; ===============================================================================================================================
  627. Func _GUICtrlEdit_HideBalloonTip($hWnd)
  628. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  629. Return _SendMessage($hWnd, $EM_HIDEBALLOONTIP) <> 0
  630. EndFunc ;==>_GUICtrlEdit_HideBalloonTip
  631. ; #FUNCTION# ====================================================================================================================
  632. ; Author ........: Gary Frost (gafrost)
  633. ; Modified.......:
  634. ; ===============================================================================================================================
  635. Func _GUICtrlEdit_InsertText($hWnd, $sText, $iIndex = -1)
  636. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  637. If $iIndex = -1 Then
  638. _GUICtrlEdit_AppendText($hWnd, $sText)
  639. Else
  640. _GUICtrlEdit_SetSel($hWnd, $iIndex, $iIndex)
  641. _SendMessage($hWnd, $EM_REPLACESEL, True, $sText, 0, "wparam", "wstr")
  642. EndIf
  643. EndFunc ;==>_GUICtrlEdit_InsertText
  644. ; #FUNCTION# ====================================================================================================================
  645. ; Author ........: Gary Frost (gafrost)
  646. ; Modified.......:
  647. ; ===============================================================================================================================
  648. Func _GUICtrlEdit_LineFromChar($hWnd, $iIndex = -1)
  649. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  650. Return _SendMessage($hWnd, $EM_LINEFROMCHAR, $iIndex)
  651. EndFunc ;==>_GUICtrlEdit_LineFromChar
  652. ; #FUNCTION# ====================================================================================================================
  653. ; Author ........: Gary Frost (gafrost)
  654. ; Modified.......:
  655. ; ===============================================================================================================================
  656. Func _GUICtrlEdit_LineIndex($hWnd, $iIndex = -1)
  657. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  658. Return _SendMessage($hWnd, $EM_LINEINDEX, $iIndex)
  659. EndFunc ;==>_GUICtrlEdit_LineIndex
  660. ; #FUNCTION# ====================================================================================================================
  661. ; Author ........: Gary Frost (gafrost)
  662. ; Modified.......:
  663. ; ===============================================================================================================================
  664. Func _GUICtrlEdit_LineLength($hWnd, $iIndex = -1)
  665. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  666. Local $iCharIndex = _GUICtrlEdit_LineIndex($hWnd, $iIndex)
  667. Return _SendMessage($hWnd, $EM_LINELENGTH, $iCharIndex)
  668. EndFunc ;==>_GUICtrlEdit_LineLength
  669. ; #FUNCTION# ====================================================================================================================
  670. ; Author ........: Gary Frost (gafrost)
  671. ; Modified.......:
  672. ; ===============================================================================================================================
  673. Func _GUICtrlEdit_LineScroll($hWnd, $iHoriz, $iVert)
  674. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  675. Return _SendMessage($hWnd, $EM_LINESCROLL, $iHoriz, $iVert) <> 0
  676. EndFunc ;==>_GUICtrlEdit_LineScroll
  677. ; #FUNCTION# ====================================================================================================================
  678. ; Author ........: Gary Frost (gafrost)
  679. ; Modified.......:
  680. ; ===============================================================================================================================
  681. Func _GUICtrlEdit_PosFromChar($hWnd, $iIndex)
  682. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  683. Local $aCoord[2]
  684. Local $iRet = _SendMessage($hWnd, $EM_POSFROMCHAR, $iIndex)
  685. $aCoord[0] = _WinAPI_LoWord($iRet)
  686. $aCoord[1] = _WinAPI_HiWord($iRet)
  687. Return $aCoord
  688. EndFunc ;==>_GUICtrlEdit_PosFromChar
  689. ; #FUNCTION# ====================================================================================================================
  690. ; Author ........: Gary Frost (gafrost)
  691. ; Modified.......:
  692. ; ===============================================================================================================================
  693. Func _GUICtrlEdit_ReplaceSel($hWnd, $sText, $bUndo = True)
  694. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  695. _SendMessage($hWnd, $EM_REPLACESEL, $bUndo, $sText, 0, "wparam", "wstr")
  696. EndFunc ;==>_GUICtrlEdit_ReplaceSel
  697. ; #FUNCTION# ====================================================================================================================
  698. ; Author ........: Gary Frost (gafrost)
  699. ; Modified.......:
  700. ; ===============================================================================================================================
  701. Func _GUICtrlEdit_Scroll($hWnd, $iDirection)
  702. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  703. If BitAND($iDirection, $__EDITCONSTANT_SB_LINEDOWN) <> $__EDITCONSTANT_SB_LINEDOWN And _
  704. BitAND($iDirection, $__EDITCONSTANT_SB_LINEUP) <> $__EDITCONSTANT_SB_LINEUP And _
  705. BitAND($iDirection, $__EDITCONSTANT_SB_PAGEDOWN) <> $__EDITCONSTANT_SB_PAGEDOWN And _
  706. BitAND($iDirection, $__EDITCONSTANT_SB_PAGEUP) <> $__EDITCONSTANT_SB_PAGEUP And _
  707. BitAND($iDirection, $__EDITCONSTANT_SB_SCROLLCARET) <> $__EDITCONSTANT_SB_SCROLLCARET Then Return 0
  708. If $iDirection == $__EDITCONSTANT_SB_SCROLLCARET Then
  709. Return _SendMessage($hWnd, $EM_SCROLLCARET)
  710. Else
  711. Return _SendMessage($hWnd, $EM_SCROLL, $iDirection)
  712. EndIf
  713. EndFunc ;==>_GUICtrlEdit_Scroll
  714. ; #FUNCTION# ====================================================================================================================
  715. ; Author ........: Guinness
  716. ; Modified.......:
  717. ; ===============================================================================================================================
  718. Func _GUICtrlEdit_SetCueBanner($hWnd, $sText, $bOnFocus = False)
  719. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  720. Local $tText = _WinAPI_MultiByteToWideChar($sText)
  721. Return _SendMessage($hWnd, $EM_SETCUEBANNER, $bOnFocus, $tText, 0, "wparam", "struct*") = 1
  722. EndFunc ;==>_GUICtrlEdit_SetCueBanner
  723. ; #NO_DOC_FUNCTION# =============================================================================================================
  724. ; Name...........: _GUICtrlEdit_SetHandle
  725. ; Description ...: Sets the handle of the memory that will be used
  726. ; Syntax.........: _GUICtrlEdit_SetHandle ( $hWnd, $hMemory )
  727. ; Parameters ....: $hWnd - Handle to the control
  728. ; $hMemory - A handle to the memory buffer the edit control uses to store the currently displayed text
  729. ; +instead of allocating its own memory
  730. ; Return values .:
  731. ; Author ........: Gary Frost (gafrost)
  732. ; Modified.......:
  733. ; Remarks .......:
  734. ; Related .......: _GUICtrlEdit_GetHandle
  735. ; Link ..........:
  736. ; Example .......:
  737. ; ===============================================================================================================================
  738. Func _GUICtrlEdit_SetHandle($hWnd, $hMemory)
  739. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  740. _SendMessage($hWnd, $EM_SETHANDLE, $hMemory, 0, 0, "handle")
  741. EndFunc ;==>_GUICtrlEdit_SetHandle
  742. ; #NO_DOC_FUNCTION# =============================================================================================================
  743. ; Name...........: _GUICtrlEdit_SetIMEStatus
  744. ; Description ...: Sets the status flags that determine how an edit control interacts with the Input Method Editor (IME)
  745. ; Syntax.........: _GUICtrlEdit_SetIMEStatus ( $hWnd, $iComposition )
  746. ; Parameters ....: $hWnd - Handle to the control
  747. ; $iComposition - One or more of the following:
  748. ; |$EIMES_GETCOMPSTRATONCE - The edit control hooks the WM_IME_COMPOSITION message
  749. ; |$EIMES_CANCELCOMPSTRINFOCUS - The edit control cancels the composition string when it receives the WM_SETFOCUS message
  750. ; |$EIMES_COMPLETECOMPSTRKILLFOCUS - The edit control completes the composition string upon receiving the WM_KILLFOCUS message
  751. ; Return values .: Success - the previous value of the $iComposition parameter
  752. ; Author ........: Gary Frost (gafrost)
  753. ; Modified.......:
  754. ; Remarks .......:
  755. ; Related .......:
  756. ; Link ..........:
  757. ; Example .......:
  758. ; ===============================================================================================================================
  759. Func _GUICtrlEdit_SetIMEStatus($hWnd, $iComposition)
  760. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  761. Return _SendMessage($hWnd, $EM_SETIMESTATUS, $EMSIS_COMPOSITIONSTRING, $iComposition)
  762. EndFunc ;==>_GUICtrlEdit_SetIMEStatus
  763. ; #FUNCTION# ====================================================================================================================
  764. ; Author ........: Gary Frost (gafrost)
  765. ; Modified.......:
  766. ; ===============================================================================================================================
  767. Func _GUICtrlEdit_SetLimitText($hWnd, $iLimit)
  768. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  769. _SendMessage($hWnd, $EM_SETLIMITTEXT, $iLimit)
  770. EndFunc ;==>_GUICtrlEdit_SetLimitText
  771. ; #FUNCTION# ====================================================================================================================
  772. ; Author ........: Gary Frost (gafrost)
  773. ; Modified.......:
  774. ; ===============================================================================================================================
  775. Func _GUICtrlEdit_SetMargins($hWnd, $iMargin = 0x1, $iLeft = 0xFFFF, $iRight = 0xFFFF)
  776. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  777. _SendMessage($hWnd, $EM_SETMARGINS, $iMargin, _WinAPI_MakeLong($iLeft, $iRight))
  778. EndFunc ;==>_GUICtrlEdit_SetMargins
  779. ; #FUNCTION# ====================================================================================================================
  780. ; Author ........: Gary Frost (gafrost)
  781. ; Modified.......:
  782. ; ===============================================================================================================================
  783. Func _GUICtrlEdit_SetModify($hWnd, $bModified)
  784. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  785. _SendMessage($hWnd, $EM_SETMODIFY, $bModified)
  786. EndFunc ;==>_GUICtrlEdit_SetModify
  787. ; #FUNCTION# ====================================================================================================================
  788. ; Author ........: Gary Frost
  789. ; Modified.......:
  790. ; ===============================================================================================================================
  791. Func _GUICtrlEdit_SetPasswordChar($hWnd, $sDisplayChar = "0")
  792. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  793. $sDisplayChar = StringLeft($sDisplayChar, 1)
  794. If Asc($sDisplayChar) = 48 Then
  795. _SendMessage($hWnd, $EM_SETPASSWORDCHAR)
  796. Else
  797. _SendMessage($hWnd, $EM_SETPASSWORDCHAR, Asc($sDisplayChar))
  798. EndIf
  799. EndFunc ;==>_GUICtrlEdit_SetPasswordChar
  800. ; #FUNCTION# ====================================================================================================================
  801. ; Author ........: Gary Frost (gafrost)
  802. ; Modified.......:
  803. ; ===============================================================================================================================
  804. Func _GUICtrlEdit_SetReadOnly($hWnd, $bReadOnly)
  805. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  806. Return _SendMessage($hWnd, $EM_SETREADONLY, $bReadOnly) <> 0
  807. EndFunc ;==>_GUICtrlEdit_SetReadOnly
  808. ; #FUNCTION# ====================================================================================================================
  809. ; Author ........: Gary Frost (gafrost)
  810. ; Modified.......:
  811. ; ===============================================================================================================================
  812. Func _GUICtrlEdit_SetRECT($hWnd, $aRect)
  813. Local $tRECT = DllStructCreate($tagRECT)
  814. DllStructSetData($tRECT, "Left", $aRect[0])
  815. DllStructSetData($tRECT, "Top", $aRect[1])
  816. DllStructSetData($tRECT, "Right", $aRect[2])
  817. DllStructSetData($tRECT, "Bottom", $aRect[3])
  818. _GUICtrlEdit_SetRECTEx($hWnd, $tRECT)
  819. EndFunc ;==>_GUICtrlEdit_SetRECT
  820. ; #FUNCTION# ====================================================================================================================
  821. ; Author ........: Gary Frost (gafrost)
  822. ; Modified.......:
  823. ; ===============================================================================================================================
  824. Func _GUICtrlEdit_SetRECTEx($hWnd, $tRECT)
  825. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  826. _SendMessage($hWnd, $EM_SETRECT, 0, $tRECT, 0, "wparam", "struct*")
  827. EndFunc ;==>_GUICtrlEdit_SetRECTEx
  828. ; #FUNCTION# ====================================================================================================================
  829. ; Author ........: Gary Frost (gafrost)
  830. ; Modified.......:
  831. ; ===============================================================================================================================
  832. Func _GUICtrlEdit_SetRECTNP($hWnd, $aRect)
  833. Local $tRECT = DllStructCreate($tagRECT)
  834. DllStructSetData($tRECT, "Left", $aRect[0])
  835. DllStructSetData($tRECT, "Top", $aRect[1])
  836. DllStructSetData($tRECT, "Right", $aRect[2])
  837. DllStructSetData($tRECT, "Bottom", $aRect[3])
  838. _GUICtrlEdit_SetRectNPEx($hWnd, $tRECT)
  839. EndFunc ;==>_GUICtrlEdit_SetRECTNP
  840. ; #FUNCTION# ====================================================================================================================
  841. ; Author ........: Gary Frost (gafrost)
  842. ; Modified.......:
  843. ; ===============================================================================================================================
  844. Func _GUICtrlEdit_SetRectNPEx($hWnd, $tRECT)
  845. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  846. _SendMessage($hWnd, $EM_SETRECTNP, 0, $tRECT, 0, "wparam", "struct*")
  847. EndFunc ;==>_GUICtrlEdit_SetRectNPEx
  848. ; #FUNCTION# ====================================================================================================================
  849. ; Author ........: Gary Frost (gafrost)
  850. ; Modified.......:
  851. ; ===============================================================================================================================
  852. Func _GUICtrlEdit_SetSel($hWnd, $iStart, $iEnd)
  853. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  854. _SendMessage($hWnd, $EM_SETSEL, $iStart, $iEnd)
  855. EndFunc ;==>_GUICtrlEdit_SetSel
  856. ; #FUNCTION# ====================================================================================================================
  857. ; Author ........: Gary Frost (gafrost)
  858. ; Modified.......:
  859. ; ===============================================================================================================================
  860. Func _GUICtrlEdit_SetTabStops($hWnd, $aTabStops)
  861. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  862. If Not IsArray($aTabStops) Then Return SetError(-1, -1, False)
  863. Local $sTabStops = ""
  864. Local $iNumTabStops = UBound($aTabStops)
  865. For $x = 0 To $iNumTabStops - 1
  866. $sTabStops &= "int;"
  867. Next
  868. $sTabStops = StringTrimRight($sTabStops, 1)
  869. Local $tTabStops = DllStructCreate($sTabStops)
  870. For $x = 0 To $iNumTabStops - 1
  871. DllStructSetData($tTabStops, $x + 1, $aTabStops[$x])
  872. Next
  873. Local $iRet = _SendMessage($hWnd, $EM_SETTABSTOPS, $iNumTabStops, $tTabStops, 0, "wparam", "struct*") <> 0
  874. _WinAPI_InvalidateRect($hWnd)
  875. Return $iRet
  876. EndFunc ;==>_GUICtrlEdit_SetTabStops
  877. ; #FUNCTION# ====================================================================================================================
  878. ; Author ........: Gary Frost (gafrost)
  879. ; Modified.......:
  880. ; ===============================================================================================================================
  881. Func _GUICtrlEdit_SetText($hWnd, $sText)
  882. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  883. _SendMessage($hWnd, $__EDITCONSTANT_WM_SETTEXT, 0, $sText, 0, "wparam", "wstr")
  884. EndFunc ;==>_GUICtrlEdit_SetText
  885. ; #NO_DOC_FUNCTION# =============================================================================================================
  886. ; Name...........: _GUICtrlEdit_SetWordBreakProc
  887. ; Description ...: Replaces an edit control's default Wordwrap function with an application-defined Wordwrap function
  888. ; Syntax.........: _GUICtrlEdit_SetWordBreakProc ( $hWnd, $iAddressFunc )
  889. ; Parameters ....: $hWnd - Handle to the control
  890. ; $iAddressFunc - The address of the application-defined Wordwrap function
  891. ; Return values .:
  892. ; Author ........: Gary Frost (gafrost)
  893. ; Modified.......:
  894. ; Remarks .......:
  895. ; Related .......: _GUICtrlEdit_GetWordBreakProc
  896. ; Link ..........:
  897. ; Example .......:
  898. ; ===============================================================================================================================
  899. Func _GUICtrlEdit_SetWordBreakProc($hWnd, $iAddressFunc)
  900. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  901. _SendMessage($hWnd, $EM_SETWORDBREAKPROC, 0, $iAddressFunc)
  902. EndFunc ;==>_GUICtrlEdit_SetWordBreakProc
  903. ; #FUNCTION# ====================================================================================================================
  904. ; Author ........: Gary Frost
  905. ; Modified.......:
  906. ; ===============================================================================================================================
  907. Func _GUICtrlEdit_ShowBalloonTip($hWnd, $sTitle, $sText, $iIcon)
  908. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  909. Local $tTitle = _WinAPI_MultiByteToWideChar($sTitle)
  910. Local $tText = _WinAPI_MultiByteToWideChar($sText)
  911. Local $tTT = DllStructCreate($__tagEDITBALLOONTIP)
  912. DllStructSetData($tTT, "Size", DllStructGetSize($tTT))
  913. DllStructSetData($tTT, "Title", DllStructGetPtr($tTitle))
  914. DllStructSetData($tTT, "Text", DllStructGetPtr($tText))
  915. DllStructSetData($tTT, "Icon", $iIcon)
  916. Return _SendMessage($hWnd, $EM_SHOWBALLOONTIP, 0, $tTT, 0, "wparam", "struct*") <> 0
  917. EndFunc ;==>_GUICtrlEdit_ShowBalloonTip
  918. ; #FUNCTION# ====================================================================================================================
  919. ; Author ........: Gary Frost (gafrost)
  920. ; Modified.......:
  921. ; ===============================================================================================================================
  922. Func _GUICtrlEdit_Undo($hWnd)
  923. If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd)
  924. Return _SendMessage($hWnd, $EM_UNDO) <> 0
  925. EndFunc ;==>_GUICtrlEdit_Undo