GuiRichEdit_En.au3 201 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778
  1. #include-once
  2. #include "Clipboard.au3"
  3. #include "EditConstants.au3"
  4. #include "FileConstants.au3"
  5. #include "RichEditConstants.au3"
  6. #include "SendMessage.au3"
  7. #include "StructureConstants.au3"
  8. #include "UDFGlobalID.au3"
  9. #include "WinAPIConv.au3"
  10. #include "WinAPIHobj.au3"
  11. #include "WinAPISysInternals.au3"
  12. ; #INDEX# =======================================================================================================================
  13. ; Title .........: Rich Edit
  14. ; AutoIt Version : 3.3.14.5
  15. ; Language ......: English
  16. ; Description ...: Programmer-friendly Rich Edit control
  17. ; Author(s) .....: GaryFrost, grham, Prog@ndy, KIP, c.haslam
  18. ; OLE stuff .....: example from http://www.powerbasic.com/support/pbforums/showpost.php?p=294112&postcount=7
  19. ; ===============================================================================================================================
  20. ; #VARIABLES# ===================================================================================================================
  21. Global $__g_sRTFClassName, $__g_sRTFVersion, $__g_iRTFTwipsPeSpaceUnit = 1440 ; inches
  22. Global $__g_sGRE_CF_RTF, $__g_sGRE_CF_RETEXTOBJ
  23. Global $__g_pGRC_StreamFromFileCallback = DllCallbackRegister("__GCR_StreamFromFileCallback", "dword", "long_ptr;ptr;long;ptr")
  24. Global $__g_pGRC_StreamFromVarCallback = DllCallbackRegister("__GCR_StreamFromVarCallback", "dword", "long_ptr;ptr;long;ptr")
  25. Global $__g_pGRC_StreamToFileCallback = DllCallbackRegister("__GCR_StreamToFileCallback", "dword", "long_ptr;ptr;long;ptr")
  26. Global $__g_pGRC_StreamToVarCallback = DllCallbackRegister("__GCR_StreamToVarCallback", "dword", "long_ptr;ptr;long;ptr")
  27. Global $__g_pGRC_sStreamVar
  28. Global $__g_hRELastWnd
  29. ; Functions translated from http://www.powerbasic.com/support/pbforums/showpost.php?p=294112&postcount=7
  30. ; by Prog@ndy
  31. Global $__g_tObj_RichComObject = DllStructCreate("ptr pIntf; dword Refcount")
  32. Global $__g_tCall_RichCom, $__g_pObj_RichCom
  33. Global $__g_hLib_RichCom_OLE32 = DllOpen("OLE32.DLL")
  34. Global $__g_pRichCom_Object_QueryInterface = DllCallbackRegister("__RichCom_Object_QueryInterface", "long", "ptr;dword;dword")
  35. Global $__g_pRichCom_Object_AddRef = DllCallbackRegister("__RichCom_Object_AddRef", "long", "ptr")
  36. Global $__g_pRichCom_Object_Release = DllCallbackRegister("__RichCom_Object_Release", "long", "ptr")
  37. Global $__g_pRichCom_Object_GetNewStorage = DllCallbackRegister("__RichCom_Object_GetNewStorage", "long", "ptr;ptr")
  38. Global $__g_pRichCom_Object_GetInPlaceContext = DllCallbackRegister("__RichCom_Object_GetInPlaceContext", "long", "ptr;dword;dword;dword")
  39. Global $__g_pRichCom_Object_ShowContainerUI = DllCallbackRegister("__RichCom_Object_ShowContainerUI", "long", "ptr;long")
  40. Global $__g_pRichCom_Object_QueryInsertObject = DllCallbackRegister("__RichCom_Object_QueryInsertObject", "long", "ptr;dword;ptr;long")
  41. Global $__g_pRichCom_Object_DeleteObject = DllCallbackRegister("__RichCom_Object_DeleteObject", "long", "ptr;ptr")
  42. Global $__g_pRichCom_Object_QueryAcceptData = DllCallbackRegister("__RichCom_Object_QueryAcceptData", "long", "ptr;ptr;dword;dword;dword;ptr")
  43. Global $__g_pRichCom_Object_ContextSensitiveHelp = DllCallbackRegister("__RichCom_Object_ContextSensitiveHelp", "long", "ptr;long")
  44. Global $__g_pRichCom_Object_GetClipboardData = DllCallbackRegister("__RichCom_Object_GetClipboardData", "long", "ptr;ptr;dword;ptr")
  45. Global $__g_pRichCom_Object_GetDragDropEffect = DllCallbackRegister("__RichCom_Object_GetDragDropEffect", "long", "ptr;dword;dword;dword")
  46. Global $__g_pRichCom_Object_GetContextMenu = DllCallbackRegister("__RichCom_Object_GetContextMenu", "long", "ptr;short;ptr;ptr;ptr")
  47. ; ===============================================================================================================================
  48. ; #CONSTANTS# ===================================================================================================================
  49. Global Const $__RICHEDITCONSTANT_SB_LINEDOWN = 1
  50. Global Const $__RICHEDITCONSTANT_SB_LINEUP = 0
  51. Global Const $__RICHEDITCONSTANT_SB_PAGEDOWN = 3
  52. Global Const $__RICHEDITCONSTANT_SB_PAGEUP = 2
  53. Global Const $__RICHEDITCONSTANT_WM_COPY = 0x00000301
  54. Global Const $__RICHEDITCONSTANT_WM_SETFONT = 0x0030
  55. Global Const $__RICHEDITCONSTANT_WM_CUT = 0x00000300
  56. Global Const $__RICHEDITCONSTANT_WM_PASTE = 0x00000302
  57. Global Const $__RICHEDITCONSTANT_WM_SETREDRAW = 0x000B
  58. Global Const $__RICHEDITCONSTANT_COLOR_WINDOWTEXT = 8
  59. Global Const $_GCR_S_OK = 0
  60. Global Const $_GCR_E_NOTIMPL = 0x80004001
  61. Global Const $_GCR_E_INVALIDARG = 0x80070057
  62. ; ===============================================================================================================================
  63. ; #CURRENT# =====================================================================================================================
  64. ; _GUICtrlRichEdit_AppendText
  65. ; _GUICtrlRichEdit_AutoDetectURL
  66. ; _GUICtrlRichEdit_CanPaste
  67. ; _GUICtrlRichEdit_CanPasteSpecial
  68. ; _GUICtrlRichEdit_CanRedo
  69. ; _GUICtrlRichEdit_CanUndo
  70. ; _GUICtrlRichEdit_ChangeFontSize
  71. ; _GUICtrlRichEdit_Copy
  72. ; _GUICtrlRichEdit_Create
  73. ; _GUICtrlRichEdit_Cut
  74. ; _GUICtrlRichEdit_Deselect
  75. ; _GUICtrlRichEdit_Destroy
  76. ; _GUICtrlRichEdit_EmptyUndoBuffer
  77. ; _GUICtrlRichEdit_FindText
  78. ; _GUICtrlRichEdit_FindTextInRange
  79. ; _GUICtrlRichEdit_GetCharAttributes
  80. ; _GUICtrlRichEdit_GetCharBkColor
  81. ; _GUICtrlRichEdit_GetCharColor
  82. ; _GUICtrlRichEdit_GetCharPosFromXY
  83. ; _GUICtrlRichEdit_GetCharPosOfNextWord
  84. ; _GUICtrlRichEdit_GetCharPosOfPreviousWord
  85. ; _GUICtrlRichEdit_GetCharWordBreakInfo
  86. ; _GUICtrlRichEdit_GetBkColor
  87. ; _GUICtrlRichEdit_GetText
  88. ; _GUICtrlRichEdit_GetTextLength
  89. ; _GUICtrlRichEdit_GetZoom
  90. ; _GUICtrlRichEdit_GetFirstCharPosOnLine
  91. ; _GUICtrlRichEdit_GetFont
  92. ; _GUICtrlRichEdit_GetRECT
  93. ; _GUICtrlRichEdit_GetLineCount
  94. ; _GUICtrlRichEdit_GetLineLength
  95. ; _GUICtrlRichEdit_GetLineNumberFromCharPos
  96. ; _GUICtrlRichEdit_GetNextRedo
  97. ; _GUICtrlRichEdit_GetNextUndo
  98. ; _GUICtrlRichEdit_GetNumberOfFirstVisibleLine
  99. ; _GUICtrlRichEdit_GetParaAlignment
  100. ; _GUICtrlRichEdit_GetParaAttributes
  101. ; _GUICtrlRichEdit_GetParaBorder
  102. ; _GUICtrlRichEdit_GetParaIndents
  103. ; _GUICtrlRichEdit_GetParaNumbering
  104. ; _GUICtrlRichEdit_GetParaShading
  105. ; _GUICtrlRichEdit_GetParaSpacing
  106. ; _GUICtrlRichEdit_GetParaTabStops
  107. ; _GUICtrlRichEdit_GetPasswordChar
  108. ; _GUICtrlRichEdit_GetScrollPos
  109. ; _GUICtrlRichEdit_GetSel
  110. ; _GUICtrlRichEdit_GetSelAA
  111. ; _GUICtrlRichEdit_GetSelText
  112. ; _GUICtrlRichEdit_GetSpaceUnit
  113. ; _GUICtrlRichEdit_GetTextInLine
  114. ; _GUICtrlRichEdit_GetTextInRange
  115. ; _GUICtrlRichEdit_GetVersion
  116. ; _GUICtrlRichEdit_GetXYFromCharPos
  117. ; _GUICtrlRichEdit_GotoCharPos
  118. ; _GUICtrlRichEdit_HideSelection
  119. ; _GUICtrlRichEdit_InsertText
  120. ; _GUICtrlRichEdit_IsModified
  121. ; _GUICtrlRichEdit_IsTextSelected
  122. ; _GUICtrlRichEdit_Paste
  123. ; _GUICtrlRichEdit_PasteSpecial
  124. ; _GUICtrlRichEdit_PauseRedraw
  125. ; _GUICtrlRichEdit_Redo
  126. ; _GUICtrlRichEdit_ReplaceText
  127. ; _GUICtrlRichEdit_ResumeRedraw
  128. ; _GUICtrlRichEdit_ScrollLineOrPage
  129. ; _GUICtrlRichEdit_ScrollLines
  130. ; _GUICtrlRichEdit_ScrollToCaret
  131. ; _GUICtrlRichEdit_SetCharAttributes
  132. ; _GUICtrlRichEdit_SetCharBkColor
  133. ; _GUICtrlRichEdit_SetCharColor
  134. ; _GUICtrlRichEdit_SetBkColor
  135. ; _GUICtrlRichEdit_SetLimitOnText
  136. ; _GUICtrlRichEdit_SetTabStops
  137. ; _GUICtrlRichEdit_SetZoom
  138. ; _GUICtrlRichEdit_SetEventMask
  139. ; _GUICtrlRichEdit_SetFont
  140. ; _GUICtrlRichEdit_SetRECT
  141. ; _GUICtrlRichEdit_SetModified
  142. ; _GUICtrlRichEdit_SetParaAlignment
  143. ; _GUICtrlRichEdit_SetParaAttributes
  144. ; _GUICtrlRichEdit_SetParaBorder
  145. ; _GUICtrlRichEdit_SetParaIndents
  146. ; _GUICtrlRichEdit_SetParaNumbering
  147. ; _GUICtrlRichEdit_SetParaShading
  148. ; _GUICtrlRichEdit_SetParaSpacing
  149. ; _GUICtrlRichEdit_SetParaTabStops
  150. ; _GUICtrlRichEdit_SetPasswordChar
  151. ; _GUICtrlRichEdit_SetReadOnly
  152. ; _GUICtrlRichEdit_SetScrollPos
  153. ; _GUICtrlRichEdit_SetSel
  154. ; _GUICtrlRichEdit_SetSpaceUnit
  155. ; _GUICtrlRichEdit_SetText
  156. ; _GUICtrlRichEdit_SetUndoLimit
  157. ; _GUICtrlRichEdit_StreamFromFile
  158. ; _GUICtrlRichEdit_StreamFromVar
  159. ; _GUICtrlRichEdit_StreamToFile
  160. ; _GUICtrlRichEdit_StreamToVar
  161. ; _GUICtrlRichEdit_Undo
  162. ; ===============================================================================================================================
  163. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  164. ; $tagEDITSTREAM
  165. ; $tagBIDIOPTIONS
  166. ; $tagCHARFORMAT
  167. ; $tagCHARFORMAT2
  168. ; $tagCHARRANGE
  169. ; $tagFINDTEXT
  170. ; $tagFINDTEXTEX
  171. ; $tagGETTEXTEX
  172. ; $tagGETTEXTLENGTHEX
  173. ; $tagPARAFORMAT
  174. ; $tagPARAFORMAT2
  175. ; $tagSETTEXTEX
  176. ; $tagTEXTRANGE
  177. ; $tagMSGFILTER
  178. ; $tagENLINK
  179. ; __GCR_ConvertRomanToNumber
  180. ; __GCR_ConvertTwipsToSpaceUnit
  181. ; __GCR_GetParaScopeChar
  182. ; __GCR_Init
  183. ; __GCR_IsNumeric
  184. ; __GCR_ParseParaNumberingStyle
  185. ; __GCR_SendGetCharFormatMessage
  186. ; __GCR_SendGetParaFormatMessage
  187. ; __GCR_SetOLECallback
  188. ; __GCR_StreamFromFileCallback
  189. ; __GCR_StreamFromVarCallback
  190. ; __GCR_StreamToFileCallback
  191. ; __GCR_StreamToVarCallback
  192. ; __RichCom_Object_AddRef
  193. ; __RichCom_Object_ContextSensitiveHelp
  194. ; __RichCom_Object_DeleteObject
  195. ; __RichCom_Object_GetClipboardData
  196. ; __RichCom_Object_GetContextMenu
  197. ; __RichCom_Object_GetDragDropEffect
  198. ; __RichCom_Object_GetInPlaceContext
  199. ; __RichCom_Object_GetNewStorage
  200. ; __RichCom_Object_QueryAcceptData
  201. ; __RichCom_Object_QueryInsertObject
  202. ; __RichCom_Object_QueryInterface
  203. ; __RichCom_Object_Release
  204. ; __RichCom_Object_ShowContainerUI
  205. ; ===============================================================================================================================
  206. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  207. ; Name...........: $tagEDITSTREAM
  208. ; Description ...: Contains information that an application passes to a rich edit control in a EM_STREAMIN or EM_STREAMOUT message
  209. ; Fields ........: dwCookie - Specifies an application-defined value that the rich edit control passes to the EditStreamCallback callback function specified by the pfnCallback member
  210. ; dwError - Indicates the results of the stream-in (read) or stream-out (write) operation
  211. ; pfnCallback - Pointer to an EditStreamCallback function
  212. ; Author ........: Gary Frost (gafrost)
  213. ; Remarks .......:
  214. ; ===============================================================================================================================
  215. Global Const $tagEDITSTREAM = "align 4;dword_ptr dwCookie;dword dwError;ptr pfnCallback"
  216. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  217. ; Name...........: $tagBIDIOPTIONS
  218. ; Description ...: Contains bidirectional information about a rich edit control
  219. ; Fields ........: cbSize - Specifies the size, in bytes, of the structure
  220. ; wMask - A set of mask bits that determine which of the wEffects flags will be set to 1 or 0 by the rich edit control. This approach eliminates the need to read the effects flags before changing them.
  221. ; |Obsolete bits are valid only for the bidirectional version of Rich Edit 1.0.
  222. ; | $BOM_DEFPARADIR - Default paragraph direction—implies alignment (obsolete).
  223. ; | $BOM_PLAINTEXT - Use plain text layout (obsolete).
  224. ; | $BOM_NEUTRALOVERRIDE - Override neutral layout.
  225. ; | $BOM_CONTEXTREADING - Context reading order.
  226. ; | $BOM_CONTEXTALIGNMENT - Context alignment.
  227. ; | $BOM_LEGACYBIDICLASS - Treatment of plus, minus, and slash characters in right-to-left (LTR) or bidirectional text.
  228. ; wEffects - A set of flags that indicate the desired or current state of the effects flags. Obsolete bits are valid only for the bidirectional version of Rich Edit 1.0.
  229. ; |Obsolete bits are valid only for the bidirectional version of Rich Edit 1.0.
  230. ; | $BOE_RTLDIR - Default paragraph direction—implies alignment (obsolete).
  231. ; | $BOE_PLAINTEXT - Uses plain text layout (obsolete).
  232. ; | $BOE_NEUTRALOVERRIDE - Overrides neutral layout.
  233. ; | $BOE_CONTEXTREADING - Context reading order.
  234. ; | $BOE_CONTEXTALIGNMENT - Context alignment.
  235. ; | $BOE_LEGACYBIDICLASS - Causes the plus and minus characters to be treated as neutral characters with no implied direction. Also causes the slash character to be treated as a common separator.
  236. ; Author ........: Gary Frost (gafrost)
  237. ; Remarks .......:
  238. ; ===============================================================================================================================
  239. Global Const $tagBIDIOPTIONS = "uint cbSize;word wMask;word wEffects"
  240. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  241. ; Name...........: $tagCHARFORMAT
  242. ; Description ...: Contains information about character formatting in a rich edit control
  243. ; Fields ........: cbSize - Size in bytes of the specified structure
  244. ; dwMask - Members containing valid information or attributes to set. This member can be zero, one, or more than one of the following values.
  245. ; | $CFM_BOLD - The $CFE_BOLD value of the dwEffects member is valid.
  246. ; | $CFM_CHARSET - The bCharSet member is valid.
  247. ; | $CFM_COLOR - The crTextColor member and the $CFE_AUTOCOLOR value of the dwEffects member are valid.
  248. ; | $CFM_FACE - The szFaceName member is valid.
  249. ; | $CFM_ITALIC - The $CFE_ITALIC value of the dwEffects member is valid.
  250. ; | $CFM_OFFSET - The yOffset member is valid.
  251. ; | $CFM_PROTECTED - The $CFE_PROTECTED value of the dwEffects member is valid.
  252. ; | $CFM_SIZE - The yHeight member is valid.
  253. ; | $CFM_STRIKEOUT - The $CFE_STRIKEOUT value of the dwEffects member is valid.
  254. ; | $CFM_UNDERLINE - The $CFE_UNDERLINE value of the dwEffects member is valid.
  255. ; dwEffects - Character effects. This member can be a combination of the following values.
  256. ; | $CFE_AUTOCOLOR - The text color is the return value of GetSysColor(COLOR_WINDOWTEXT).
  257. ; | $CFE_BOLD - Characters are bold.
  258. ; | $CFE_DISABLED - RichEdit 2.0 and later: Characters are displayed with a shadow that is offset by 3/4 point or one pixel, whichever is larger.
  259. ; | $CFE_ITALIC - Characters are italic.
  260. ; | $CFE_STRIKEOUT - Characters are struck.
  261. ; | $CFE_UNDERLINE - Characters are underlined.
  262. ; | $CFE_PROTECTED - Characters are protected; an attempt to modify them will cause an EN_PROTECTED notification message.
  263. ; yHeight - Character height, in twips (1/1440 of an inch or 1/20 of a printer's point).
  264. ; yOffset - Character offset, in twips, from the baseline. If the value of this member is positive, the character is a superscript; if it is negative, the character is a subscript.
  265. ; crCharColor - Text color. This member is ignored if the $CFE_AUTOCOLOR character effect is specified. To generate a COLORREF, use the RGB macro.
  266. ; bCharSet - Character set value. The bCharSet member can be one of the values specified for the lfCharSet member of the LOGFONT structure. Rich Edit 3.0 may override this value if it is invalid for the target characters.
  267. ; bPitchAndFamily - Font family and pitch. This member is the same as the lfPitchAndFamily member of the LOGFONT structure.
  268. ; szFaceName - Null-terminated character array specifying the font name.
  269. ; Author ........: Gary Frost (gafrost)
  270. ; Remarks .......:
  271. ; ===============================================================================================================================
  272. Global Const $tagCHARFORMAT = "struct;uint cbSize;dword dwMask;dword dwEffects;long yHeight;long yOffset;INT crCharColor;" & _
  273. "byte bCharSet;byte bPitchAndFamily;wchar szFaceName[32];endstruct"
  274. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  275. ; Name...........: $tagCHARFORMAT2
  276. ; Description ...: Contains information about character formatting in a rich edit control
  277. ; Fields ........: cbSize - Size in bytes of the specified structure
  278. ; dwMask - Members containing valid information or attributes to set. This member can be zero, one, or more than one of the following values.
  279. ; | $CFM_BOLD - The $CFE_BOLD value of the dwEffects member is valid.
  280. ; | $CFM_CHARSET - The bCharSet member is valid.
  281. ; | $CFM_COLOR - The crTextColor member and the $CFE_AUTOCOLOR value of the dwEffects member are valid.
  282. ; | $CFM_FACE - The szFaceName member is valid.
  283. ; | $CFM_ITALIC - The $CFE_ITALIC value of the dwEffects member is valid.
  284. ; | $CFM_OFFSET - The yOffset member is valid.
  285. ; | $CFM_PROTECTED - The $CFE_PROTECTED value of the dwEffects member is valid.
  286. ; | $CFM_SIZE - The yHeight member is valid.
  287. ; | $CFM_STRIKEOUT - The $CFE_STRIKEOUT value of the dwEffects member is valid.
  288. ; | $CFM_UNDERLINE - The $CFE_UNDERLINE value of the dwEffects member is valid.
  289. ; |Set the following values to indicate the valid structure members.
  290. ; | $CFM_ANIMATION - The bAnimation member is valid.
  291. ; | $CFM_BACKCOLOR - The crBackColor member is valid.
  292. ; | $CFM_CHARSET - The bCharSet member is valid.
  293. ; | $CFM_COLOR - The crTextColor member is valid unless the CFE_AUTOCOLOR flag is set in the dwEffects member.
  294. ; | $CFM_FACE - The szFaceName member is valid.
  295. ; | $CFM_KERNING - The wKerning member is valid.
  296. ; | $CFM_LCID - The lcid member is valid.
  297. ; | $CFM_OFFSET - The yOffset member is valid.
  298. ; | $CFM_REVAUTHOR - The bRevAuthor member is valid.
  299. ; | $CFM_SIZE - The yHeight member is valid.
  300. ; | $CFM_SPACING - The sSpacing member is valid.
  301. ; | $CFM_STYLE - The sStyle member is valid.
  302. ; | $CFM_UNDERLINETYPE - The bUnderlineType member is valid.
  303. ; | $CFM_WEIGHT - The wWeight member is valid.
  304. ; dwEffects - A set of bit flags that specify character effects. Some of the flags are included only for compatibility with Microsoft Text Object Model (TOM) interfaces; the rich edit control stores the value but does not use it to display text.
  305. ; |This member can be a combination of the following values.
  306. ; | $CFE_ALLCAPS - Characters are all capital letters. The value does not affect the way the control displays the text. This value applies only to versions earlier than Rich Edit 3.0.
  307. ; | $CFE_AUTOBACKCOLOR - The background color is the return value of GetSysColor(COLOR_WINDOW). If this flag is set, crBackColor member is ignored.
  308. ; | $CFE_AUTOCOLOR - The text color is the return value of GetSysColor(COLOR_WINDOWTEXT). If this flag is set, the crTextColor member is ignored.
  309. ; | $CFE_BOLD - Characters are bold.
  310. ; | $CFE_DISABLED - Characters are displayed with a shadow that is offset by 3/4 point or one pixel, whichever is larger.
  311. ; | $CFE_EMBOSS - Characters are embossed. The value does not affect how the control displays the text.
  312. ; | $CFE_HIDDEN - For Rich Edit 3.0 and later, characters are not displayed.
  313. ; | $CFE_IMPRINT - Characters are displayed as imprinted characters. The value does not affect how the control displays the text.
  314. ; | $CFE_ITALIC - Characters are italic.
  315. ; | $CFE_LINK - A rich edit control can send EN_LINK notification messages when it receives mouse messages while the mouse pointer is over text with the CFE_LINK effect.
  316. ; | $CFE_OUTLINE - Characters are displayed as outlined characters. The value does not affect how the control displays the text.
  317. ; | $CFE_PROTECTED - Characters are protected; an attempt to modify them will cause an EN_PROTECTED notification message.
  318. ; | $CFE_REVISED - Characters are marked as revised.
  319. ; | $CFE_SHADOW - Characters are displayed as shadowed characters. The value does not affect how the control displays the text.
  320. ; | $CFE_SMALLCAPS - Characters are in small capital letters. The value does not affect how the control displays the text.
  321. ; | $CFE_STRIKEOUT - Characters are struck out.
  322. ; | $CFE_SUBSCRIPT - Characters are subscript. The CFE_SUPERSCRIPT and CFE_SUBSCRIPT values are mutually exclusive. For both values, the control automatically calculates an offset and a smaller font size. Alternatively, you can use the yHeight and yOffset members to explicitly specify font size and offset for subscript and superscript characters.
  323. ; | $CFE_SUPERSCRIPT - Characters are superscript.
  324. ; | $CFE_UNDERLINE - Characters are underlined.
  325. ; yHeight - Character height, in twips (1/1440 of an inch or 1/20 of a printer's point).
  326. ; yOffset - Character offset, in twips, from the baseline. If the value of this member is positive, the character is a superscript; if it is negative, the character is a subscript.
  327. ; crCharColor - Text color. This member is ignored if the $CFE_AUTOCOLOR character effect is specified. To generate a COLORREF, use the RGB macro.
  328. ; bCharSet - Character set value. The bCharSet member can be one of the values specified for the lfCharSet member of the LOGFONT structure. Rich Edit 3.0 may override this value if it is invalid for the target characters.
  329. ; bPitchAndFamily - Font family and pitch. This member is the same as the lfPitchAndFamily member of the LOGFONT structure.
  330. ; szFaceName - Null-terminated character array specifying the font name.
  331. ; wWeight - Font weight. This member is the same as the lfWeight member of the LOGFONT structure. To use this member, set the CFM_WEIGHT flag in the dwMask member.
  332. ; sSpacing - Horizontal space between letters, in twips. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with Microsoft WindowsText Object Model (TOM) interfaces. To use this member, set the CFM_SPACING flag in the dwMask member.
  333. ; crBackColor - Background color. To use this member, set the CFM_BACKCOLOR flag in the dwMask member. This member is ignored if the CFE_AUTOBACKCOLOR character effect is specified. To generate a , use the macro.
  334. ; lcid - A 32-bit locale identifier that contains a language identifier in the lower word and a sorting identifier and reserved value in the upper word. This member has no effect on the text displayed by a rich edit control, but spelling and grammar checkers can use it to deal with language-dependent problems. You can use the macro to create an LCID value. To use this member, set the CFM_LCID flag in the dwMask member.
  335. ; dwReserved - Reserved; the value must be zero.
  336. ; sStyle - Character style handle. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with WindowsTOM interfaces. To use this member, set the CFM_STYLE flag in the dwMask member. For more information see the Text Object Model documentation.
  337. ; wKerning - Value of the font size, above which to kern the character (yHeight). This value has no effect on the text displayed by a rich edit control; it is included for compatibility with TOM interfaces. To use this member, set the CFM_KERNING flag in the dwMask member.
  338. ; bUnderlineType - Specifies the underline type. To use this member, set the CFM_UNDERLINETYPE flag in the dwMask member. This member can be one of the following values.
  339. ; | $CFU_CF1UNDERLINE - The structure maps CHARFORMAT's bit underline to CHARFORMAT2, (that is, it performs a CHARFORMAT type of underline on this text).
  340. ; | $CFU_UNDERLINE - Solid underlined text.
  341. ; | $CFU_UNDERLINEDOTTED - Dotted underlined text. For versions earlier than Rich Edit 3.0, text is displayed with a solid underline.
  342. ; | $CFU_UNDERLINEDOUBLE - Double-underlined text. The rich edit control displays the text with a solid underline.
  343. ; | $CFU_UNDERLINENONE - No underline. This is the default.
  344. ; | $CFU_UNDERLINEWORD - Underline words only. The rich edit control displays the text with a solid underline.
  345. ; bAnimation - Text animation type. This value has no effect on the text displayed by a rich edit control; it is included for compatibility with TOM interfaces. To use this member, set the CFM_ANIMATION flag in the dwMask member.
  346. ; bRevAuthor - An index that identifies the author making a revision. The rich edit control uses different text colors for each different author index. To use this member, set the CFM_REVAUTHOR flag in the dwMask member.
  347. ; bReserved1 - Reserved; the value must be zero.
  348. ; Author ........: Gary Frost (gafrost)
  349. ; Remarks .......:
  350. ; ===============================================================================================================================
  351. Global Const $tagCHARFORMAT2 = $tagCHARFORMAT & ";word wWeight;short sSpacing;INT crBackColor;dword lcid;dword dwReserved;" & _
  352. "short sStyle;word wKerning;byte bUnderlineType;byte bAnimation;byte bRevAuthor;byte bReserved1"
  353. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  354. ; Name...........: $tagCHARRANGE
  355. ; Description ...: Specifies a range of characters in a rich edit control
  356. ; Fields ........: cpMin - Character position index immediately preceding the first character in the range.
  357. ; cpMax - Character position immediately following the last character in the range.
  358. ; Author ........: Gary Frost (gafrost)
  359. ; Remarks .......:
  360. ; ===============================================================================================================================
  361. Global Const $tagCHARRANGE = "struct;long cpMin;long cpMax;endstruct"
  362. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  363. ; Name...........: $tagFINDTEXT
  364. ; Description ...: Contains information about a search operation in a rich edit control
  365. ; Fields ........: cpMin - Character position index immediately preceding the first character in the range.
  366. ; cpMax - Character position immediately following the last character in the range.
  367. ; lpstrText - Pointer to the null-terminated string used in the find operation.
  368. ; Author ........: Gary Frost (gafrost)
  369. ; Remarks .......:
  370. ; ===============================================================================================================================
  371. Global Const $tagFINDTEXT = $tagCHARRANGE & ";ptr lpstrText"
  372. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  373. ; Name...........: $tagFINDTEXTEX
  374. ; Description ...: Contains information about text to search for in a rich edit control.
  375. ; Fields ........: cpMin - Character position index immediately preceding the first character in the range to search.
  376. ; cpMax - Character position immediately following the last character in the range to search.
  377. ; lpstrText - Pointer to the null-terminated string used in the find operation.
  378. ; cpMinRang - Character position index immediately preceding the first character in the range found.
  379. ; cpMaxRange - Character position immediately following the last character in the range found.
  380. ; Author ........: Gary Frost (gafrost)
  381. ; Remarks .......:
  382. ; ===============================================================================================================================
  383. Global Const $tagFINDTEXTEX = $tagCHARRANGE & ";ptr lpstrText;long cpMinRang;long cpMaxRange"
  384. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  385. ; Name...........: $tagGETTEXTEX
  386. ; Description ...: Contains information about an operation to get text from a rich edit control.
  387. ; Fields ........: cb - Count of bytes in the fetched string.
  388. ; flags - Value specifying a text operation. This member can be one of the following values.
  389. ; | $GT_DEFAULT - No CR translation.
  390. ; | $GT_SELECTION - Retrieves the text for the current selection.
  391. ; | $GT_USECRLF - Indicates that when copying text, each CR should be translated into a CRLF.
  392. ; codepage - Code page used in the translation. It is $CP_ACP for ANSI Code Page and 1200 for Unicode.
  393. ; lpDefaultChar - Points to the character used if a wide character cannot be represented in the specified code page.
  394. ; |It is used only if the code page is not 1200 (Unicode). If this member is NULL, a system default value is used.
  395. ; lpUsedDefChar - Points to a flag that indicates whether a default character was used.
  396. ; |It is used only if the code page is not 1200 (Unicode).
  397. ; |The flag is set to TRUE if one or more wide characters in the source string cannot be represented in the specified code page.
  398. ; |Otherwise, the flag is set to FALSE. This member may be NULL.
  399. ; Author ........: Gary Frost (gafrost)
  400. ; Remarks .......:
  401. ; ===============================================================================================================================
  402. Global Const $tagGETTEXTEX = "align 4;dword cb;dword flags;uint codepage;ptr lpDefaultChar;ptr lpbUsedDefChar"
  403. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  404. ; Name...........: $tagGETTEXTLENGTHEX
  405. ; Description ...: Contains information about how the text length of a rich edit control should be calculated.
  406. ; Fields ........: flags - Value specifying the method to be used in determining the text length. This member can be one or more of the following values (some values are mutually exclusive).
  407. ; | $GTL_DEFAULT - Returns the number of characters. This is the default.
  408. ; | $GTL_USECRLF - Computes the answer by using CR/LFs at the end of paragraphs.
  409. ; | $GTL_PRECISE - Computes a precise answer. This approach could necessitate a conversion and thereby take longer. This flag cannot be used with the GTL_CLOSE flag. E_INVALIDARG will be returned if both are used.
  410. ; | $GTL_CLOSE - Computes an approximate (close) answer. It is obtained quickly and can be used to set the buffer size. This flag cannot be used with the GTL_PRECISE flag. E_INVALIDARG will be returned if both are used.
  411. ; | $GTL_NUMCHARS - Returns the number of characters. This flag cannot be used with the GTL_NUMBYTES flag. E_INVALIDARG will be returned if both are used.
  412. ; | $GTL_NUMBYTES - Returns the number of bytes. This flag cannot be used with the GTL_NUMCHARS flag. E_INVALIDARG will be returned if both are used.
  413. ; codepage - Code page used in the translation. It is $CP_ACP for ANSI Code Page and 1200 for Unicode.
  414. ; Author ........: Gary Frost (gafrost)
  415. ; Remarks .......:
  416. ; ===============================================================================================================================
  417. Global Const $tagGETTEXTLENGTHEX = "dword flags;uint codepage"
  418. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  419. ; Name...........: $tagPARAFORMAT
  420. ; Description ...: Contains information about paragraph formatting attributes in a rich edit control.
  421. ; Fields ........: cbSize - Structure size, in bytes.
  422. ; dwMask - Members containing valid information or attributes to set. This parameter can be none or a combination of the following values. If both PFM_STARTINDENT and PFM_OFFSETINDENT are specified, PFM_STARTINDENT takes precedence.
  423. ; | $PFM_ALIGNMENT - The wAlignment member is valid.
  424. ; | $PFM_NUMBERING - The wNumbering member is valid.
  425. ; | $PFM_OFFSET - The dxOffset member is valid.
  426. ; | $PFM_OFFSETINDENT - The dxStartIndent member is valid and specifies a relative value.
  427. ; | $PFM_RIGHTINDENT - The dxRightIndent member is valid.
  428. ; | $PFM_RTLPARA - Rich Edit 2.0: The wEffects member is valid
  429. ; | $PFM_STARTINDENT - The dxStartIndent member is valid.
  430. ; | $PFM_TABSTOPS - The cTabStobs and rgxTabStops members are valid.
  431. ; wNumbering - Value specifying numbering options. This member can be zero or $PFN_BULLET.
  432. ; wEffects - A bit flag that specifies a paragraph effect. It is included only for compatibility with Text Object Model (TOM) interfaces; the rich edit control stores the value but does not use it to display the text. This parameter can be one of the following values.
  433. ; | 0 - Displays text using left-to-right reading order. This is the default.
  434. ; | $PFE_RLTPARA - Displays text using right-to-left reading order.
  435. ; dxStartIndent - Indentation of the first line in the paragraph, in twips.
  436. ; |If the paragraph formatting is being set and PFM_OFFSETINDENT is specified, this member is treated as a relative value that is added to the starting indentation of each affected paragraph.
  437. ; dxRightIndent - Size, of the right indentation relative to the right margin, in twips.
  438. ; dxOffset - Indentation of the second and subsequent lines of a paragraph relative to the starting indentation, in twips.
  439. ; |The first line is indented if this member is negative or outdented if this member is positive.
  440. ; wAlignment - Value specifying the paragraph alignment. This member can be one of the following values.
  441. ; | $PFA_CENTER - Paragraphs are centered.
  442. ; | $PFA_LEFT - Paragraphs are aligned with the left margin.
  443. ; | $PFA_RIGHT - Paragraphs are aligned with the right margin.
  444. ; cTabCount - Number of tab stops.
  445. ; rgxTabs - Array of absolute tab stop positions. Each element in the array specifies information about a tab stop. The 24 low-order bits specify the absolute offset, in twips. To use this member, set the PFM_TABSTOPS flag in the dwMask member.
  446. ; |Rich Edit 2.0: For compatibility with TOM interfaces, you can use the eight high-order bits to store additional information about each tab stop.
  447. ; | Bits 24-27 can specify one of the following values to indicate the tab alignment. These bits do not affect the rich edit control display for versions earlier than Rich Edit 3.0.
  448. ; | 0 - Ordinary tab
  449. ; | 1 - Center tab
  450. ; | 2 - Right-aligned tab
  451. ; | 3 - Decimal tab
  452. ; | 4 - Word bar tab (vertical bar)
  453. ; | Bits 28-31 can specify one of the following values to indicate the type of tab leader. These bits do not affect the rich edit control display.
  454. ; | 0 - No leader
  455. ; | 1 - Dotted leader
  456. ; | 2 - Dashed leader
  457. ; | 3 - Underlined leader
  458. ; | 4 - Thick line leader
  459. ; | 5 - Double line leader
  460. ; Author ........: Gary Frost (gafrost)
  461. ; Remarks .......:
  462. ; ===============================================================================================================================
  463. Global Const $tagPARAFORMAT = "uint cbSize;dword dwMask;word wNumbering;word wEffects;long dxStartIndent;" _
  464. & "long dxRightIndent;long dxOffset;word wAlignment;short cTabCount;long rgxTabs[32]"
  465. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  466. ; Name...........: $tagPARAFORMAT2
  467. ; Description ...: Contains information about paragraph formatting attributes in a rich edit control.
  468. ; Fields ........: cbSize - Structure size, in bytes.
  469. ; dwMask - The members of the PARAFORMAT2 structure that contain valid information. The dwMask member can be a combination of the values from two sets of bit flags. One set indicates the structure members that are valid; another set indicates the valid attributes in the wEffects member.
  470. ; |Set the following values to indicate the valid structure members.
  471. ; | $PFM_ALIGNMENT - The wAlignment member is valid.
  472. ; | $PFM_BORDER - The wBorderSpace, wBorderWidth, and wBorders members are valid.
  473. ; | $PFM_LINESPACING - The dyLineSpacing and bLineSpacingRule members are valid.
  474. ; | $PFM_NUMBERING - The wNumbering member is valid.
  475. ; | $PFM_NUMBERINGSTART - The wNumberingStart member is valid.
  476. ; | $PFM_NUMBERINGSTYLE - The wNumberingStyle member is valid.
  477. ; | $PFM_NUMBERINGTAB - The wNumberingTab member is valid.
  478. ; | $PFM_OFFSET - The dxOffset member is valid.
  479. ; | $PFM_OFFSETINDENT - The dxStartIndent member is valid. If you are setting the indentation, dxStartIndent specifies the amount to indent relative to the current indentation.
  480. ; | $PFM_RIGHTINDENT - The dxRightIndent member is valid.
  481. ; | $PFM_SHADING - The wShadingWeight and wShadingStyle members are valid.
  482. ; | $PFM_SPACEAFTER - The dySpaceAfter member is valid.
  483. ; | $PFM_SPACEBEFORE - The dySpaceBefore member is valid.
  484. ; | $PFM_STARTINDENT - The dxStartIndent member is valid and specifies the indentation from the left margin. If both PFM_STARTINDENT and PFM_OFFSETINDENT are specified, PFM_STARTINDENT takes precedence.
  485. ; | $PFM_STYLE - The sStyle member is valid.
  486. ; | $PFM_TABSTOPS - The cTabCount and rgxTabs members are valid.
  487. ; |Set the following values to indicate the valid attributes of the wEffects member.
  488. ; | $PFM_DONOTHYPHEN - The PFE_DONOTHYPHEN value is valid.
  489. ; | $PFM_KEEP - The PFE_KEEP value is valid.
  490. ; | $PFM_KEEPNEXT - The PFE_KEEPNEXT value is valid.
  491. ; | $PFM_NOLINENUMBER - The PFE_NOLINENUMBER value is valid.
  492. ; | $PFM_NOWIDOWCONTROL - The PFE_NOWIDOWCONTROL value is valid.
  493. ; | $PFM_PAGEBREAKBEFORE - The PFE_PAGEBREAKBEFORE value is valid.
  494. ; | $PFM_RTLPARA - The PFE_RTLPARA value is valid.
  495. ; | $PFM_SIDEBYSIDE - The PFE_SIDEBYSIDE value is valid.
  496. ; | $PFM_TABLE - The PFE_TABLE value is valid.
  497. ; wNumbering - Options used for bulleted or numbered paragraphs. To use this member, set the PFM_NUMBERING flag in the dwMask member.
  498. ; |This member can be one of the following values.
  499. ; | zero - No paragraph numbering or bullets.
  500. ; | $PFN_BULLET - Insert a bullet at the beginning of each selected paragraph.
  501. ; | Rich Edit versions earlier than version 3.0 do not display paragraph numbers.
  502. ; | However, for compatibility with Microsoft Text Object Model (TOM) interfaces,
  503. ; | wNumbering can specify one of the following values.
  504. ; | (The rich edit control stores the value but does not use it to display the text.)
  505. ; | 2 - Uses Arabic numbers (1, 2, 3, ...).
  506. ; | 3 - Uses lowercase letters (a, b, c, ...).
  507. ; | 4 - Uses uppercase letters (A, B, C, ...).
  508. ; | 5 - Uses lowercase Roman numerals (i, ii, iii, ...).
  509. ; | 6 - Uses uppercase Roman numerals (I, II, III, ...).
  510. ; | 7 - Uses a sequence of characters beginning with the Unicode character specified by the wNumberingStart member.
  511. ; wEffects - A set of bit flags that specify paragraph effects. These flags are included only for compatibility with Text Object Model (TOM) interfaces; the rich edit control stores the value but does not use it to display the text.
  512. ; |This member can be a combination of the following values.
  513. ; | $PFE_DONOTHYPHEN - Disables automatic hyphenation.
  514. ; | $PFE_KEEP - No page break within the paragraph.
  515. ; | $PFE_KEEPNEXT - No page break between this paragraph and the next.
  516. ; | $PFE_NOLINENUMBER - Disables line numbering (in Rich Edit 3.0 only).
  517. ; | $PFE_NOWIDOWCONTROL - Disables widow and orphan control for the selected paragraph.
  518. ; | $PFE_PAGEBREAKBEFORE - Inserts a page break before the selected paragraph.
  519. ; | $PFE_RTLPARA - Displays text using right-to-left reading order (in Rich Edit 2.1 and later).
  520. ; | $PFE_SIDEBYSIDE - Displays paragraphs side by side.
  521. ; | $PFE_TABLE - The paragraph is a table row.
  522. ; dxStartIndent - Indentation of the paragraph's first line, in twips.
  523. ; |The indentation of subsequent lines depends on the dxOffset member.
  524. ; |To use the dxStartIndent member, set the $PFM_STARTINDENT or $PFM_OFFSETINDENT flag in the dwMask member.
  525. ; |If you are setting the indentation, use the $PFM_STARTINDENT flag to specify an absolute indentation from the left margin
  526. ; |or use the $PFM_OFFSETINDENT flag to specify an indentation relative to the paragraph's current indentation.
  527. ; |Use either flag to retrieve the current indentation.
  528. ; dxRightIndent - Indentation of the right side of the paragraph, relative to the right margin, in twips.
  529. ; |To use this member, set the $PFM_RIGHTINDENT flag in the dwMask member.
  530. ; dxOffset - Indentation of the second and subsequent lines, relative to the indentation of the first line, in twips.
  531. ; |The first line is indented if this member is negative or outdented if this member is positive.
  532. ; |To use this member, set the $PFM_OFFSET flag in the dwMask member.
  533. ; wAlignment - Paragraph alignment. To use this member, set the PFM_ALIGNMENT flag in the dwMask member. This member can be one of the following values.
  534. ; | $PFA_LEFT - Paragraphs are aligned with the left margin.
  535. ; | $PFA_RIGHT - Paragraphs are aligned with the right margin.
  536. ; | $PFA_CENTER - Paragraphs are centered.
  537. ; | $PFA_JUSTIFY - Rich Edit 2.0: Paragraphs are justified.
  538. ; | This value is included for compatibility with TOM interfaces;
  539. ; | rich edit controls earlier than Rich Edit 3.0 display the text aligned with the left margin.
  540. ; | $PFA_FULL_INTERWORD - Paragraphs are justified by expanding the blanks alone.
  541. ; cTabCount - Number of tab stops defined in the rgxTabs array.
  542. ; rgxTabs - Array of absolute tab stop positions. Each element in the array specifies information about a tab stop. The 24 low-order bits specify the absolute offset, in twips. To use this member, set the PFM_TABSTOPS flag in the dwMask member.
  543. ; |Rich Edit 2.0: For compatibility with TOM interfaces, you can use the eight high-order bits to store additional information about each tab stop.
  544. ; | Bits 24-27 can specify one of the following values to indicate the tab alignment. These bits do not affect the rich edit control display for versions earlier than Rich Edit 3.0.
  545. ; | 0 - Ordinary tab
  546. ; | 1 - Center tab
  547. ; | 2 - Right-aligned tab
  548. ; | 3 - Decimal tab
  549. ; | 4 - Word bar tab (vertical bar)
  550. ; | Bits 28-31 can specify one of the following values to indicate the type of tab leader. These bits do not affect the rich edit control display.
  551. ; | 0 - No leader
  552. ; | 1 - Dotted leader
  553. ; | 2 - Dashed leader
  554. ; | 3 - Underlined leader
  555. ; | 4 - Thick line leader
  556. ; | 5 - Double line leader
  557. ; dySpaceBefore - Size of the spacing above the paragraph, in twips. To use this member, set the PFM_SPACEBEFORE flag in the dwMask member. The value must be greater than or equal to zero.
  558. ; dySpaceAfter - Specifies the size of the spacing below the paragraph, in twips. To use this member, set the PFM_SPACEAFTER flag in the dwMask member. The value must be greater than or equal to zero.
  559. ; dyLineSpacing - Spacing between lines. For a description of how this value is interpreted, see the bLineSpacingRule member. To use this member, set the PFM_LINESPACING flag in the dwMask member.
  560. ; sStyle - Text style. To use this member, set the PFM_STYLE flag in the dwMask member. This member is included only for compatibility with TOM interfaces and Microsoft Word; the rich edit control stores the value but does not use it to display the text.
  561. ; bLineSpacingRule - Type of line spacing. To use this member, set the PFM_SPACEAFTER flag in the dwMask member. This member can be one of the following values.
  562. ; | 0 - Single spacing. The dyLineSpacing member is ignored.
  563. ; | 1 - One-and-a-half spacing. The dyLineSpacing member is ignored.
  564. ; | 2 - Double spacing. The dyLineSpacing member is ignored.
  565. ; | 3 - The dyLineSpacing member specifies the spacingfrom one line to the next, in twips. However, if dyLineSpacing specifies a value that is less than single spacing, the control displays single-spaced text.
  566. ; | 4 - The dyLineSpacing member specifies the spacing from one line to the next, in twips. The control uses the exact spacing specified, even if dyLineSpacing specifies a value that is less than single spacing.
  567. ; | 5 - The value of dyLineSpacing / 20 is the spacing, in lines, from one line to the next. Thus, setting dyLineSpacing to 20 produces single-spaced text, 40 is double spaced, 60 is triple spaced, and so on.
  568. ; bOutlineLevel - Reserved; must be zero.
  569. ; wShadingWeight - Percentage foreground color used in shading. The wShadingStyle member specifies the foreground and background shading colors. A value of 5 indicates a shading color consisting of 5 percent foreground color and 95 percent background color. To use these members, set the PFM_SHADING flag in the dwMask member. This member is included only for compatibility with Word; the rich edit control stores the value but does not use it to display the text.
  570. ; wShadingStyle - Style and colors used for background shading. Bits 0 to 3 contain the shading style, bits 4 to 7 contain the foreground color index, and bits 8 to 11 contain the background color index. To use this member, set the PFM_SHADING flag in the dwMask member. This member is included only for compatibility with Word; the rich edit control stores the value but does not use it to display the text.
  571. ; | The shading style can be one of the following values.
  572. ; | 0 - None
  573. ; | 1 - Dark horizontal
  574. ; | 2 - Dark vertical
  575. ; | 3 - Dark down diagonal
  576. ; | 4 - Dark up diagonal
  577. ; | 5 - Dark grid
  578. ; | 6 - Dark trellis
  579. ; | 7 - Light horizontal
  580. ; | 8 - Light vertical
  581. ; | 9 - Light down diagonal
  582. ; | 10 - Light up diagonal
  583. ; | 11 - Light grid
  584. ; | 12 - Light trellis
  585. ; | The foreground and background color indexes can be one of the following values.
  586. ; | 0 - Black
  587. ; | 1 - Blue
  588. ; | 2 - Cyan
  589. ; | 3 - Green
  590. ; | 4 - Magenta
  591. ; | 5 - Red
  592. ; | 6 - Yellow
  593. ; | 7 - White
  594. ; | 8 - Dark blue
  595. ; | 9 - Dark cyan
  596. ; | 10 - Dark green
  597. ; | 11 - Dark magenta
  598. ; | 12 - Dark red
  599. ; | 13 - Dark yellow
  600. ; | 14 - Dark gray
  601. ; | 15 - Light gray
  602. ; wNumberingStart - Starting number or Unicode value used for numbered paragraphs. Use this member in conjunction with the wNumbering member. This member is included only for compatibility with TOM interfaces; the rich edit control stores the value but does not use it to display the text or bullets. To use this member, set the PFM_NUMBERINGSTART flag in the dwMask member.
  603. ; wNumberingStyle - Numbering style used with numbered paragraphs. Use this member in conjunction with the wNumbering member. This member is included only for compatibility with TOM interfaces; the rich edit control stores the value but rich edit versions earlier than 3.0 do not use it to display the text or bullets. To use this member, set the PFM_NUMBERINGSTYLE flag in the dwMask member. This member can be one of the following values.
  604. ; | 0 - Follows the number with a right parenthesis.
  605. ; | 0x100 - Encloses the number in parentheses.
  606. ; | 0x200 - Follows the number with a period.
  607. ; | 0x300 - Displays only the number.
  608. ; | 0x400 - Continues a numbered list without applying the next number or bullet.
  609. ; | 0x8000 - Starts a new number with wNumberingStart.
  610. ; wNumberingTab - Minimum space between a paragraph number and the paragraph text, in twips. Use this member in conjunction with the wNumbering member. The wNumberingTab member is included for compatibility with TOM interfaces; previous to Rich Edit 3.0, the rich edit control stores the value but does not use it to display text. To use this member, set the PFM_NUMBERINGTAB flag in the dwMask member.
  611. ; wBorderSpace - The space between the border and the paragraph text, in twips. The wBorderSpace member is included for compatibility with Word; the rich edit control stores the values but does not use them to display text. To use this member, set the PFM_BORDER flag in the dwMask member.
  612. ; wBorderWidth - Border width, in twips. To use this member, set the PFM_BORDER flag in the dwMask member.
  613. ; wBorders - Border location, style, and color. Bits 0 to 7 specify the border locations, bits 8 to 11 specify the border style, and bits 12 to 15 specify the border color index. To use this member, set the PFM_BORDER flag in the dwMask member.
  614. ; | Specify the border locations using a combination of the following values in bits 0 to 7.
  615. ; | 1 - Left border.
  616. ; | 2 - Right border.
  617. ; | 4 - Top border.
  618. ; | 8 - Bottom border.
  619. ; | 16 - Inside borders.
  620. ; | 32 - Outside borders.
  621. ; | 64 - Autocolor. If this bit is set, the color index in bits 12 to 15 is not used.
  622. ; | Specify the border style using one of the following values for bits 8 to 11.
  623. ; | 0 - None
  624. ; | 1 - 3/4 point
  625. ; | 2 - 11/2 point
  626. ; | 3 - 21/4 point
  627. ; | 4 - 3 point
  628. ; | 5 - 41/2 point
  629. ; | 6 - 6 point
  630. ; | 7 - 3/4 point double
  631. ; | 8 - 11/2 point double
  632. ; | 9 - 21/4 point double
  633. ; | 10 - 3/4 point gray
  634. ; | 11 - 3/4 point gray dashed
  635. ; | Specify the border color using one of the following values for bits 12 to 15. This value is ignored if the autocolor bit (bit 6) is set.
  636. ; | 0 - Black
  637. ; | 1 - Blue
  638. ; | 2 - Cyan
  639. ; | 3 - Green
  640. ; | 4 - Magenta
  641. ; | 5 - Red
  642. ; | 6 - Yellow
  643. ; | 7 - White
  644. ; | 8 - Dark blue
  645. ; | 9 - Dark cyan
  646. ; | 10 - Dark green
  647. ; | 11 - Dark magenta
  648. ; | 12 - Dark red
  649. ; | 13 - Dark yellow
  650. ; | 14 - Dark gray
  651. ; | 15 - Light gray
  652. ; Author ........: Gary Frost (gafrost)
  653. ; Remarks .......:
  654. ; ===============================================================================================================================
  655. Global Const $tagPARAFORMAT2 = $tagPARAFORMAT _
  656. & ";long dySpaceBefore;long dySpaceAfter;long dyLineSpacing;short sStyle;byte bLineSpacingRule;" _
  657. & "byte bOutlineLevel;word wShadingWeight;word wShadingStyle;word wNumberingStart;word wNumberingStyle;" _
  658. & "word wNumberingTab;word wBorderSpace;word wBorderWidth;word wBorders"
  659. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  660. ; Name...........: $tagSETTEXTEX
  661. ; Description ...: Specifies which code page (if any) to use in setting text, whether the text replaces all the text in the control or just the selection, and whether the undo state is to be preserved.
  662. ; Fields ........: flags - Option flags. It can be any reasonable combination of the following flags.
  663. ; | $ST_DEFAULT - Deletes the undo stack, discards rich-text formatting, replaces all text.
  664. ; | $ST_KEEPUNDO - Keeps the undo stack.
  665. ; | $ST_SELECTION - Replaces selection and keeps rich-text formatting.
  666. ; codepage - Code page used in the translation. It is $CP_ACP for ANSI Code Page and 1200 for Unicode.
  667. ; Author ........: Gary Frost (gafrost)
  668. ; Remarks .......:
  669. ; ===============================================================================================================================
  670. Global Const $tagSETTEXTEX = "dword flags;uint codepage"
  671. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  672. ; Name...........: $tagTEXTRANGE
  673. ; Description ...: Specifies a range of characters in a rich edit control
  674. ; Fields ........: cpMin - Character position index immediately preceding the first character in the range.
  675. ; cpMax - Character position immediately following the last character in the range.
  676. ; lpstrText - Pointer to buffer that receives the text.
  677. ; Author ........: Gary Frost (gafrost)
  678. ; Remarks .......:
  679. ; ===============================================================================================================================
  680. Global Const $tagTEXTRANGE = $tagCHARRANGE & ";ptr lpstrText"
  681. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  682. ; Name...........: $tagMSGFILTER
  683. ; Description ...: Contains information about a keyboard or mouse event.
  684. ; Fields ........: hWndFrom - Window handle to the control sending a message
  685. ; IDFrom - Identifier of the control sending a message
  686. ; Code - Notification code
  687. ; msg - Keyboard or mouse message identifier.
  688. ; wParam - The wParam parameter of the message.
  689. ; lParam - The lParam parameter of the message.
  690. ; Author ........: Gary Frost (gafrost)
  691. ; Remarks .......:
  692. ; ===============================================================================================================================
  693. Global Const $tagMSGFILTER = "align 4;" & $tagNMHDR & ";uint msg;wparam wParam;lparam lParam"
  694. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  695. ; Name...........: $tagENLINK
  696. ; Description ...: Contains information about an EN_LINK notification message from a rich edit control.
  697. ; Fields ........: hWndFrom - Window handle to the control sending a message
  698. ; IDFrom - Identifier of the control sending a message
  699. ; Code - Notification code
  700. ; msg - Keyboard or mouse message identifier.
  701. ; wParam - The wParam parameter of the message.
  702. ; lParam - The lParam parameter of the message.
  703. ; cpMin - Character position index immediately preceding the first character in the range.
  704. ; cpMax - Character position immediately following the last character in the range.
  705. ; Author ........: Gary Frost (gafrost)
  706. ; Remarks .......:
  707. ; ===============================================================================================================================
  708. Global Const $tagENLINK = "align 4;" & $tagNMHDR & ";uint msg;wparam wParam;lparam lParam;" & $tagCHARRANGE
  709. ; #FUNCTION# ====================================================================================================================
  710. ; Authors........: Gary Frost (gafrost (custompcs@charter.net))
  711. ; Modified ......: Prog@ndy, Chris Haslam (c.haslam)
  712. ; ===============================================================================================================================
  713. Func _GUICtrlRichEdit_AppendText($hWnd, $sText)
  714. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  715. Local $iLength = _GUICtrlRichEdit_GetTextLength($hWnd)
  716. _GUICtrlRichEdit_SetSel($hWnd, $iLength, $iLength) ; go to end of text
  717. Local $tSetText = DllStructCreate($tagSETTEXTEX)
  718. DllStructSetData($tSetText, 1, $ST_SELECTION)
  719. Local $iRet
  720. If StringLeft($sText, 5) <> "{\rtf" And StringLeft($sText, 5) <> "{urtf" Then
  721. DllStructSetData($tSetText, 2, $CP_UNICODE)
  722. $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "wstr")
  723. Else
  724. DllStructSetData($tSetText, 2, $CP_ACP)
  725. $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "STR")
  726. EndIf
  727. If Not $iRet Then Return SetError(700, 0, False)
  728. Return True
  729. EndFunc ;==>_GUICtrlRichEdit_AppendText
  730. ; #FUNCTION# ====================================================================================================================
  731. ; Authors........: Chris Haslam (c.haslam)
  732. ; Modified ......:
  733. ; ===============================================================================================================================
  734. Func _GUICtrlRichEdit_AutoDetectURL($hWnd, $bState)
  735. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  736. If Not IsBool($bState) Then Return SetError(102, 0, False)
  737. If _SendMessage($hWnd, $EM_AUTOURLDETECT, $bState) Then Return SetError(700, 0, False)
  738. Return True
  739. EndFunc ;==>_GUICtrlRichEdit_AutoDetectURL
  740. ; #FUNCTION# ====================================================================================================================
  741. ; Authors........: Prog@ndy
  742. ; Modified ......: Chris Haslam (c.haslam)
  743. ; ===============================================================================================================================
  744. Func _GUICtrlRichEdit_CanPaste($hWnd)
  745. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  746. Local $iRet = _SendMessage($hWnd, $EM_CANPASTE, 0, 0)
  747. Return $iRet <> 0
  748. EndFunc ;==>_GUICtrlRichEdit_CanPaste
  749. ; #FUNCTION# ====================================================================================================================
  750. ; Authors........: Chris Haslam (c.haslam)
  751. ; Modified ......:
  752. ; ===============================================================================================================================
  753. Func _GUICtrlRichEdit_CanPasteSpecial($hWnd)
  754. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  755. Return _SendMessage($hWnd, $EM_CANPASTE, $__g_sGRE_CF_RTF, 0) <> 0 _
  756. And _SendMessage($hWnd, $EM_CANPASTE, $__g_sGRE_CF_RETEXTOBJ, 0) <> 0
  757. EndFunc ;==>_GUICtrlRichEdit_CanPasteSpecial
  758. ; #FUNCTION# ====================================================================================================================
  759. ; Authors........: Prog@ndy
  760. ; Modified ......: Chris Haslam (c.haslam)
  761. ; ===============================================================================================================================
  762. Func _GUICtrlRichEdit_CanRedo($hWnd)
  763. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  764. Return _SendMessage($hWnd, $EM_CANREDO, 0, 0) <> 0
  765. EndFunc ;==>_GUICtrlRichEdit_CanRedo
  766. ; #FUNCTION# ====================================================================================================================
  767. ; Authors........: Prog@ndy
  768. ; Modified ......: Chris Haslam (c.haslam)
  769. ; ===============================================================================================================================
  770. Func _GUICtrlRichEdit_CanUndo($hWnd)
  771. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  772. Return _SendMessage($hWnd, $EM_CANUNDO, 0, 0) <> 0
  773. EndFunc ;==>_GUICtrlRichEdit_CanUndo
  774. ; #FUNCTION# ====================================================================================================================
  775. ; Authors........: Prog@ndy
  776. ; Modified ......: Chris Haslam (c.haslam)
  777. ; ===============================================================================================================================
  778. Func _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement)
  779. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  780. If Not __GCR_IsNumeric($iIncrement) Then SetError(102, 0, False)
  781. If Not _GUICtrlRichEdit_IsTextSelected($hWnd) Then Return SetError(-1, 0, False)
  782. Return _SendMessage($hWnd, $EM_SETFONTSIZE, $iIncrement, 0) <> 0
  783. EndFunc ;==>_GUICtrlRichEdit_ChangeFontSize
  784. ; #FUNCTION# ====================================================================================================================
  785. ; Authors........: Prog@ndy
  786. ; Modified ......: Chris Haslam (c.haslam)
  787. ; ===============================================================================================================================
  788. Func _GUICtrlRichEdit_Copy($hWnd)
  789. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  790. _SendMessage($hWnd, $__RICHEDITCONSTANT_WM_COPY, 0, 0)
  791. Return True
  792. EndFunc ;==>_GUICtrlRichEdit_Copy
  793. ; #FUNCTION# ====================================================================================================================
  794. ; Author ........: Gary Frost
  795. ; Modified.......: Chris Haslam (c.haslam)
  796. ; ===============================================================================================================================
  797. Func _GUICtrlRichEdit_Create($hWnd, $sText, $iLeft, $iTop, $iWidth = 150, $iHeight = 150, $iStyle = -1, $iExStyle = -1)
  798. If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ; Invalid Window handle for _GUICtrlRichEdit_Create 1st parameter
  799. If Not IsString($sText) Then Return SetError(2, 0, 0) ; 2nd parameter not a string for _GUICtrlRichEdit_Create
  800. If Not __GCR_IsNumeric($iWidth, ">0,-1") Then Return SetError(105, 0, 0)
  801. If Not __GCR_IsNumeric($iHeight, ">0,-1") Then Return SetError(106, 0, 0)
  802. If Not __GCR_IsNumeric($iStyle, ">=0,-1") Then Return SetError(107, 0, 0)
  803. If Not __GCR_IsNumeric($iExStyle, ">=0,-1") Then Return SetError(108, 0, 0)
  804. If $iWidth = -1 Then $iWidth = 150
  805. If $iHeight = -1 Then $iHeight = 150
  806. If $iStyle = -1 Then $iStyle = BitOR($ES_WANTRETURN, $ES_MULTILINE)
  807. If BitAND($iStyle, $ES_MULTILINE) <> 0 Then $iStyle = BitOR($iStyle, $ES_WANTRETURN)
  808. If $iExStyle = -1 Then $iExStyle = 0x200 ; $DS_FOREGROUND
  809. $iStyle = BitOR($iStyle, $__UDFGUICONSTANT_WS_CHILD, $__UDFGUICONSTANT_WS_VISIBLE)
  810. If BitAND($iStyle, $ES_READONLY) = 0 Then $iStyle = BitOR($iStyle, $__UDFGUICONSTANT_WS_TABSTOP)
  811. Local $nCtrlID = __UDF_GetNextGlobalID($hWnd)
  812. If @error Then Return SetError(@error, @extended, 0)
  813. __GCR_Init()
  814. Local $hRichEdit = _WinAPI_CreateWindowEx($iExStyle, $__g_sRTFClassName, "", $iStyle, $iLeft, $iTop, $iWidth, _
  815. $iHeight, $hWnd, $nCtrlID)
  816. If $hRichEdit = 0 Then Return SetError(700, 0, False)
  817. __GCR_SetOLECallback($hRichEdit)
  818. _SendMessage($hRichEdit, $__RICHEDITCONSTANT_WM_SETFONT, _WinAPI_GetStockObject($DEFAULT_GUI_FONT), True)
  819. _GUICtrlRichEdit_AppendText($hRichEdit, $sText)
  820. Return $hRichEdit
  821. EndFunc ;==>_GUICtrlRichEdit_Create
  822. ; #FUNCTION# ====================================================================================================================
  823. ; Authors........: Prog@ndy
  824. ; Modified ......: Chris Haslam (c.haslam)
  825. ; ===============================================================================================================================
  826. Func _GUICtrlRichEdit_Cut($hWnd)
  827. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  828. _SendMessage($hWnd, $__RICHEDITCONSTANT_WM_CUT, 0, 0)
  829. Return True
  830. EndFunc ;==>_GUICtrlRichEdit_Cut
  831. ; #FUNCTION# ====================================================================================================================
  832. ; Authors........: Chris Haslam (c.haslam)
  833. ; Modified ......:
  834. ; ===============================================================================================================================
  835. Func _GUICtrlRichEdit_Deselect($hWnd)
  836. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  837. _SendMessage($hWnd, $EM_SETSEL, -1, 0)
  838. Return True
  839. EndFunc ;==>_GUICtrlRichEdit_Deselect
  840. ; #FUNCTION# ====================================================================================================================
  841. ; Author ........: Gary Frost (gafrost)
  842. ; Modified.......: Chris Haslam (c.haslam)
  843. ; ===============================================================================================================================
  844. Func _GUICtrlRichEdit_Destroy(ByRef $hWnd)
  845. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(2, 2, False)
  846. Local $iDestroyed = 0
  847. If IsHWnd($hWnd) Then
  848. If _WinAPI_InProcess($hWnd, $__g_hRELastWnd) Then
  849. Local $nCtrlID = _WinAPI_GetDlgCtrlID($hWnd)
  850. Local $hParent = _WinAPI_GetParent($hWnd)
  851. $iDestroyed = _WinAPI_DestroyWindow($hWnd)
  852. Local $iRet = __UDF_FreeGlobalID($hParent, $nCtrlID)
  853. If Not $iRet Then
  854. ; can check for errors here if needed, for debug
  855. EndIf
  856. Else
  857. ; Not Allowed to Destroy Other Applications Control(s)
  858. Return SetError(1, 1, False)
  859. EndIf
  860. Else
  861. $iDestroyed = GUICtrlDelete($hWnd)
  862. EndIf
  863. If $iDestroyed Then $hWnd = 0
  864. Return $iDestroyed <> 0
  865. EndFunc ;==>_GUICtrlRichEdit_Destroy
  866. ; #FUNCTION# ====================================================================================================================
  867. ; Author ........: Chris Haslam (c.haslam)
  868. ; Modified.......:
  869. ; ===============================================================================================================================
  870. Func _GUICtrlRichEdit_EmptyUndoBuffer($hWnd)
  871. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  872. _SendMessage($hWnd, $EM_EMPTYUNDOBUFFER, 0, 0)
  873. Return True
  874. EndFunc ;==>_GUICtrlRichEdit_EmptyUndoBuffer
  875. ; #FUNCTION# ====================================================================================================================
  876. ; Authors........: Chris Haslam (c.haslam)
  877. ; Modified ......: jpm
  878. ; ===============================================================================================================================
  879. Func _GUICtrlRichEdit_FindText($hWnd, $sText, $bForward = True, $bMatchCase = False, $bWholeWord = False, $iBehavior = 0)
  880. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, -1)
  881. If $sText = "" Then Return SetError(102, 0, -1)
  882. If Not IsBool($bForward) Then Return SetError(103, 0, -1)
  883. If Not IsBool($bMatchCase) Then Return SetError(104, 0, -1)
  884. If Not IsBool($bWholeWord) Then Return SetError(105, 0, -1)
  885. If Not __GCR_IsNumeric($iBehavior) Then Return SetError(1061, 0, -1)
  886. If BitAND($iBehavior, BitNOT(BitOR($FR_MATCHALEFHAMZA, $FR_MATCHDIAC, $FR_MATCHKASHIDA))) <> 0 Then Return SetError(1062, 0, -1)
  887. Local $iLen = StringLen($sText) + 3
  888. Local $tText = DllStructCreate("wchar[" & $iLen & "]")
  889. DllStructSetData($tText, 1, $sText)
  890. Local $tFindtext = DllStructCreate($tagFINDTEXT)
  891. Local $aiAnchorActive
  892. Local $bSel = _GUICtrlRichEdit_IsTextSelected($hWnd)
  893. If $bSel Then
  894. $aiAnchorActive = _GUICtrlRichEdit_GetSelAA($hWnd)
  895. Else
  896. $aiAnchorActive = _GUICtrlRichEdit_GetSel($hWnd)
  897. EndIf
  898. DllStructSetData($tFindtext, 1, $aiAnchorActive[0])
  899. DllStructSetData($tFindtext, 2, ($bForward ? -1 : 0)) ; to end else to start
  900. DllStructSetData($tFindtext, 3, DllStructGetPtr($tText))
  901. Local Const $FR_DOWN = 0x00000001
  902. Local Const $FR_WHOLEWORD = 0x00000002
  903. Local Const $FR_MATCHCASE = 0x00000004
  904. Local $wParam = 0
  905. If $bForward Then $wParam = $FR_DOWN
  906. If $bWholeWord Then $wParam = BitOR($wParam, $FR_WHOLEWORD)
  907. If $bMatchCase Then $wParam = BitOR($wParam, $FR_MATCHCASE)
  908. $wParam = BitOR($wParam, $iBehavior)
  909. Return _SendMessage($hWnd, $EM_FINDTEXTW, $wParam, $tFindtext, "wparam", "ptr", "struct*")
  910. EndFunc ;==>_GUICtrlRichEdit_FindText
  911. ; #FUNCTION# ====================================================================================================================
  912. ; Authors........: Chris Haslam (c.haslam)
  913. ; Modified ......: jpm
  914. ; ===============================================================================================================================
  915. Func _GUICtrlRichEdit_FindTextInRange($hWnd, $sText, $iStart = 0, $iEnd = -1, $bMatchCase = False, $bWholeWord = False, $iBehavior = 0)
  916. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  917. If $sText = "" Then Return SetError(102, 0, 0)
  918. If Not __GCR_IsNumeric($iStart, ">=0,-1") Then Return SetError(103, 0, 0)
  919. If Not __GCR_IsNumeric($iEnd, ">=0,-1") Then Return SetError(104, 0, 0)
  920. If Not IsBool($bMatchCase) Then Return SetError(105, 0, 0)
  921. If Not IsBool($bWholeWord) Then Return SetError(106, 0, 0)
  922. If Not __GCR_IsNumeric($iBehavior) Then Return SetError(1071, 0, 0)
  923. If BitAND($iBehavior, BitNOT(BitOR($FR_MATCHALEFHAMZA, $FR_MATCHDIAC, $FR_MATCHKASHIDA))) <> 0 Then Return SetError(1072, 0, 0)
  924. Local $iLen = StringLen($sText) + 3
  925. Local $tText = DllStructCreate("wchar Text[" & $iLen & "]")
  926. DllStructSetData($tText, "Text", $sText)
  927. Local $tFindtext = DllStructCreate($tagFINDTEXTEX)
  928. DllStructSetData($tFindtext, "cpMin", $iStart)
  929. DllStructSetData($tFindtext, "cpMax", $iEnd)
  930. DllStructSetData($tFindtext, "lpstrText", DllStructGetPtr($tText))
  931. Local Const $FR_DOWN = 0x00000001
  932. Local Const $FR_WHOLEWORD = 0x00000002
  933. Local Const $FR_MATCHCASE = 0x00000004
  934. Local $wParam = 0
  935. If $iEnd >= $iStart Or $iEnd = -1 Then
  936. $wParam = $FR_DOWN
  937. EndIf
  938. If $bWholeWord Then $wParam = BitOR($wParam, $FR_WHOLEWORD)
  939. If $bMatchCase Then $wParam = BitOR($wParam, $FR_MATCHCASE)
  940. $wParam = BitOR($wParam, $iBehavior)
  941. _SendMessage($hWnd, $EM_FINDTEXTEXW, $wParam, $tFindtext, "iWparam", "ptr", "struct*")
  942. Local $aRet[2]
  943. $aRet[0] = DllStructGetData($tFindtext, "cpMinRang")
  944. $aRet[1] = DllStructGetData($tFindtext, "cpMaxRange")
  945. Return $aRet
  946. EndFunc ;==>_GUICtrlRichEdit_FindTextInRange
  947. ; #FUNCTION# ====================================================================================================================
  948. ; Authors........: Chris Haslam (c.haslam)
  949. ; Modified ......: jpm
  950. ; ===============================================================================================================================
  951. Func _GUICtrlRichEdit_GetCharAttributes($hWnd)
  952. Local Const $aV[17][3] = [ _
  953. ["bo", $CFM_BOLD, $CFE_BOLD], ["di", $CFM_DISABLED, $CFE_DISABLED], _
  954. ["em", $CFM_EMBOSS, $CFE_EMBOSS], ["hi", $CFM_HIDDEN, $CFE_HIDDEN], _
  955. ["im", $CFM_IMPRINT, $CFE_IMPRINT], ["it", $CFM_ITALIC, $CFE_ITALIC], _
  956. ["li", $CFM_LINK, $CFE_LINK], ["ou", $CFM_OUTLINE, $CFE_OUTLINE], _
  957. ["pr", $CFM_PROTECTED, $CFE_PROTECTED], ["re", $CFM_REVISED, $CFE_REVISED], _
  958. ["sh", $CFM_SHADOW, $CFE_SHADOW], ["sm", $CFM_SMALLCAPS, $CFE_SMALLCAPS], _
  959. ["st", $CFM_STRIKEOUT, $CFE_STRIKEOUT], ["sb", $CFM_SUBSCRIPT, $CFE_SUBSCRIPT], _
  960. ["sp", $CFM_SUPERSCRIPT, $CFE_SUPERSCRIPT], ["un", $CFM_UNDERLINE, $CFE_UNDERLINE], _
  961. ["al", $CFM_ALLCAPS, $CFE_ALLCAPS]]
  962. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  963. Local $bSel = _GUICtrlRichEdit_IsTextSelected($hWnd)
  964. If Not $bSel Then Return SetError(-1, 0, "")
  965. Local $tCharFormat = DllStructCreate($tagCHARFORMAT2)
  966. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  967. ; $wParam = ($bDefault ? $SCF_DEFAULT : $SCF_SELECTION) ; SCF_DEFAULT doesn't work
  968. Local $iMask = _SendMessage($hWnd, $EM_GETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*")
  969. Local $iEffects = DllStructGetData($tCharFormat, 3)
  970. Local $sStatesAndAtts = "", $sState, $bM, $bE
  971. For $i = 0 To UBound($aV, $UBOUND_ROWS) - 1
  972. $bM = BitAND($iMask, $aV[$i][1]) = $aV[$i][1]
  973. $bE = BitAND($iEffects, $aV[$i][2]) = $aV[$i][2]
  974. If $bSel Then
  975. If $bM Then
  976. If $bE Then
  977. $sState = "+"
  978. Else
  979. $sState = "-"
  980. EndIf
  981. Else
  982. $sState = "~"
  983. EndIf
  984. Else
  985. If $bM Then
  986. $sState = "+"
  987. Else
  988. $sState = "-"
  989. EndIf
  990. EndIf
  991. If $sState <> "-" Then $sStatesAndAtts &= $aV[$i][0] & $sState
  992. Next
  993. Return $sStatesAndAtts
  994. EndFunc ;==>_GUICtrlRichEdit_GetCharAttributes
  995. ; #FUNCTION# ====================================================================================================================
  996. ; Authors........: grham
  997. ; Modified ......: Chris Haslam (c.haslam), jpm
  998. ; ===============================================================================================================================
  999. Func _GUICtrlRichEdit_GetCharBkColor($hWnd)
  1000. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1001. Local $tCharFormat = DllStructCreate($tagCHARFORMAT2)
  1002. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  1003. __GCR_SendGetCharFormatMessage($hWnd, $tCharFormat)
  1004. Local $iEffects = DllStructGetData($tCharFormat, 3)
  1005. Local $iBkColor
  1006. If BitAND($iEffects, $CFE_AUTOBACKCOLOR) = $CFE_AUTOBACKCOLOR Then
  1007. $iBkColor = _WinAPI_GetSysColor($__RICHEDITCONSTANT_COLOR_WINDOWTEXT)
  1008. Else
  1009. $iBkColor = DllStructGetData($tCharFormat, 12)
  1010. EndIf
  1011. Return SetExtended(BitAND($iEffects, $CFM_BACKCOLOR) <> 0, $iBkColor)
  1012. EndFunc ;==>_GUICtrlRichEdit_GetCharBkColor
  1013. ; #FUNCTION# ====================================================================================================================
  1014. ; Authors........: grham
  1015. ; Modified ......: Chris Haslam (c.haslam), jpm
  1016. ; ===============================================================================================================================
  1017. Func _GUICtrlRichEdit_GetCharColor($hWnd)
  1018. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1019. Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
  1020. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  1021. __GCR_SendGetCharFormatMessage($hWnd, $tCharFormat)
  1022. Local $iEffects = DllStructGetData($tCharFormat, 3)
  1023. Local $iColor
  1024. If BitAND($iEffects, $CFE_AUTOCOLOR) = $CFE_AUTOCOLOR Then
  1025. $iColor = _WinAPI_GetSysColor($__RICHEDITCONSTANT_COLOR_WINDOWTEXT)
  1026. Else
  1027. $iColor = DllStructGetData($tCharFormat, 6)
  1028. EndIf
  1029. Return SetExtended(BitAND($iEffects, $CFM_COLOR) <> 0, $iColor)
  1030. EndFunc ;==>_GUICtrlRichEdit_GetCharColor
  1031. ; #FUNCTION# ====================================================================================================================
  1032. ; Author ........: Gary Frost (gafrost)
  1033. ; Modified.......: Prog@ndy, Chris Haslam (c.haslam)
  1034. ; ===============================================================================================================================
  1035. Func _GUICtrlRichEdit_GetCharPosFromXY($hWnd, $iX, $iY)
  1036. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1037. If Not __GCR_IsNumeric($iX) Then Return SetError(102, 0, 0)
  1038. If Not __GCR_IsNumeric($iY) Then Return SetError(103, 0, 0)
  1039. Local $aiRect = _GUICtrlRichEdit_GetRECT($hWnd)
  1040. If $iX < $aiRect[0] Or $iX > $aiRect[2] Or $iY < $aiRect[1] Or $iY > $aiRect[3] Then Return -1
  1041. Local $tPointL = DllStructCreate("LONG x; LONG y;")
  1042. DllStructSetData($tPointL, 1, $iX)
  1043. DllStructSetData($tPointL, 2, $iY)
  1044. Local $iRet = _SendMessage($hWnd, $EM_CHARFROMPOS, 0, $tPointL, 0, "wparam", "struct*")
  1045. If Not $iRet Then Return SetError(-1, 0, 0)
  1046. Return $iRet
  1047. EndFunc ;==>_GUICtrlRichEdit_GetCharPosFromXY
  1048. ; #FUNCTION# ====================================================================================================================
  1049. ; Author ........: Chris Haslam (c.haslam)
  1050. ; Modified.......:
  1051. ; ===============================================================================================================================
  1052. Func _GUICtrlRichEdit_GetCharPosOfNextWord($hWnd, $iCpStart)
  1053. ; WB_RIGHT, WB_LEFT, WB_RIGHTBREAK, WB_LEFTBREAK and WB_ISDELIMITER don't work properly or at all
  1054. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1055. If Not __GCR_IsNumeric($iCpStart) Then Return SetError(102, 0, 0)
  1056. Return _SendMessage($hWnd, $EM_FINDWORDBREAK, $WB_MOVEWORDRIGHT, $iCpStart)
  1057. EndFunc ;==>_GUICtrlRichEdit_GetCharPosOfNextWord
  1058. ; #FUNCTION# ====================================================================================================================
  1059. ; Author ........: Chris Haslam (c.haslam)
  1060. ; Modified.......:
  1061. ; ===============================================================================================================================
  1062. Func _GUICtrlRichEdit_GetCharPosOfPreviousWord($hWnd, $iCpStart)
  1063. ; WB_RIGHT, WB_LEFT, WB_RIGHTBREAK, WB_LEFTBREAK and WB_ISDELIMITER don't work properly or at all
  1064. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1065. If Not __GCR_IsNumeric($iCpStart) Then Return SetError(102, 0, 0)
  1066. Return _SendMessage($hWnd, $EM_FINDWORDBREAK, $WB_MOVEWORDLEFT, $iCpStart)
  1067. EndFunc ;==>_GUICtrlRichEdit_GetCharPosOfPreviousWord
  1068. ; #FUNCTION# ====================================================================================================================
  1069. ; Author ........: Chris Haslam (c.haslam)
  1070. ; Modified.......:
  1071. ; ===============================================================================================================================
  1072. Func _GUICtrlRichEdit_GetCharWordBreakInfo($hWnd, $iCp)
  1073. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1074. If Not __GCR_IsNumeric($iCp) Then Return SetError(102, 0, "")
  1075. Local $iRet = _SendMessage($hWnd, $EM_FINDWORDBREAK, $WB_CLASSIFY, $iCp)
  1076. Local $iClass = BitAND($iRet, 0xF0)
  1077. Local $sRet = ""
  1078. If BitAND($iClass, $WBF_BREAKAFTER) Then $sRet &= "c"
  1079. If BitAND($iClass, $WBF_BREAKLINE) Then $sRet &= "d"
  1080. If BitAND($iClass, $WBF_ISWHITE) Then $sRet &= "w"
  1081. $sRet &= ";" & BitAND($iRet, 0xF)
  1082. Return $sRet
  1083. EndFunc ;==>_GUICtrlRichEdit_GetCharWordBreakInfo
  1084. ; #FUNCTION# ====================================================================================================================
  1085. ; Authors........: jpm
  1086. ; Modified ......:
  1087. ; ===============================================================================================================================
  1088. Func _GUICtrlRichEdit_GetBkColor($hWnd)
  1089. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1090. Local $iBkColor = _SendMessage($hWnd, $EM_SETBKGNDCOLOR, False, 0)
  1091. _SendMessage($hWnd, $EM_SETBKGNDCOLOR, False, $iBkColor)
  1092. Return $iBkColor
  1093. EndFunc ;==>_GUICtrlRichEdit_GetBkColor
  1094. ; #FUNCTION# ====================================================================================================================
  1095. ; Authors........: Prog@ndy
  1096. ; Modified ......: Chris Haslam (c.haslam), jpm, Prog@ndy
  1097. ; ===============================================================================================================================
  1098. Func _GUICtrlRichEdit_GetText($hWnd, $bCrToCrLf = False, $iCodePage = 0, $sReplChar = "")
  1099. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1100. If Not IsBool($bCrToCrLf) Then Return SetError(102, 0, "")
  1101. If Not __GCR_IsNumeric($iCodePage) Then Return SetError(103, 0, "")
  1102. Local $iLen = _GUICtrlRichEdit_GetTextLength($hWnd, False, True) + 1
  1103. Local $sUni = ''
  1104. If $iCodePage = $CP_UNICODE Or Not $iCodePage Then $sUni = "w"
  1105. Local $tText = DllStructCreate($sUni & "char[" & $iLen & "]")
  1106. Local $tGetTextEx = DllStructCreate($tagGETTEXTEX)
  1107. DllStructSetData($tGetTextEx, "cb", DllStructGetSize($tText))
  1108. Local $iFlags = 0
  1109. If $bCrToCrLf Then $iFlags = $GT_USECRLF
  1110. DllStructSetData($tGetTextEx, "flags", $iFlags)
  1111. If $iCodePage = 0 Then $iCodePage = $CP_UNICODE
  1112. DllStructSetData($tGetTextEx, "codepage", $iCodePage)
  1113. Local $pUsedDefChar = 0, $pDefaultChar = 0
  1114. If $sReplChar <> "" Then
  1115. Local $tDefaultChar = DllStructCreate("char")
  1116. $pDefaultChar = DllStructGetPtr($tDefaultChar, 1)
  1117. DllStructSetData($tDefaultChar, 1, $sReplChar)
  1118. Local $tUsedDefChar = DllStructCreate("bool")
  1119. $pUsedDefChar = DllStructGetPtr($tUsedDefChar, 1)
  1120. EndIf
  1121. DllStructSetData($tGetTextEx, "lpDefaultChar", $pDefaultChar)
  1122. DllStructSetData($tGetTextEx, "lpbUsedDefChar", $pUsedDefChar)
  1123. Local $iRet = _SendMessage($hWnd, $EM_GETTEXTEX, $tGetTextEx, $tText, 0, "struct*", "struct*")
  1124. If $iRet = 0 Then Return SetError(700, 0, "")
  1125. If $sReplChar <> "" Then SetExtended(DllStructGetData($tUsedDefChar, 1) <> 0)
  1126. Return DllStructGetData($tText, 1)
  1127. EndFunc ;==>_GUICtrlRichEdit_GetText
  1128. ; #FUNCTION# ====================================================================================================================
  1129. ; Authors........: Prog@ndy
  1130. ; Modified ......: Chris Haslam (c.haslam)
  1131. ; ===============================================================================================================================
  1132. Func _GUICtrlRichEdit_GetTextLength($hWnd, $bExact = True, $bChars = False)
  1133. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1134. If Not IsBool($bExact) Then Return SetError(102, 0, 0)
  1135. If Not IsBool($bChars) Then Return SetError(103, 0, 0)
  1136. Local $tGetTextLen = DllStructCreate($tagGETTEXTLENGTHEX)
  1137. Local $iFlags = BitOR($GTL_USECRLF, ($bExact ? $GTL_PRECISE : $GTL_CLOSE))
  1138. $iFlags = BitOR($iFlags, ($bChars ? $GTL_DEFAULT : $GTL_NUMBYTES))
  1139. DllStructSetData($tGetTextLen, 1, $iFlags)
  1140. DllStructSetData($tGetTextLen, 2, ($bChars ? $CP_ACP : $CP_UNICODE))
  1141. Local $iRet = _SendMessage($hWnd, $EM_GETTEXTLENGTHEX, $tGetTextLen, 0, 0, "struct*")
  1142. Return $iRet
  1143. EndFunc ;==>_GUICtrlRichEdit_GetTextLength
  1144. ; #FUNCTION# ====================================================================================================================
  1145. ; Author ........: Chris Haslam (c.haslam)
  1146. ; Modified.......:
  1147. ; ===============================================================================================================================
  1148. Func _GUICtrlRichEdit_GetZoom($hWnd)
  1149. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1150. Local $wParam = 0, $lParam = 0
  1151. Local $aI = _SendMessage($hWnd, $EM_GETZOOM, $wParam, $lParam, -1, "int*", "int*")
  1152. If Not $aI[0] Then Return SetError(700, 0, 0)
  1153. Local $iRet
  1154. If $aI[3] = 0 And $aI[4] = 0 Then ; if a control that has not been zoomed
  1155. $iRet = 100
  1156. Else
  1157. $iRet = $aI[3] / $aI[4] * 100
  1158. EndIf
  1159. Return StringFormat("%.2f", $iRet)
  1160. EndFunc ;==>_GUICtrlRichEdit_GetZoom
  1161. ; #FUNCTION# ====================================================================================================================
  1162. ; Authors........: Gary Frost (custompcs at charter dot net)
  1163. ; Modified ......: Chris Haslam (c.haslam)
  1164. ; ===============================================================================================================================
  1165. Func _GUICtrlRichEdit_GetFirstCharPosOnLine($hWnd, $iLine = -1)
  1166. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1167. If Not __GCR_IsNumeric($iLine, ">0,-1") Then Return SetError(1021, 0, 0)
  1168. If $iLine <> -1 Then $iLine -= 1
  1169. Local $iRet = _SendMessage($hWnd, $EM_LINEINDEX, $iLine)
  1170. If $iRet = -1 Then Return SetError(1022, 0, 0)
  1171. Return $iRet
  1172. EndFunc ;==>_GUICtrlRichEdit_GetFirstCharPosOnLine
  1173. ; #FUNCTION# ====================================================================================================================
  1174. ; Author ........: Chris Haslam (c.haslam)
  1175. ; Modified.......: jpm
  1176. ; ===============================================================================================================================
  1177. Func _GUICtrlRichEdit_GetFont($hWnd)
  1178. ; MSDN does not give a mask (CFM) for bPitchAndFamily so it appears that there is no way of knowing when it is valid => omitted here
  1179. Local $aRet[3] = [0, "", 0]
  1180. ;, $iLcid = 1033
  1181. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1182. Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
  1183. DllStructSetData($tCharFormat, "cbSize", DllStructGetSize($tCharFormat))
  1184. __GCR_SendGetCharFormatMessage($hWnd, $tCharFormat)
  1185. If BitAND(DllStructGetData($tCharFormat, "dwMask"), $CFM_FACE) = $CFM_FACE Then _
  1186. $aRet[1] = DllStructGetData($tCharFormat, "szFaceName")
  1187. If BitAND(DllStructGetData($tCharFormat, "dwMask"), $CFM_SIZE) = $CFM_SIZE Then _
  1188. $aRet[0] = DllStructGetData($tCharFormat, "yHeight") / 20
  1189. If BitAND(DllStructGetData($tCharFormat, "dwMask"), $CFM_CHARSET) = $CFM_CHARSET Then _
  1190. $aRet[2] = DllStructGetData($tCharFormat, "bCharSet")
  1191. ; available if using $tagCHARFORMAT2
  1192. ;If BitAND(DllStructGetData($tCharFormat, "dwMask"), $CFM_LCID) = $CFM_LCID Then _
  1193. ;$iLcid = DllStructGetData($tCharFormat, 13)
  1194. Return $aRet
  1195. EndFunc ;==>_GUICtrlRichEdit_GetFont
  1196. ; #FUNCTION# ====================================================================================================================
  1197. ; Author ........: Gary Frost (gafrost)
  1198. ; Modified.......: Chris Haslam (c.haslam), jpm
  1199. ; ===============================================================================================================================
  1200. Func _GUICtrlRichEdit_GetRECT($hWnd)
  1201. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1202. Local $tRECT = DllStructCreate($tagRECT)
  1203. _SendMessage($hWnd, $EM_GETRECT, 0, $tRECT, 0, "wparam", "struct*")
  1204. Local $aiRect[4]
  1205. $aiRect[0] = DllStructGetData($tRECT, "Left")
  1206. $aiRect[1] = DllStructGetData($tRECT, "Top")
  1207. $aiRect[2] = DllStructGetData($tRECT, "Right")
  1208. $aiRect[3] = DllStructGetData($tRECT, "Bottom")
  1209. Return $aiRect
  1210. EndFunc ;==>_GUICtrlRichEdit_GetRECT
  1211. ; #FUNCTION# ====================================================================================================================
  1212. ; Authors........: Gary Frost (custompcs at charter dot net)
  1213. ; Modified ......: Chris Haslam (c.haslam)
  1214. ; ===============================================================================================================================
  1215. Func _GUICtrlRichEdit_GetLineCount($hWnd)
  1216. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1217. Return _SendMessage($hWnd, $EM_GETLINECOUNT)
  1218. EndFunc ;==>_GUICtrlRichEdit_GetLineCount
  1219. ; #FUNCTION# ====================================================================================================================
  1220. ; Authors........: Gary Frost (custompcs at charter dot net)
  1221. ; Modified ......: Chris Haslam (c.haslam)
  1222. ; ===============================================================================================================================
  1223. Func _GUICtrlRichEdit_GetLineLength($hWnd, $iLine)
  1224. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1225. If Not __GCR_IsNumeric($iLine, ">0,-1") Then Return SetError(102, 0, 0)
  1226. Local $iCharPos = _GUICtrlRichEdit_GetFirstCharPosOnLine($hWnd, $iLine)
  1227. Local $iRet = _SendMessage($hWnd, $EM_LINELENGTH, $iCharPos)
  1228. Return $iRet
  1229. EndFunc ;==>_GUICtrlRichEdit_GetLineLength
  1230. ; #FUNCTION# ====================================================================================================================
  1231. ; Authors........: Chris Haslam (c.haslam)
  1232. ; Modified ......:
  1233. ; ===============================================================================================================================
  1234. Func _GUICtrlRichEdit_GetLineNumberFromCharPos($hWnd, $iCharPos)
  1235. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1236. If Not __GCR_IsNumeric($iCharPos, ">=0") Then Return SetError(102, 0, 0)
  1237. Return _SendMessage($hWnd, $EM_EXLINEFROMCHAR, 0, $iCharPos) + 1
  1238. EndFunc ;==>_GUICtrlRichEdit_GetLineNumberFromCharPos
  1239. ; #FUNCTION# ====================================================================================================================
  1240. ; Author ........: Prog@ndy
  1241. ; Modified.......: Chris Haslam (c.haslam)
  1242. ; ===============================================================================================================================
  1243. Func _GUICtrlRichEdit_GetNextRedo($hWnd, $bName = True)
  1244. Local Const $aS[6] = ["Unknown", "Typing", "Delete", "Drag and drop", "Cut", "Paste"]
  1245. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1246. If Not IsBool($bName) Then Return SetError(102, 0, "")
  1247. Local $iUid = _SendMessage($hWnd, $EM_GETREDONAME, 0, 0)
  1248. If $bName Then
  1249. Return $aS[$iUid]
  1250. Else
  1251. Return $iUid
  1252. EndIf
  1253. EndFunc ;==>_GUICtrlRichEdit_GetNextRedo
  1254. ; #FUNCTION# ====================================================================================================================
  1255. ; Author ........: Prog@ndy
  1256. ; Modified.......: Chris Haslam (c.haslam)
  1257. ; ===============================================================================================================================
  1258. Func _GUICtrlRichEdit_GetNextUndo($hWnd, $bName = True)
  1259. Local Const $aS[6] = ["Unknown", "Typing", "Delete", "Drag and drop", "Cut", "Paste"]
  1260. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1261. If Not IsBool($bName) Then Return SetError(102, 0, "")
  1262. Local $iUid = _SendMessage($hWnd, $EM_GETUNDONAME, 0, 0)
  1263. If $bName Then
  1264. Return $aS[$iUid]
  1265. Else
  1266. Return $iUid
  1267. EndIf
  1268. EndFunc ;==>_GUICtrlRichEdit_GetNextUndo
  1269. ; #FUNCTION# ====================================================================================================================
  1270. ; Author ........: Gary Frost (gafrost)
  1271. ; Modified.......:
  1272. ; ===============================================================================================================================
  1273. Func _GUICtrlRichEdit_GetNumberOfFirstVisibleLine($hWnd)
  1274. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1275. Return _SendMessage($hWnd, $EM_GETFIRSTVISIBLELINE) + 1
  1276. EndFunc ;==>_GUICtrlRichEdit_GetNumberOfFirstVisibleLine
  1277. ; #FUNCTION# ====================================================================================================================
  1278. ; Authors........: Chris Haslam (c.haslam)
  1279. ; Modified ......:
  1280. ; ===============================================================================================================================
  1281. Func _GUICtrlRichEdit_GetParaAlignment($hWnd)
  1282. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1283. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1284. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  1285. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1286. If @error Then Return SetError(@error, 0, "")
  1287. Local $iMask = DllStructGetData($tParaFormat, 2)
  1288. Local $iAlignment = DllStructGetData($tParaFormat, 8)
  1289. Local $sRet = ""
  1290. Switch ($iAlignment)
  1291. Case $PFA_LEFT
  1292. $sRet = "l"
  1293. Case $PFA_CENTER
  1294. $sRet = "c"
  1295. Case $PFA_RIGHT
  1296. $sRet = "r"
  1297. Case $PFA_JUSTIFY
  1298. $sRet = "j"
  1299. Case $PFA_FULL_INTERWORD
  1300. $sRet = "w"
  1301. EndSwitch
  1302. $sRet &= ";" & __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_ALIGNMENT)
  1303. Return $sRet
  1304. EndFunc ;==>_GUICtrlRichEdit_GetParaAlignment
  1305. ; #FUNCTION# ====================================================================================================================
  1306. ; Authors........: Chris Haslam (c.haslam)
  1307. ; Modified ......:
  1308. ; ===============================================================================================================================
  1309. Func _GUICtrlRichEdit_GetParaAttributes($hWnd)
  1310. ; dwMask is always BitOR of all PFMs
  1311. Local Enum $eAbbrev = 0, $eEffect, $eInverted
  1312. ; MS seems to mean LINENUMBER and WIDOWCONTROL, not NOLINENUMBER and NOWIDOWCONTROL
  1313. Local Const $aV[9][3] = [ _ ; abbrev, mask, effect, inverted
  1314. ["fpg", $PFE_PAGEBREAKBEFORE, False], _
  1315. ["hyp", $PFE_DONOTHYPHEN, True], _
  1316. ["kpt", $PFE_KEEP, False], _
  1317. ["kpn", $PFE_KEEPNEXT, False], _
  1318. ["pwo", $PFE_NOWIDOWCONTROL, False], _
  1319. ["r2l", $PFE_RTLPARA, False], _
  1320. ["row", $PFE_TABLE, False], _
  1321. ["sbs", $PFE_SIDEBYSIDE, False], _
  1322. ["sln", $PFE_NOLINENUMBER, False]]
  1323. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1324. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1325. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  1326. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1327. If @error Then Return SetError(@error, 0, "")
  1328. Local $iEffects = DllStructGetData($tParaFormat, "wEffects")
  1329. Local $sStatesAndAtts = "", $sState
  1330. For $i = 0 To UBound($aV, $UBOUND_ROWS) - 1
  1331. $sStatesAndAtts &= $aV[$i][$eAbbrev]
  1332. If BitAND($iEffects, $aV[$i][$eEffect]) = $aV[$i][$eEffect] Then
  1333. $sState = ($aV[$i][$eInverted] ? "-" : "+")
  1334. Else
  1335. $sState = ($aV[$i][$eInverted] ? "+" : "-")
  1336. EndIf
  1337. $sStatesAndAtts &= $sState & ";"
  1338. Next
  1339. $sStatesAndAtts &= (_GUICtrlRichEdit_IsTextSelected($hWnd) ? "f" : "c")
  1340. Return $sStatesAndAtts
  1341. EndFunc ;==>_GUICtrlRichEdit_GetParaAttributes
  1342. ; #FUNCTION# ====================================================================================================================
  1343. ; Authors........: Chris Haslam (c.haslam)
  1344. ; Modified ......:
  1345. ; ===============================================================================================================================
  1346. Func _GUICtrlRichEdit_GetParaBorder($hWnd)
  1347. Local Const $avLocs[6][2] = [["l", 1], ["r", 2], ["t", 4], ["b", 8], ["i", 16], ["o", 32]]
  1348. Local Const $avLS[12] = ["none", .75, 1.5, 2.25, 3, 4.5, 6, ".75d", "1.5d", "2.25d", ".75g", ".75gd"]
  1349. Local Const $sClrs = "blk;blu;cyn;grn;mag;red;yel;whi;dbl;dgn;dmg;drd;dyl;dgy;lgy;"
  1350. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1351. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1352. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  1353. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1354. If @error Then Return SetError(@error, 0, "")
  1355. Local $iMask = DllStructGetData($tParaFormat, 2)
  1356. Local $iSpace = DllStructGetData($tParaFormat, 22)
  1357. ; $iWidth = DllStructGetData($tParaFormat, 23) ; wBorderWidth does not round-trip in Rich Edit 3.0
  1358. Local $iBorders = DllStructGetData($tParaFormat, 24)
  1359. Local $sRet = ""
  1360. For $i = 0 To UBound($avLocs, $UBOUND_ROWS) - 1
  1361. If BitAND($iBorders, $avLocs[$i][1]) Then $sRet &= $avLocs[$i][0]
  1362. Next
  1363. $sRet &= ";"
  1364. $sRet &= $avLS[BitShift(BitAND($iBorders, 0xF00), 8)]
  1365. $sRet &= ";"
  1366. If BitAND($iBorders, 64) Then
  1367. $sRet &= "aut"
  1368. Else
  1369. $sRet &= StringMid($sClrs, BitShift(BitAND($iBorders, 0xF000), 12) * 4 + 1, 3)
  1370. EndIf
  1371. $sRet &= ";"
  1372. $sRet &= __GCR_ConvertTwipsToSpaceUnit($iSpace) & ";" ; & __GCR_ConvertTwipsToSpaceUnit($iWidth) & ";"
  1373. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_BORDER)
  1374. Return $sRet
  1375. EndFunc ;==>_GUICtrlRichEdit_GetParaBorder
  1376. ; #FUNCTION# ====================================================================================================================
  1377. ; Authors........: Chris Haslam (c.haslam)
  1378. ; Modified ......:
  1379. ; ===============================================================================================================================
  1380. Func _GUICtrlRichEdit_GetParaIndents($hWnd)
  1381. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1382. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1383. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  1384. DllStructSetData($tParaFormat, "dwMask", BitOR($PFM_STARTINDENT, $PFM_OFFSET))
  1385. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1386. If @error Then Return SetError(@error, 0, "")
  1387. Local $iMask = DllStructGetData($tParaFormat, "dwMask")
  1388. Local $iIdxSI = DllStructGetData($tParaFormat, "dxStartIndent") ; absolute
  1389. Local $iIdxOfs = DllStructGetData($tParaFormat, "dxOffset")
  1390. Local $iDxRI = DllStructGetData($tParaFormat, "dxRightIndent")
  1391. Local $iLeft = __GCR_ConvertTwipsToSpaceUnit($iIdxSI + $iIdxOfs)
  1392. Local $iFirstLine = __GCR_ConvertTwipsToSpaceUnit(-$iIdxOfs)
  1393. Local $iRight = __GCR_ConvertTwipsToSpaceUnit($iDxRI)
  1394. Local $iRet = $iLeft & ";" & $iRight & ";" & $iFirstLine & ";" & __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_STARTINDENT)
  1395. Return $iRet
  1396. EndFunc ;==>_GUICtrlRichEdit_GetParaIndents
  1397. ; #FUNCTION# ====================================================================================================================
  1398. ; Authors........: Chris Haslam (c.haslam)
  1399. ; Modified ......:
  1400. ; ===============================================================================================================================
  1401. Func _GUICtrlRichEdit_GetParaNumbering($hWnd)
  1402. Local Const $avRoman[7][2] = [[1000, "m"], [500, "d"], [100, "c"], [50, "l"], [10, "x"], [5, "v"], [1, "i"]]
  1403. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1404. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1405. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  1406. DllStructSetData($tParaFormat, 2, BitOR($PFM_NUMBERING, $PFM_NUMBERINGSTART, $PFM_NUMBERINGSTYLE))
  1407. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1408. If @error Then Return SetError(@error, 0, "")
  1409. Local $iMask = DllStructGetData($tParaFormat, "dwMask")
  1410. Local $iChar = DllStructGetData($tParaFormat, "wNumbering")
  1411. Local $iStart = DllStructGetData($tParaFormat, "wNumberingStart")
  1412. Local $iStyle = DllStructGetData($tParaFormat, "wNumberingStyle")
  1413. Local $iTab = DllStructGetData($tParaFormat, "wNumberingTab")
  1414. Local $sRet = ""
  1415. Switch $iChar
  1416. Case 0 ; no numbering
  1417. $sRet = ""
  1418. Case 1 ; bullet
  1419. $sRet = "."
  1420. Case 2 ; Arabic
  1421. $sRet = $iStart
  1422. Case 3
  1423. $sRet = Chr(Asc("a") + $iStart - 1)
  1424. Case 4
  1425. $sRet = Chr(Asc("a") + $iStart - 1)
  1426. Case 5, 6 ; lower case Roman
  1427. For $i = 0 To UBound($avRoman, $UBOUND_ROWS) - 2 Step 2
  1428. For $j = $i To $i + 1
  1429. While $iStart >= $avRoman[$j][0]
  1430. $sRet &= $avRoman[$j][1]
  1431. $iStart -= $avRoman[$j][0]
  1432. WEnd
  1433. If $iStart = $avRoman[$j][0] - 1 Then
  1434. $sRet &= $avRoman[$i + 2][1] & $avRoman[$j][1]
  1435. $iStart -= $avRoman[$j][0] - $avRoman[$i + 2][0]
  1436. EndIf
  1437. Next
  1438. Next
  1439. While $iStart > 0
  1440. $sRet &= "i"
  1441. $iStart -= 1
  1442. WEnd
  1443. If $iChar = 6 Then $sRet = StringUpper($sRet)
  1444. EndSwitch
  1445. If $iChar > 1 Then
  1446. Switch $iStyle
  1447. Case 0
  1448. $sRet &= ")"
  1449. Case 0x100
  1450. $sRet = "(" & $sRet & ")"
  1451. Case 0x200
  1452. $sRet &= "."
  1453. Case 0x300 ; display only number
  1454. ; do nothing
  1455. EndSwitch
  1456. EndIf
  1457. ; set number-to-text spacing based on font at anchor
  1458. Local $aV = _GUICtrlRichEdit_GetFont($hWnd)
  1459. Local $iPoints = $aV[0]
  1460. Local $iQspaces = Round($iTab / ($iPoints * 20), 0)
  1461. For $i = 1 To $iQspaces
  1462. $sRet &= " "
  1463. Next
  1464. $sRet &= ";"
  1465. $sRet &= (($iChar = 5 Or $iChar = 6) ? "Roman;" : ";")
  1466. $sRet &= __GCR_ConvertTwipsToSpaceUnit($iTab) & ";"
  1467. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, BitOR($PFM_NUMBERING, $PFM_NUMBERINGSTART, $PFM_NUMBERINGSTYLE))
  1468. Return $sRet
  1469. EndFunc ;==>_GUICtrlRichEdit_GetParaNumbering
  1470. ; #FUNCTION# ====================================================================================================================
  1471. ; Authors........: Chris Haslam (c.haslam)
  1472. ; Modified ......:
  1473. ; ===============================================================================================================================
  1474. Func _GUICtrlRichEdit_GetParaShading($hWnd)
  1475. Local Const $asStyles[13] = ["non", "dhz", "dvt", "ddd", "dud", "dgr", "dtr", "lhz", "lrt", "ldd", "lud", _
  1476. "lgr", "ltr"]
  1477. Local Const $asClrs[16] = ["blk", "blu", "cyn", "grn", "mag", "red", "yel", "whi", "dbl", "dgn", "dmg", _
  1478. "drd", "dyl", "dgy", "lgy"]
  1479. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1480. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1481. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  1482. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1483. If @error Then Return SetError(@error, 0, "")
  1484. Local $iMask = DllStructGetData($tParaFormat, "dwMask")
  1485. Local $iWeight = DllStructGetData($tParaFormat, "wShadingWeight")
  1486. Local $iS = DllStructGetData($tParaFormat, "wShadingStyle")
  1487. Local $sRet = $iWeight & ";"
  1488. Local $iN = BitAND($iS, 0xF)
  1489. $sRet &= $asStyles[$iN] & ";"
  1490. $iN = BitShift(BitAND($iS, 0xF0), 4)
  1491. $sRet &= $asClrs[$iN] & ";"
  1492. $iN = BitShift(BitAND($iS, 0xF00), 8)
  1493. $sRet &= $asClrs[$iN] & ";"
  1494. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_SHADING)
  1495. Return $sRet
  1496. EndFunc ;==>_GUICtrlRichEdit_GetParaShading
  1497. ; #FUNCTION# ====================================================================================================================
  1498. ; Authors........: Chris Haslam (c.haslam)
  1499. ; Modified ......:
  1500. ; ===============================================================================================================================
  1501. Func _GUICtrlRichEdit_GetParaSpacing($hWnd)
  1502. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1503. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  1504. DllStructSetData($tParaFormat, "cbSize", DllStructGetSize($tParaFormat))
  1505. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1506. If @error Then Return SetError(@error, 0, "")
  1507. Local $iInter = DllStructGetData($tParaFormat, "dyLineSpacing")
  1508. Local $iRule = DllStructGetData($tParaFormat, "bLineSpacingRule")
  1509. Local $sRet = ""
  1510. Switch $iRule
  1511. Case 0
  1512. $sRet = "1 line;"
  1513. Case 1
  1514. $sRet = "1.5 lines;"
  1515. Case 2
  1516. $sRet = "2 lines;"
  1517. Case 3, 4
  1518. $sRet = __GCR_ConvertTwipsToSpaceUnit($iInter) & ";"
  1519. Case 5
  1520. $sRet = StringFormat("%.2f", $iInter / 20) & " lines;"
  1521. EndSwitch
  1522. Local $iMask = 0 ; perhaps a BUG (jpm) always 0
  1523. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_LINESPACING) & ";"
  1524. Local $iBefore = DllStructGetData($tParaFormat, "dySpaceBefore")
  1525. $sRet &= __GCR_ConvertTwipsToSpaceUnit($iBefore) & ";"
  1526. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_SPACEBEFORE) & ";"
  1527. Local $iAfter = DllStructGetData($tParaFormat, "dySPaceAfter")
  1528. $sRet &= __GCR_ConvertTwipsToSpaceUnit($iAfter) & ";"
  1529. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_SPACEAFTER)
  1530. Return $sRet
  1531. EndFunc ;==>_GUICtrlRichEdit_GetParaSpacing
  1532. ; #FUNCTION# ====================================================================================================================
  1533. ; Authors........: Chris Haslam (c.haslam)
  1534. ; Modified ......:
  1535. ; ===============================================================================================================================
  1536. Func _GUICtrlRichEdit_GetParaTabStops($hWnd)
  1537. Local Const $asKind[5] = ["l", "c", "r", "d", "b"], $asLeader[6] = [" ", ".", "-", "_", "t", "="]
  1538. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  1539. Local $tParaFormat = DllStructCreate($tagPARAFORMAT)
  1540. DllStructSetData($tParaFormat, "cbSize", DllStructGetSize($tParaFormat))
  1541. __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  1542. If @error Then Return SetError(@error, 0, "")
  1543. Local $iMask = DllStructGetData($tParaFormat, "dwMask")
  1544. Local $iQtabs = DllStructGetData($tParaFormat, "cTabCount")
  1545. Local $sRet = $iQtabs & ";"
  1546. Local $iN, $iM
  1547. For $i = 1 To $iQtabs
  1548. $iN = DllStructGetData($tParaFormat, "rgxTabs", $i)
  1549. $sRet &= __GCR_ConvertTwipsToSpaceUnit(BitAND($iN, 0xFFFFF))
  1550. $iM = BitAND(BitShift($iN, 24), 0xF)
  1551. $sRet &= $asKind[$iM]
  1552. $iM = BitAND(BitShift($iN, 28), 0xF)
  1553. $sRet &= $asLeader[$iM] & ";"
  1554. Next
  1555. $sRet &= __GCR_GetParaScopeChar($hWnd, $iMask, $PFM_TABSTOPS)
  1556. Return $sRet
  1557. EndFunc ;==>_GUICtrlRichEdit_GetParaTabStops
  1558. ; #FUNCTION# ====================================================================================================================
  1559. ; Author ........: Gary Frost
  1560. ; Modified.......: Chris Haslam (c.haslam)
  1561. ; ===============================================================================================================================
  1562. Func _GUICtrlRichEdit_GetPasswordChar($hWnd)
  1563. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1564. Local $n = _SendMessage($hWnd, $EM_GETPASSWORDCHAR)
  1565. Return ($n = 0) ? "" : Chr($n)
  1566. EndFunc ;==>_GUICtrlRichEdit_GetPasswordChar
  1567. ; #FUNCTION# ====================================================================================================================
  1568. ; Author ........: unknown
  1569. ; Modified.......: Chris Haslam (c.haslam), jpm
  1570. ; ===============================================================================================================================
  1571. Func _GUICtrlRichEdit_GetScrollPos($hWnd)
  1572. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1573. Local $tPoint = DllStructCreate($tagPOINT)
  1574. _SendMessage($hWnd, $EM_GETSCROLLPOS, 0, $tPoint, 0, "wparam", "struct*")
  1575. Local $aRet[2]
  1576. $aRet[0] = DllStructGetData($tPoint, "x")
  1577. $aRet[1] = DllStructGetData($tPoint, "y")
  1578. Return $aRet
  1579. EndFunc ;==>_GUICtrlRichEdit_GetScrollPos
  1580. ; #FUNCTION# ====================================================================================================================
  1581. ; Author ........: Prog@ndy
  1582. ; Modified.......: Chris Haslam (c.haslam), jpm
  1583. ; ===============================================================================================================================
  1584. Func _GUICtrlRichEdit_GetSel($hWnd)
  1585. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1586. Local $tCharRange = DllStructCreate($tagCHARRANGE)
  1587. _SendMessage($hWnd, $EM_EXGETSEL, 0, $tCharRange, 0, "wparam", "struct*")
  1588. Local $aRet[2]
  1589. $aRet[0] = DllStructGetData($tCharRange, 1)
  1590. $aRet[1] = DllStructGetData($tCharRange, 2)
  1591. Return $aRet
  1592. EndFunc ;==>_GUICtrlRichEdit_GetSel
  1593. ; #FUNCTION# ====================================================================================================================
  1594. ; Author ........: Prog@ndy
  1595. ; Modified.......: Chris Haslam (c.haslam), jpm
  1596. ; ===============================================================================================================================
  1597. Func _GUICtrlRichEdit_GetSelAA($hWnd)
  1598. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1599. Local $aiLowHigh = _GUICtrlRichEdit_GetSel($hWnd)
  1600. If $aiLowHigh[0] = $aiLowHigh[1] Then Return SetError(-1, 0, 0) ; no text selected
  1601. _SendMessage($hWnd, $EM_SETSEL, -1, 0) ; deselect
  1602. Local $aiNoSel = _GUICtrlRichEdit_GetSel($hWnd)
  1603. Local $aRet[2]
  1604. If $aiLowHigh[0] = $aiNoSel[0] Then ; if active < anchor
  1605. $aRet[0] = $aiLowHigh[1]
  1606. $aRet[1] = $aiLowHigh[0]
  1607. Else
  1608. $aRet = $aiLowHigh
  1609. EndIf
  1610. ; restore selection
  1611. _SendMessage($hWnd, $EM_SETSEL, $aiLowHigh[0], $aiLowHigh[1])
  1612. _WinAPI_SetFocus($hWnd) ; need to have the selection updated
  1613. Return $aRet
  1614. EndFunc ;==>_GUICtrlRichEdit_GetSelAA
  1615. ; #FUNCTION# ====================================================================================================================
  1616. ; Author ........: Prog@ndy
  1617. ; Modified.......: Chris Haslam (c.haslam)
  1618. ; ===============================================================================================================================
  1619. Func _GUICtrlRichEdit_GetSelText($hWnd)
  1620. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1621. If Not _GUICtrlRichEdit_IsTextSelected($hWnd) Then Return SetError(-1, 0, -1)
  1622. Local $aiLowHigh = _GUICtrlRichEdit_GetSel($hWnd)
  1623. Local $tText = DllStructCreate("wchar[" & $aiLowHigh[1] - $aiLowHigh[0] + 1 & "]")
  1624. _SendMessage($hWnd, $EM_GETSELTEXT, 0, $tText, 0, "wparam", "struct*")
  1625. Return DllStructGetData($tText, 1)
  1626. EndFunc ;==>_GUICtrlRichEdit_GetSelText
  1627. ; #FUNCTION# ====================================================================================================================
  1628. ; Author ........: Chris Haslam (c.haslam)
  1629. ; Modified.......:
  1630. ; ===============================================================================================================================
  1631. Func _GUICtrlRichEdit_GetSpaceUnit()
  1632. Switch $__g_iRTFTwipsPeSpaceUnit
  1633. Case 1440
  1634. Return "in"
  1635. Case 567
  1636. Return "cm"
  1637. Case 56.7
  1638. Return "mm"
  1639. Case 20
  1640. Return "pt"
  1641. Case 1
  1642. Return "tw"
  1643. EndSwitch
  1644. EndFunc ;==>_GUICtrlRichEdit_GetSpaceUnit
  1645. ; #FUNCTION# ====================================================================================================================
  1646. ; Authors........: Gary Frost (gafrost (custompcs@charter.net))
  1647. ; Modified ......: Chris Haslam (c.haslam)
  1648. ; ===============================================================================================================================
  1649. Func _GUICtrlRichEdit_GetTextInLine($hWnd, $iLine)
  1650. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1651. If Not __GCR_IsNumeric($iLine, ">0,-1") Then Return SetError(1021, 0, False)
  1652. If $iLine > _GUICtrlRichEdit_GetLineCount($hWnd) Then Return SetError(1022, 0, False)
  1653. Local $iLen = _GUICtrlRichEdit_GetLineLength($hWnd, $iLine)
  1654. If $iLen = 0 Then Return ""
  1655. Local $tBuffer = DllStructCreate("short Len;wchar Text[" & $iLen + 2 & "]")
  1656. DllStructSetData($tBuffer, "Len", $iLen + 2)
  1657. If $iLine <> -1 Then $iLine -= 1
  1658. Local $iRet = _SendMessage($hWnd, $EM_GETLINE, $iLine, $tBuffer, 10, "wparam", "struct*")
  1659. If $iRet = 0 Then Return SetError(700, 0, False)
  1660. Local $tString = DllStructCreate("wchar Text[" & $iLen + 1 & "]", DllStructGetPtr($tBuffer))
  1661. Return StringLeft(DllStructGetData($tString, "Text"), $iLen)
  1662. EndFunc ;==>_GUICtrlRichEdit_GetTextInLine
  1663. ; #FUNCTION# ====================================================================================================================
  1664. ; Authors........: Gary Frost (gafrost (custompcs@charter.net))
  1665. ; Modified ......: Prog@ndy, Chris Haslam (c.haslam)
  1666. ; ===============================================================================================================================
  1667. Func _GUICtrlRichEdit_GetTextInRange($hWnd, $iStart, $iEnd)
  1668. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1669. If Not __GCR_IsNumeric($iStart, ">=0") Then Return SetError(102, 0, False)
  1670. If Not __GCR_IsNumeric($iEnd, ">=0,-1") Then Return SetError(1031, 0, False)
  1671. If Not ($iEnd > $iStart Or $iEnd = -1) Then Return SetError(1032, 0, False)
  1672. Local $iLen = _GUICtrlRichEdit_GetTextLength($hWnd) ; can't use $iEnd - $iStart + 1 because of Unicode
  1673. Local $tText = DllStructCreate("wchar[" & ($iLen + 4) & "]")
  1674. Local $tTextRange = DllStructCreate($tagTEXTRANGE)
  1675. DllStructSetData($tTextRange, 1, $iStart)
  1676. DllStructSetData($tTextRange, 2, $iEnd)
  1677. DllStructSetData($tTextRange, 3, DllStructGetPtr($tText))
  1678. _SendMessage($hWnd, $EM_GETTEXTRANGE, 0, $tTextRange, 0, "wparam", "struct*")
  1679. Return DllStructGetData($tText, 1)
  1680. EndFunc ;==>_GUICtrlRichEdit_GetTextInRange
  1681. ; #FUNCTION# ====================================================================================================================
  1682. ; Author ........: Chris Haslam (c.haslam)
  1683. ; Modified.......:
  1684. ; ===============================================================================================================================
  1685. Func _GUICtrlRichEdit_GetVersion()
  1686. Return $__g_sRTFVersion
  1687. EndFunc ;==>_GUICtrlRichEdit_GetVersion
  1688. ; #FUNCTION# ====================================================================================================================
  1689. ; Author ........: Chris Haslam (c.haslam)
  1690. ; Modified.......: jpm
  1691. ; ===============================================================================================================================
  1692. Func _GUICtrlRichEdit_GetXYFromCharPos($hWnd, $iCharPos)
  1693. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1694. If Not __GCR_IsNumeric($iCharPos, ">=0") Then Return SetError(1021, 0, 0)
  1695. If $iCharPos > _GUICtrlRichEdit_GetTextLength($hWnd) Then Return SetError(1022, 0, 0)
  1696. Local $tPoint = DllStructCreate($tagPOINT)
  1697. _SendMessage($hWnd, $EM_POSFROMCHAR, $tPoint, $iCharPos, 0, "struct*", "lparam")
  1698. Local $aRet[2]
  1699. $aRet[0] = DllStructGetData($tPoint, "X")
  1700. $aRet[1] = DllStructGetData($tPoint, "Y")
  1701. Return $aRet
  1702. EndFunc ;==>_GUICtrlRichEdit_GetXYFromCharPos
  1703. ; #FUNCTION# ====================================================================================================================
  1704. ; Author ........: Chris Haslam (c.haslam)
  1705. ; Modified.......:
  1706. ; ===============================================================================================================================
  1707. Func _GUICtrlRichEdit_GotoCharPos($hWnd, $iCharPos)
  1708. _GUICtrlRichEdit_SetSel($hWnd, $iCharPos, $iCharPos)
  1709. If @error Then Return SetError(@error, 0, False)
  1710. Return True
  1711. EndFunc ;==>_GUICtrlRichEdit_GotoCharPos
  1712. ; #FUNCTION# ====================================================================================================================
  1713. ; Author ........: Prog@ndy
  1714. ; Modified.......: Chris Haslam (c.haslam), jpm
  1715. ; ===============================================================================================================================
  1716. Func _GUICtrlRichEdit_HideSelection($hWnd, $bHide = True)
  1717. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1718. If Not IsBool($bHide) Then Return SetError(102, 0, False)
  1719. _SendMessage($hWnd, $EM_HIDESELECTION, $bHide, 0)
  1720. _WinAPI_SetFocus($hWnd) ; need to have the selection updated
  1721. EndFunc ;==>_GUICtrlRichEdit_HideSelection
  1722. ; #FUNCTION# ====================================================================================================================
  1723. ; Authors........: Gary Frost (gafrost (custompcs@charter.net)
  1724. ; Modified ......: Prog@ndy, Chris Haslam (c.haslam)
  1725. ; ===============================================================================================================================
  1726. Func _GUICtrlRichEdit_InsertText($hWnd, $sText)
  1727. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1728. If $sText = "" Then Return SetError(102, 0, False)
  1729. Local $tSetText = DllStructCreate($tagSETTEXTEX)
  1730. DllStructSetData($tSetText, 1, $ST_SELECTION)
  1731. _GUICtrlRichEdit_Deselect($hWnd)
  1732. Local $iRet
  1733. If StringLeft($sText, 5) <> "{\rtf" And StringLeft($sText, 5) <> "{urtf" Then
  1734. DllStructSetData($tSetText, 2, $CP_UNICODE)
  1735. $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "wstr")
  1736. Else
  1737. DllStructSetData($tSetText, 2, $CP_ACP)
  1738. $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "STR")
  1739. EndIf
  1740. If Not $iRet Then Return SetError(103, 0, False) ; cannot be set
  1741. Return True
  1742. EndFunc ;==>_GUICtrlRichEdit_InsertText
  1743. ; #FUNCTION# ====================================================================================================================
  1744. ; Author ........: Gary Frost (gafrost)
  1745. ; Modified.......: Chris Haslam (c.haslam)
  1746. ; ===============================================================================================================================
  1747. Func _GUICtrlRichEdit_IsModified($hWnd)
  1748. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1749. Return _SendMessage($hWnd, $EM_GETMODIFY) <> 0
  1750. EndFunc ;==>_GUICtrlRichEdit_IsModified
  1751. ; #FUNCTION# ====================================================================================================================
  1752. ; Authors........: Chris Haslam (c.haslam)
  1753. ; Modified ......:
  1754. ; ===============================================================================================================================
  1755. Func _GUICtrlRichEdit_IsTextSelected($hWnd)
  1756. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1757. Local $tCharRange = DllStructCreate($tagCHARRANGE)
  1758. _SendMessage($hWnd, $EM_EXGETSEL, 0, $tCharRange, 0, "wparam", "struct*")
  1759. Return DllStructGetData($tCharRange, 2) <> DllStructGetData($tCharRange, 1)
  1760. EndFunc ;==>_GUICtrlRichEdit_IsTextSelected
  1761. ; #FUNCTION# ====================================================================================================================
  1762. ; Authors........: Prog@ndy
  1763. ; Modified ......: Chris Haslam (c.haslam)
  1764. ; ===============================================================================================================================
  1765. Func _GUICtrlRichEdit_Paste($hWnd)
  1766. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1767. _SendMessage($hWnd, $__RICHEDITCONSTANT_WM_PASTE, 0, 0)
  1768. Return True
  1769. EndFunc ;==>_GUICtrlRichEdit_Paste
  1770. ; #FUNCTION# ====================================================================================================================
  1771. ; Authors........: Prog@ndy
  1772. ; Modified ......: Chris Haslam (c.haslam)
  1773. ; ===============================================================================================================================
  1774. Func _GUICtrlRichEdit_PasteSpecial($hWnd, $bAndObjects = True)
  1775. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1776. Local $iN = ($bAndObjects ? $__g_sGRE_CF_RETEXTOBJ : $__g_sGRE_CF_RTF)
  1777. _SendMessage($hWnd, $EM_PASTESPECIAL, $iN, 0)
  1778. Return True
  1779. EndFunc ;==>_GUICtrlRichEdit_PasteSpecial
  1780. ; #FUNCTION# ====================================================================================================================
  1781. ; Authors........: unknown
  1782. ; Modified ......: Chris Haslam (c.haslam)
  1783. ; ===============================================================================================================================
  1784. Func _GUICtrlRichEdit_PauseRedraw($hWnd)
  1785. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1786. _SendMessage($hWnd, $__RICHEDITCONSTANT_WM_SETREDRAW, False)
  1787. EndFunc ;==>_GUICtrlRichEdit_PauseRedraw
  1788. ; #FUNCTION# ====================================================================================================================
  1789. ; Authors........: Prog@ndy
  1790. ; Modified ......: Chris Haslam (c.haslam)
  1791. ; ===============================================================================================================================
  1792. Func _GUICtrlRichEdit_Redo($hWnd)
  1793. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1794. Return _SendMessage($hWnd, $EM_REDO, 0, 0) <> 0
  1795. EndFunc ;==>_GUICtrlRichEdit_Redo
  1796. ; #FUNCTION# ====================================================================================================================
  1797. ; Authors........: Gary Frost (gafrost)
  1798. ; Modified ......: Chris Haslam (c.haslam), jpm
  1799. ; ===============================================================================================================================
  1800. Func _GUICtrlRichEdit_ReplaceText($hWnd, $sText, $bCanUndo = True)
  1801. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1802. If Not IsBool($bCanUndo) Then Return SetError(103, 0, False)
  1803. If Not _GUICtrlRichEdit_IsTextSelected($hWnd) Then Return SetError(-1, 0, False)
  1804. Local $tText = DllStructCreate("wchar Text[" & StringLen($sText) + 1 & "]")
  1805. DllStructSetData($tText, "Text", $sText)
  1806. If _WinAPI_InProcess($hWnd, $__g_hRELastWnd) Then
  1807. _SendMessage($hWnd, $EM_REPLACESEL, $bCanUndo, $tText, 0, "wparam", "struct*")
  1808. Else
  1809. Local $iText = DllStructGetSize($tText)
  1810. Local $tMemMap
  1811. Local $pMemory = _MemInit($hWnd, $iText, $tMemMap)
  1812. _MemWrite($tMemMap, $tText)
  1813. _SendMessage($hWnd, $EM_REPLACESEL, $bCanUndo, $pMemory, 0, "wparam", "ptr")
  1814. _MemFree($tMemMap)
  1815. EndIf
  1816. Return True
  1817. EndFunc ;==>_GUICtrlRichEdit_ReplaceText
  1818. ; #FUNCTION# ====================================================================================================================
  1819. ; Authors........: unknown
  1820. ; Modified ......:
  1821. ; ===============================================================================================================================
  1822. Func _GUICtrlRichEdit_ResumeRedraw($hWnd)
  1823. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1824. _SendMessage($hWnd, $__RICHEDITCONSTANT_WM_SETREDRAW, True)
  1825. Return _WinAPI_InvalidateRect($hWnd)
  1826. EndFunc ;==>_GUICtrlRichEdit_ResumeRedraw
  1827. ; #FUNCTION# ====================================================================================================================
  1828. ; Author ........: Chris Haslam (c.haslam)
  1829. ; Modified.......:
  1830. ; ===============================================================================================================================
  1831. Func _GUICtrlRichEdit_ScrollLineOrPage($hWnd, $sAction)
  1832. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, 0)
  1833. If StringLen($sAction) <> 2 Then Return SetError(1021, 0, 0)
  1834. Local $sCh = StringLeft($sAction, 1)
  1835. If Not ($sCh = "l" Or $sCh = "p") Then Return SetError(1022, 0, 0)
  1836. $sCh = StringRight($sAction, 1)
  1837. If Not ($sCh = "d" Or $sCh = "u") Then Return SetError(1023, 0, 0)
  1838. Local $wParam = 0
  1839. Switch $sAction
  1840. Case "ld"
  1841. $wParam = $__RICHEDITCONSTANT_SB_LINEDOWN
  1842. Case "lu"
  1843. $wParam = $__RICHEDITCONSTANT_SB_LINEUP
  1844. Case "pd"
  1845. $wParam = $__RICHEDITCONSTANT_SB_PAGEDOWN
  1846. Case "pu"
  1847. $wParam = $__RICHEDITCONSTANT_SB_PAGEUP
  1848. EndSwitch
  1849. Local $iRet = _SendMessage($hWnd, $EM_SCROLL, $wParam, 0)
  1850. $iRet = BitAND($iRet, 0xFFFF) ; low word
  1851. If BitAND($iRet, 0x8000) <> 0 Then $iRet = BitOR($iRet, 0xFFFF0000) ; extend sign bit
  1852. Return $iRet
  1853. EndFunc ;==>_GUICtrlRichEdit_ScrollLineOrPage
  1854. ; #FUNCTION# ====================================================================================================================
  1855. ; Author ........: Gary Frost (gafrost)
  1856. ; Modified.......: Chris Haslam (c.haslam)
  1857. ; ===============================================================================================================================
  1858. Func _GUICtrlRichEdit_ScrollLines($hWnd, $iQlines)
  1859. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1860. If Not __GCR_IsNumeric($iQlines) Then SetError(102, 0, False)
  1861. Local $iRet = _SendMessage($hWnd, $EM_LINESCROLL, 0, $iQlines)
  1862. If $iRet = 0 Then Return SetError(700, 0, False)
  1863. Return True
  1864. EndFunc ;==>_GUICtrlRichEdit_ScrollLines
  1865. ; #FUNCTION# ====================================================================================================================
  1866. ; Author ........: Chris Haslam (c.haslam)
  1867. ; Modified.......:
  1868. ; ===============================================================================================================================
  1869. Func _GUICtrlRichEdit_ScrollToCaret($hWnd)
  1870. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1871. _SendMessage($hWnd, $EM_SCROLLCARET, 0, 0)
  1872. Return True
  1873. EndFunc ;==>_GUICtrlRichEdit_ScrollToCaret
  1874. ; #FUNCTION# ====================================================================================================================
  1875. ; Authors........: Chris Haslam (c.haslam)
  1876. ; Modified ......: jpm
  1877. ; ===============================================================================================================================
  1878. Func _GUICtrlRichEdit_SetCharAttributes($hWnd, $sStatesAndEffects, $bWord = False)
  1879. Local Const $aV[17][3] = [ _
  1880. ["bo", $CFM_BOLD, $CFE_BOLD], ["di", $CFM_DISABLED, $CFE_DISABLED], _
  1881. ["em", $CFM_EMBOSS, $CFE_EMBOSS], ["hi", $CFM_HIDDEN, $CFE_HIDDEN], _
  1882. ["im", $CFM_IMPRINT, $CFE_IMPRINT], ["it", $CFM_ITALIC, $CFE_ITALIC], _
  1883. ["li", $CFM_LINK, $CFE_LINK], ["ou", $CFM_OUTLINE, $CFE_OUTLINE], _
  1884. ["pr", $CFM_PROTECTED, $CFE_PROTECTED], ["re", $CFM_REVISED, $CFE_REVISED], _
  1885. ["sh", $CFM_SHADOW, $CFE_SHADOW], ["sm", $CFM_SMALLCAPS, $CFE_SMALLCAPS], _
  1886. ["st", $CFM_STRIKEOUT, $CFE_STRIKEOUT], ["sb", $CFM_SUBSCRIPT, $CFE_SUBSCRIPT], _
  1887. ["sp", $CFM_SUPERSCRIPT, $CFE_SUPERSCRIPT], ["un", $CFM_UNDERLINE, $CFE_UNDERLINE], _
  1888. ["al", $CFM_ALLCAPS, $CFE_ALLCAPS]]
  1889. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1890. If Not IsBool($bWord) Then Return SetError(103, 0, False)
  1891. Local $iMask = 0, $iEffects = 0, $n, $s
  1892. For $i = 1 To StringLen($sStatesAndEffects) Step 3
  1893. $s = StringMid($sStatesAndEffects, $i + 1, 2)
  1894. $n = -1
  1895. For $j = 0 To UBound($aV) - 1
  1896. If $aV[$j][0] = $s Then
  1897. $n = $j
  1898. ExitLoop
  1899. EndIf
  1900. Next
  1901. If $n = -1 Then Return SetError(1023, $s, False) ; not found
  1902. $iMask = BitOR($iMask, $aV[$n][1])
  1903. $s = StringMid($sStatesAndEffects, $i, 1)
  1904. Switch $s
  1905. Case "+"
  1906. $iEffects = BitOR($iEffects, $aV[$n][2])
  1907. Case "-"
  1908. ; do nothing
  1909. Case Else
  1910. Return SetError(1022, $s, False)
  1911. EndSwitch
  1912. Next
  1913. Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
  1914. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  1915. DllStructSetData($tCharFormat, 2, $iMask)
  1916. DllStructSetData($tCharFormat, 3, $iEffects)
  1917. Local $wParam = ($bWord ? BitOR($SCF_WORD, $SCF_SELECTION) : $SCF_SELECTION)
  1918. Local $iRet = _SendMessage($hWnd, $EM_SETCHARFORMAT, $wParam, $tCharFormat, 0, "wparam", "struct*")
  1919. If Not $iRet Then Return SetError(700, 0, False)
  1920. Return True
  1921. EndFunc ;==>_GUICtrlRichEdit_SetCharAttributes
  1922. ; #FUNCTION# ====================================================================================================================
  1923. ; Authors........: Chris Haslam (c.haslam)
  1924. ; Modified ......: jpm, guinness, mLipok
  1925. ; ===============================================================================================================================
  1926. Func _GUICtrlRichEdit_SetCharBkColor($hWnd, $iBkColor = Default)
  1927. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1928. Local $tCharFormat = DllStructCreate($tagCHARFORMAT2)
  1929. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  1930. If $iBkColor = Default Then
  1931. DllStructSetData($tCharFormat, 3, $CFE_AUTOBACKCOLOR)
  1932. $iBkColor = 0
  1933. Else
  1934. If BitAND($iBkColor, 0xff000000) Then Return SetError(1022, 0, False)
  1935. EndIf
  1936. DllStructSetData($tCharFormat, 2, $CFM_BACKCOLOR)
  1937. DllStructSetData($tCharFormat, 12, $iBkColor)
  1938. Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") <> 0
  1939. EndFunc ;==>_GUICtrlRichEdit_SetCharBkColor
  1940. ; #FUNCTION# ====================================================================================================================
  1941. ; Authors........: Chris Haslam (c.haslam)
  1942. ; Modified ......: Jpm, guinness
  1943. ; ===============================================================================================================================
  1944. Func _GUICtrlRichEdit_SetCharColor($hWnd, $iColor = Default)
  1945. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1946. Local $tCharFormat = DllStructCreate($tagCHARFORMAT)
  1947. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  1948. If $iColor = Default Then
  1949. DllStructSetData($tCharFormat, 3, $CFE_AUTOCOLOR)
  1950. $iColor = 0
  1951. Else
  1952. If BitAND($iColor, 0xff000000) Then Return SetError(1022, 0, False)
  1953. EndIf
  1954. DllStructSetData($tCharFormat, 2, $CFM_COLOR)
  1955. DllStructSetData($tCharFormat, 6, $iColor)
  1956. Return _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*") <> 0
  1957. EndFunc ;==>_GUICtrlRichEdit_SetCharColor
  1958. ; #FUNCTION# ====================================================================================================================
  1959. ; Authors........: Chris Haslam (c.haslam)
  1960. ; Modified ......: Jpm, guinness
  1961. ; ===============================================================================================================================
  1962. Func _GUICtrlRichEdit_SetBkColor($hWnd, $iBngColor = Default)
  1963. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1964. Local $bSysColor = False
  1965. If $iBngColor = Default Then
  1966. $bSysColor = True
  1967. $iBngColor = 0
  1968. Else
  1969. If BitAND($iBngColor, 0xff000000) Then Return SetError(1022, 0, False)
  1970. EndIf
  1971. _SendMessage($hWnd, $EM_SETBKGNDCOLOR, $bSysColor, $iBngColor)
  1972. Return True
  1973. EndFunc ;==>_GUICtrlRichEdit_SetBkColor
  1974. ; #FUNCTION# ====================================================================================================================
  1975. ; Authors........: Chris Haslam (c.haslam)
  1976. ; Modified ......:
  1977. ; ===============================================================================================================================
  1978. Func _GUICtrlRichEdit_SetLimitOnText($hWnd, $iNewLimit)
  1979. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1980. If Not __GCR_IsNumeric($iNewLimit, ">=0") Then Return SetError(102, 0, False)
  1981. If $iNewLimit < 65535 Then $iNewLimit = 0 ; default max is 64K
  1982. _SendMessage($hWnd, $EM_EXLIMITTEXT, 0, $iNewLimit)
  1983. Return True
  1984. EndFunc ;==>_GUICtrlRichEdit_SetLimitOnText
  1985. ; #FUNCTION# ====================================================================================================================
  1986. ; Author ........: KIP
  1987. ; Modified.......: Chris Haslam (c.haslam), guinness
  1988. ; ===============================================================================================================================
  1989. Func _GUICtrlRichEdit_SetTabStops($hWnd, $vTabStops, $bRedraw = True)
  1990. ; Should take tabstops in space units (like EM_SETPARAFORMAT PFM_TABSTOPS, but how to convert inches, etc.
  1991. ; to dialog units? For now, a kludge based on experimentation
  1992. Local Const $iTwipsPerDU = 18.75
  1993. Local $tTabStops, $tagTabStops = "", $wParam
  1994. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  1995. If Not IsBool($bRedraw) Then Return SetError(103, 0, False)
  1996. If IsString($vTabStops) Then ; Set every tabstop manually
  1997. If $vTabStops = "" Then Return SetError(1023, 0, False)
  1998. Local $aS = StringSplit($vTabStops, ";")
  1999. Local $iNumTabStops = $aS[0]
  2000. For $i = 1 To $iNumTabStops
  2001. If Not __GCR_IsNumeric($aS[$i], ">0") Then Return SetError(1022, 0, False)
  2002. $tagTabStops &= "int;"
  2003. Next
  2004. $tagTabStops = StringTrimRight($tagTabStops, 1)
  2005. $tTabStops = DllStructCreate($tagTabStops)
  2006. For $i = 1 To $iNumTabStops
  2007. DllStructSetData($tTabStops, $i, $aS[$i] * $__g_iRTFTwipsPeSpaceUnit / $iTwipsPerDU)
  2008. Next
  2009. $wParam = $iNumTabStops
  2010. ElseIf IsNumber($vTabStops) Then
  2011. If __GCR_IsNumeric($vTabStops, ">0") Then
  2012. $tTabStops = DllStructCreate("int")
  2013. DllStructSetData($tTabStops, 1, $vTabStops * $__g_iRTFTwipsPeSpaceUnit / $iTwipsPerDU)
  2014. $wParam = 1
  2015. Else
  2016. Return SetError(1024, 9, False)
  2017. EndIf
  2018. Else
  2019. Return SetError(1021, 0, False)
  2020. EndIf
  2021. Local $bResult = _SendMessage($hWnd, $EM_SETTABSTOPS, $wParam, $tTabStops, 0, "wparam", "struct*") <> 0
  2022. If $bRedraw Then _WinAPI_InvalidateRect($hWnd) ; redraw the control
  2023. Return $bResult
  2024. EndFunc ;==>_GUICtrlRichEdit_SetTabStops
  2025. ; #FUNCTION# ====================================================================================================================
  2026. ; Authors........: Chris Haslam (c.haslam)
  2027. ; Modified ......:
  2028. ; ===============================================================================================================================
  2029. Func _GUICtrlRichEdit_SetZoom($hWnd, $iPercent)
  2030. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2031. If Not __GCR_IsNumeric($iPercent, ">0") Then Return SetError(1021, 0, False)
  2032. Local $iNumerator, $iDenominator
  2033. Select
  2034. Case Not ($iPercent = 100 Or ($iPercent >= 200 And $iPercent < 6400))
  2035. Return SetError(1022, 0, False)
  2036. Case $iPercent >= 100
  2037. $iNumerator = 10000
  2038. $iDenominator = 10000 / ($iPercent / 100)
  2039. Case Else
  2040. $iNumerator = 10000 * ($iPercent / 100)
  2041. $iDenominator = 10000
  2042. EndSelect
  2043. Return _SendMessage($hWnd, $EM_SETZOOM, $iNumerator, $iDenominator) <> 0
  2044. EndFunc ;==>_GUICtrlRichEdit_SetZoom
  2045. ; #FUNCTION# ====================================================================================================================
  2046. ; Authors........: Yoan Roblet (Arcker)
  2047. ; Modified ......: Chris Haslam (c.haslam)
  2048. ; ===============================================================================================================================
  2049. Func _GUICtrlRichEdit_SetEventMask($hWnd, $iEventMask)
  2050. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2051. If Not __GCR_IsNumeric($iEventMask) Then Return SetError(102, 0, False)
  2052. _SendMessage($hWnd, $EM_SETEVENTMASK, 0, $iEventMask)
  2053. Return True
  2054. EndFunc ;==>_GUICtrlRichEdit_SetEventMask
  2055. ; #FUNCTION# ====================================================================================================================
  2056. ; Author ........: Chris Haslam (c.haslam)
  2057. ; Modified.......:
  2058. ; ===============================================================================================================================
  2059. Func _GUICtrlRichEdit_SetFont($hWnd, $iPoints = Default, $sName = Default, $iCharset = Default, $iLcid = Default)
  2060. ; MSDN does not give a mask (CFM) for bPitchAndFamily so it appears that it cannot be set => omitted here
  2061. Local $iDwMask = 0
  2062. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2063. If Not ($iPoints = Default Or __GCR_IsNumeric($iPoints, ">0")) Then Return SetError(102, 0, False)
  2064. If $sName <> Default Then
  2065. Local $aS = StringSplit($sName, " ")
  2066. For $i = 1 To UBound($aS) - 1
  2067. If Not StringIsAlpha($aS[$i]) Then Return SetError(103, 0, False)
  2068. Next
  2069. EndIf
  2070. If Not ($iCharset = Default Or __GCR_IsNumeric($iCharset)) Then Return SetError(104, 0, False)
  2071. If Not ($iLcid = Default Or __GCR_IsNumeric($iLcid)) Then Return SetError(105, 0, False)
  2072. Local $tCharFormat = DllStructCreate($tagCHARFORMAT2)
  2073. DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat))
  2074. If $iPoints <> Default Then
  2075. $iDwMask = $CFM_SIZE
  2076. DllStructSetData($tCharFormat, 4, Int($iPoints * 20))
  2077. EndIf
  2078. If $sName <> Default Then
  2079. If StringLen($sName) > $LF_FACESIZE - 1 Then SetError(-1, 0, False)
  2080. $iDwMask = BitOR($iDwMask, $CFM_FACE)
  2081. DllStructSetData($tCharFormat, 9, $sName)
  2082. EndIf
  2083. If $iCharset <> Default Then
  2084. $iDwMask = BitOR($iDwMask, $CFM_CHARSET)
  2085. DllStructSetData($tCharFormat, 7, $iCharset)
  2086. EndIf
  2087. If $iLcid <> Default Then
  2088. $iDwMask = BitOR($iDwMask, $CFM_LCID)
  2089. DllStructSetData($tCharFormat, 13, $iLcid)
  2090. EndIf
  2091. DllStructSetData($tCharFormat, 2, $iDwMask)
  2092. Local $iRet = _SendMessage($hWnd, $EM_SETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*")
  2093. If Not $iRet Then Return SetError(@error + 200, 0, False)
  2094. Return True
  2095. EndFunc ;==>_GUICtrlRichEdit_SetFont
  2096. ; #FUNCTION# ====================================================================================================================
  2097. ; Author ........: Chris Haslam (c.haslam)
  2098. ; Modified.......: jpm, guinness
  2099. ; ===============================================================================================================================
  2100. Func _GUICtrlRichEdit_SetRECT($hWnd, $iLeft = Default, $iTop = Default, $iRight = Default, $iBottom = Default, $bRedraw = True)
  2101. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2102. If Not ($iLeft = Default Or __GCR_IsNumeric($iLeft, ">0")) Then Return SetError(1021, 0, False)
  2103. If Not ($iTop = Default Or __GCR_IsNumeric($iTop, ">0")) Then Return SetError(1022, 0, False)
  2104. If Not ($iRight = Default Or __GCR_IsNumeric($iRight, ">0")) Then Return SetError(1023, 0, False)
  2105. If Not ($iBottom = Default Or __GCR_IsNumeric($iBottom, ">0")) Then Return SetError(1024, 0, False)
  2106. If @NumParams = 1 Then
  2107. Local $aPos = ControlGetPos($hWnd, "", "")
  2108. $iLeft = 2
  2109. $iTop = 2
  2110. $iRight = $aPos[2]
  2111. $iBottom = $aPos[3]
  2112. _GUICtrlRichEdit_SetRECT($hWnd, $iLeft, $iTop, $iRight, $iBottom)
  2113. Return True
  2114. Else
  2115. Local $aS = _GUICtrlRichEdit_GetRECT($hWnd)
  2116. If $iLeft = Default Then
  2117. $iLeft = $aS[0]
  2118. EndIf
  2119. If $iTop = Default Then
  2120. $iTop = $aS[1]
  2121. EndIf
  2122. If $iRight = Default Then
  2123. $iRight = $aS[2]
  2124. EndIf
  2125. If $iBottom = Default Then
  2126. $iBottom = $aS[3]
  2127. EndIf
  2128. If $iLeft >= $iRight Then Return SetError(1025, 0, False)
  2129. If $iTop >= $iBottom Then Return SetError(1026, 0, False)
  2130. Local $tRECT = DllStructCreate($tagRECT)
  2131. DllStructSetData($tRECT, "Left", Number($iLeft))
  2132. DllStructSetData($tRECT, "Top", Number($iTop))
  2133. DllStructSetData($tRECT, "Right", Number($iRight))
  2134. DllStructSetData($tRECT, "Bottom", Number($iBottom))
  2135. Local $iMsg = ($bRedraw ? $EM_SETRECT : $EM_SETRECTNP)
  2136. _SendMessage($hWnd, $iMsg, 0, $tRECT, 0, "wparam", "struct*")
  2137. EndIf
  2138. Return True
  2139. EndFunc ;==>_GUICtrlRichEdit_SetRECT
  2140. ; #FUNCTION# ====================================================================================================================
  2141. ; Author ........: Gary Frost (gafrost)
  2142. ; Modified.......: Chris Haslam (c.haslam)
  2143. ; ===============================================================================================================================
  2144. Func _GUICtrlRichEdit_SetModified($hWnd, $bState = True)
  2145. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2146. If Not IsBool($bState) Then Return SetError(102, 0, False)
  2147. _SendMessage($hWnd, $EM_SETMODIFY, $bState)
  2148. Return True
  2149. EndFunc ;==>_GUICtrlRichEdit_SetModified
  2150. ; #FUNCTION# ====================================================================================================================
  2151. ; Authors........: Chris Haslam (c.haslam)
  2152. ; Modified ......: guinness
  2153. ; ===============================================================================================================================
  2154. Func _GUICtrlRichEdit_SetParaAlignment($hWnd, $sAlignment)
  2155. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2156. Local $iAlignment
  2157. Switch $sAlignment
  2158. Case "l"
  2159. $iAlignment = $PFA_LEFT
  2160. Case "c"
  2161. $iAlignment = $PFA_CENTER
  2162. Case "r"
  2163. $iAlignment = $PFA_RIGHT
  2164. Case "j"
  2165. $iAlignment = $PFA_JUSTIFY
  2166. Case "w"
  2167. $iAlignment = $PFA_FULL_INTERWORD
  2168. Case Else
  2169. Return SetError(102, 0, False)
  2170. EndSwitch
  2171. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2172. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  2173. DllStructSetData($tParaFormat, 2, $PFM_ALIGNMENT)
  2174. DllStructSetData($tParaFormat, 8, $iAlignment)
  2175. Return _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*") <> 0
  2176. EndFunc ;==>_GUICtrlRichEdit_SetParaAlignment
  2177. ; #FUNCTION# ====================================================================================================================
  2178. ; Authors........: Chris Haslam (c.haslam)
  2179. ; Modified ......:
  2180. ; ===============================================================================================================================
  2181. Func _GUICtrlRichEdit_SetParaAttributes($hWnd, $sStatesAndAtts)
  2182. Local Enum $eAbbrev = 0, $eMask, $eEffect, $eInverted
  2183. ; MS seems to mean LINENUMBER and WIDOWCONTROL, not NOLINENUMBER and NOWIDOWCONTROL
  2184. Local Const $aV[9][4] = [ _ ; abbrev, mask, effect, inverted
  2185. ["fpg", $PFM_PAGEBREAKBEFORE, $PFE_PAGEBREAKBEFORE, False], _
  2186. ["hyp", $PFM_DONOTHYPHEN, $PFE_DONOTHYPHEN, True], _
  2187. ["kpt", $PFM_KEEP, $PFE_KEEP, False], _
  2188. ["kpn", $PFM_KEEPNEXT, $PFE_KEEPNEXT, False], _
  2189. ["pwo", $PFM_NOWIDOWCONTROL, $PFE_NOWIDOWCONTROL, False], _
  2190. ["r2l", $PFM_RTLPARA, $PFE_RTLPARA, False], _
  2191. ["row", $PFM_TABLE, $PFE_TABLE, False], _
  2192. ["sbs", $PFM_SIDEBYSIDE, $PFE_SIDEBYSIDE, False], _
  2193. ["sln", $PFM_NOLINENUMBER, $PFE_NOLINENUMBER, False]]
  2194. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2195. If Mod(StringLen($sStatesAndAtts) + 1, 5) <> 0 Then Return SetError(1023, 0, False)
  2196. Local $aS = StringSplit($sStatesAndAtts, ";")
  2197. Local $iMask = 0, $iEffects = 0, $s, $n
  2198. For $i = 1 To UBound($aS, $UBOUND_ROWS) - 1
  2199. $s = StringMid($aS[$i], 2)
  2200. $n = -1
  2201. For $j = 0 To UBound($aV, $UBOUND_ROWS) - 1
  2202. If $aV[$j][$eAbbrev] = $s Then
  2203. $n = $j
  2204. ExitLoop
  2205. EndIf
  2206. Next
  2207. If $n = -1 Then Return SetError(1022, $s, False)
  2208. $iMask = BitOR($iMask, $aV[$n][$eMask])
  2209. $s = StringLeft($aS[$i], 1)
  2210. Switch $s
  2211. Case "+"
  2212. If Not $aV[$n][$eInverted] Then ; if normal sense
  2213. $iEffects = BitOR($iEffects, $aV[$n][$eEffect])
  2214. EndIf
  2215. Case "-"
  2216. If $aV[$n][$eInverted] Then ; if inverted sense
  2217. $iEffects = BitOR($iEffects, $aV[$n][$eEffect])
  2218. EndIf
  2219. Case Else
  2220. Return SetError(1021, $s, False)
  2221. EndSwitch
  2222. Next
  2223. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2224. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  2225. DllStructSetData($tParaFormat, 2, $iMask)
  2226. DllStructSetData($tParaFormat, 4, $iEffects)
  2227. Return _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*") <> 0
  2228. EndFunc ;==>_GUICtrlRichEdit_SetParaAttributes
  2229. ; #FUNCTION# ====================================================================================================================
  2230. ; Authors........: Chris Haslam (c.haslam)
  2231. ; Modified ......:
  2232. ; ===============================================================================================================================
  2233. Func _GUICtrlRichEdit_SetParaBorder($hWnd, $sLocation = Default, $vLineStyle = Default, $sColor = Default, $iSpace = Default)
  2234. ; wBorderWidth doesn't appear to work
  2235. Local $iBorders
  2236. ; Local $tOldParaFormat,$iOldLoc, $iOldSpace, $iOldLineStyle, $iOldColor, $iN
  2237. Local Const $avLocs[6][2] = [["l", 1], ["r", 2], ["t", 4], ["b", 8], ["i", 16], ["o", 32]]
  2238. Local Const $avLS[12] = ["none", .75, 1.5, 2.25, 3, 4.5, 6, ".75d", "1.5d", "2.25d", ".75g", ".75gd"]
  2239. Local Const $sClrs = ";blk;blu;cyn;grn;mag;red;yel;whi;dbl;dgn;dmg;drd;dyl;dgy;lgy;aut;"
  2240. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2241. If Not ($iSpace = Default Or __GCR_IsNumeric($iSpace, ">=0")) Then Return SetError(105, 0, False)
  2242. ; If Not ($iWidth = Default Or __GCR_IsNumeric($iWidth, ">=0")) Then Return SetError(106, 0, False) ; wBorderWidth does not round-trip
  2243. If $sLocation = "" Then
  2244. $iBorders = 0
  2245. $iSpace = 0
  2246. ; $iWidth = 0
  2247. Else
  2248. If $sLocation = Default Or $vLineStyle = Default Or $sColor = Default Or $iSpace = Default Then
  2249. Local $aS = StringSplit(_GUICtrlRichEdit_GetParaBorder($hWnd), ";")
  2250. If $sLocation = Default Then $sLocation = $aS[1]
  2251. If $vLineStyle = Default Then $vLineStyle = $aS[2]
  2252. If $sColor = Default Then $sColor = $aS[3]
  2253. If $iSpace = Default Then $iSpace = $aS[4]
  2254. EndIf
  2255. Local $iLoc = 0, $n, $s
  2256. For $i = 1 To StringLen($sLocation)
  2257. $s = StringMid($sLocation, $i, 1)
  2258. $n = -1
  2259. For $j = 0 To UBound($avLocs, $UBOUND_ROWS) - 1
  2260. If $avLocs[$j][0] = $s Then
  2261. $n = $j
  2262. ExitLoop
  2263. EndIf
  2264. Next
  2265. If $n = -1 Then Return SetError(102, $s, False)
  2266. $iLoc = BitOR($iLoc, $avLocs[$n][1])
  2267. Next
  2268. $n = -1
  2269. For $i = 0 To UBound($avLS, $UBOUND_ROWS) - 1
  2270. If $vLineStyle = $avLS[$i] Then
  2271. $n = $i
  2272. ExitLoop
  2273. EndIf
  2274. Next
  2275. If $n = -1 Then Return SetError(103, 0, False)
  2276. Local $iLineStyle = $n
  2277. $n = StringInStr($sClrs, ";" & $sColor & ";")
  2278. If $n = 0 Then Return SetError(104, 0, False)
  2279. Local $iColor = Int($n / 4)
  2280. If $iColor = 16 Then ; if autocolor
  2281. $iLoc = BitOR($iLoc, 64)
  2282. $iColor = 0
  2283. EndIf
  2284. $iBorders = $iLoc + BitShift($iLineStyle, -8) + BitShift($iColor, -12)
  2285. ; If $iWidth = Default Then $iWidth = $iOldWidth
  2286. EndIf
  2287. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2288. DllStructSetData($tParaFormat, "cbSize", DllStructGetSize($tParaFormat))
  2289. DllStructSetData($tParaFormat, "wBorderSpace", $iSpace * $__g_iRTFTwipsPeSpaceUnit)
  2290. ; DllStructGetData($tParaFormat, 23, $iWidth * $__g_iRTFTwipsPeSpaceUnit)
  2291. DllStructSetData($tParaFormat, "wBorders", $iBorders)
  2292. DllStructSetData($tParaFormat, "dwMask", $PFM_BORDER)
  2293. Return _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*") <> 0
  2294. EndFunc ;==>_GUICtrlRichEdit_SetParaBorder
  2295. ; #FUNCTION# ====================================================================================================================
  2296. ; Authors........: Chris Haslam (c.haslam)
  2297. ; Modified ......:
  2298. ; ===============================================================================================================================
  2299. Func _GUICtrlRichEdit_SetParaIndents($hWnd, $vLeft = Default, $iRight = Default, $iFirstLine = Default)
  2300. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2301. If Not ($vLeft = Default Or __GCR_IsNumeric($vLeft)) Then Return SetError(1021, 0, False)
  2302. If Not ($iRight = Default Or __GCR_IsNumeric($iRight, ">=0")) Then Return SetError(103, 0, False)
  2303. If Not ($iFirstLine = Default Or __GCR_IsNumeric($iFirstLine)) Then Return SetError(104, 0, False)
  2304. Local $s = _GUICtrlRichEdit_GetParaIndents($hWnd)
  2305. Local $aS = StringSplit($s, ";")
  2306. If $vLeft = Default Then $vLeft = $aS[1]
  2307. If $iRight = Default Then $iRight = $aS[2]
  2308. If $iFirstLine = Default Then $iFirstLine = $aS[3]
  2309. If $vLeft < 0 Then Return SetError(1022, 0, False)
  2310. If $vLeft + $iFirstLine < 0 Then Return SetError(200, 0, False)
  2311. If StringInStr("+-", StringLeft($vLeft, 1)) <> 0 Then $vLeft = $aS[1] + $vLeft
  2312. Local $iIdxSI = $vLeft + $iFirstLine
  2313. Local $iIdxOfs = -$iFirstLine
  2314. Local $tParaFormat = DllStructCreate($tagPARAFORMAT)
  2315. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  2316. DllStructSetData($tParaFormat, "dxStartIndent", $iIdxSI * $__g_iRTFTwipsPeSpaceUnit)
  2317. DllStructSetData($tParaFormat, "dxOffset", $iIdxOfs * $__g_iRTFTwipsPeSpaceUnit)
  2318. DllStructSetData($tParaFormat, "dxRightIndent", $iRight * $__g_iRTFTwipsPeSpaceUnit)
  2319. DllStructSetData($tParaFormat, 2, BitOR($PFM_STARTINDENT, $PFM_OFFSET, $PFM_RIGHTINDENT)) ; absolute
  2320. Local $iRet = _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*")
  2321. If Not $iRet Then Return SetError(700, 0, False)
  2322. Return True
  2323. EndFunc ;==>_GUICtrlRichEdit_SetParaIndents
  2324. ; #FUNCTION# ====================================================================================================================
  2325. ; Authors........: Chris Haslam (c.haslam)
  2326. ; Modified ......:
  2327. ; ===============================================================================================================================
  2328. Func _GUICtrlRichEdit_SetParaNumbering($hWnd, $sStyle, $iTextToNbrSpace = Default, $bForceRoman = False)
  2329. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2330. If Not ($iTextToNbrSpace = Default Or __GCR_IsNumeric($iTextToNbrSpace, ">0")) Then Return SetError(103, 0, False)
  2331. If Not IsBool($bForceRoman) Then Return SetError(104, 0, False)
  2332. Local $iPFM, $iWNumbering, $iWnumStart, $iWnumStyle, $iQspaces
  2333. __GCR_ParseParaNumberingStyle($sStyle, $bForceRoman, $iPFM, $iWNumbering, $iWnumStart, $iWnumStyle, $iQspaces)
  2334. If @error Then Return SetError(@error, 0, False)
  2335. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2336. DllStructSetData($tParaFormat, 1, DllStructGetSize($tParaFormat))
  2337. If BitAND($iPFM, $PFM_NUMBERING) Then DllStructSetData($tParaFormat, 3, $iWNumbering)
  2338. If BitAND($iPFM, $PFM_NUMBERINGSTART) Then DllStructSetData($tParaFormat, 19, $iWnumStart)
  2339. If BitAND($iPFM, $PFM_NUMBERINGSTYLE) Then DllStructSetData($tParaFormat, 20, $iWnumStyle)
  2340. If BitAND($iPFM, $PFM_NUMBERINGTAB) Then
  2341. Local $iTwips
  2342. If $iTextToNbrSpace = Default Then
  2343. ; set number-to-text spacing based on font at anchor or onsertion point
  2344. Local $aV = _GUICtrlRichEdit_GetFont($hWnd)
  2345. Local $iPoints = $aV[0]
  2346. $iTwips = $iQspaces * $iPoints * 20
  2347. Else
  2348. $iTwips = $iTextToNbrSpace * $__g_iRTFTwipsPeSpaceUnit
  2349. EndIf
  2350. DllStructSetData($tParaFormat, 21, $iTwips)
  2351. EndIf
  2352. DllStructSetData($tParaFormat, 2, $iPFM)
  2353. Return _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*") <> 0
  2354. EndFunc ;==>_GUICtrlRichEdit_SetParaNumbering
  2355. ; #FUNCTION# ====================================================================================================================
  2356. ; Authors........: Chris Haslam (c.haslam)
  2357. ; Modified ......:
  2358. ; ===============================================================================================================================
  2359. Func _GUICtrlRichEdit_SetParaShading($hWnd, $iWeight = Default, $sStyle = Default, $sForeColor = Default, $sBackColor = Default)
  2360. Local $iS = 0 ; perhaps a BUG (jpm) only referenced
  2361. Local Const $sStyles = ";non;dhz;dvt;ddd;dud;dgr;dtr;lhz;lrt;ldd;lud;lgr;ltr;"
  2362. Local Const $sClrs = ";blk;blu;cyn;grn;mag;red;yel;whi;dbl;dgn;dmg;drd;dyl;dgy;lgy;"
  2363. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2364. If Not ($iWeight = Default Or __GCR_IsNumeric($iWeight, ">=0")) Then Return SetError(1021, 0, False)
  2365. If $iWeight <> Default Or $sStyle <> Default Or $sForeColor <> Default Or $sBackColor <> Default Then
  2366. Local $aS = StringSplit(_GUICtrlRichEdit_GetParaShading($hWnd), ";")
  2367. If $iWeight = Default Then $iWeight = $aS[1]
  2368. If $sStyle = Default Then $sStyle = $aS[2]
  2369. If $sForeColor = Default Then $sForeColor = $aS[3]
  2370. If $sBackColor = Default Then $sBackColor = $aS[4]
  2371. #cs
  2372. $tOldParaFormat = DllStructCreate($tagPARAFORMAT2)
  2373. DllStructSetData($tOldParaFormat, 1, DllStructGetSize($tOldParaFormat))
  2374. _SendMessage($hWnd, $EM_GETPARAFORMAT, 0, DllStructGetPtr($tOldParaFormat))
  2375. #ce
  2376. EndIf
  2377. ; If $iWeight = Default Then
  2378. ; $iWeight = DllStructGetData($tOldParaFormat, 17)
  2379. ; Else
  2380. If $iWeight < 0 Or $iWeight > 100 Then Return SetError(1022, 0, False)
  2381. ; EndIf
  2382. ; If $sStyle = Default Or $sForeColor = Default Or $sBackColor = Default Then
  2383. ; $iS = DllStructGetData($tOldParaFormat, 18)
  2384. ; EndIf
  2385. ; If $sStyle = Default Then
  2386. ; $iStyle = BitAND($iS, 0xF)
  2387. ; Else
  2388. Local $iN = StringInStr($sStyles, ";" & $sStyle & ";")
  2389. If $iN = 0 Then Return SetError(103, 0, False)
  2390. Local $iStyle = Int($iN / 4)
  2391. ; EndIf
  2392. ; If $sForeColor = Default Then
  2393. Local $iFore = BitShift(BitAND($iS, 0xF0), 4)
  2394. ; Else
  2395. $iN = StringInStr($sClrs, ";" & $sForeColor & ";")
  2396. If $iN = 0 Then Return SetError(104, 0, False)
  2397. $iFore = Int($iN / 4)
  2398. ; EndIf
  2399. ; If $sBackColor = Default Then
  2400. ; $iBack = BitShift(BitAND($iS, 0xF00), 8)
  2401. ; Else
  2402. $iN = StringInStr($sClrs, ";" & $sBackColor & ";")
  2403. If $iN = 0 Then Return SetError(105, 0, False)
  2404. Local $iBack = Int($iN / 4)
  2405. ; EndIf
  2406. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2407. DllStructSetData($tParaFormat, "cbSize", DllStructGetSize($tParaFormat))
  2408. DllStructSetData($tParaFormat, "wShadingWeight", $iWeight)
  2409. $iN = $iStyle + BitShift($iFore, -4) + BitShift($iBack, -8)
  2410. DllStructSetData($tParaFormat, "wShadingStyle", $iN)
  2411. DllStructSetData($tParaFormat, "dwMask", $PFM_SHADING)
  2412. Local $iRet = _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*")
  2413. If Not $iRet Then Return SetError(700, 0, False)
  2414. Return True
  2415. EndFunc ;==>_GUICtrlRichEdit_SetParaShading
  2416. ; #FUNCTION# ====================================================================================================================
  2417. ; Authors........: Chris Haslam (c.haslam)
  2418. ; Modified ......:
  2419. ; ===============================================================================================================================
  2420. Func _GUICtrlRichEdit_SetParaSpacing($hWnd, $vInter = Default, $iBefore = Default, $iAfter = Default)
  2421. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2422. If Not ($iBefore = Default Or __GCR_IsNumeric($iBefore, ">=0")) Then Return SetError(103, 0, False)
  2423. If Not ($iAfter = Default Or __GCR_IsNumeric($iAfter, ">=0")) Then Return SetError(104, 0, False)
  2424. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2425. DllStructSetData($tParaFormat, "cbSize", DllStructGetSize($tParaFormat))
  2426. Local $iMask = 0
  2427. If $vInter <> Default Then
  2428. $vInter = StringStripWS($vInter, $STR_STRIPALL) ; strip all spaces
  2429. Local $iP = StringInStr($vInter, "line", $STR_NOCASESENSEBASIC) ; case-insensitive, faster
  2430. If $iP <> 0 Then
  2431. $vInter = StringLeft($vInter, $iP - 1)
  2432. EndIf
  2433. If Not __GCR_IsNumeric($vInter, ">=0") Then Return SetError(1021, 0, False)
  2434. Local $iRule, $iLnSp = 0
  2435. If $iP <> 0 Then ; if in lines
  2436. Switch $vInter
  2437. Case 1
  2438. $iRule = 0
  2439. Case 1.5
  2440. $iRule = 1
  2441. Case 2
  2442. $iRule = 2
  2443. Case Else
  2444. If $vInter < 1 Then Return SetError(1022, 0, False)
  2445. $iRule = 5 ; spacing in lines
  2446. $iLnSp = $vInter * 20
  2447. EndSwitch
  2448. Else
  2449. $iRule = 4 ; spacing in twips
  2450. $iLnSp = $vInter * $__g_iRTFTwipsPeSpaceUnit
  2451. EndIf
  2452. $iMask = $PFM_LINESPACING
  2453. DllStructSetData($tParaFormat, "bLineSpacingRule", $iRule)
  2454. If $iLnSp <> 0 Then DllStructSetData($tParaFormat, 13, $iLnSp)
  2455. EndIf
  2456. If $iBefore <> Default Then
  2457. $iMask = BitOR($iMask, $PFM_SPACEBEFORE)
  2458. DllStructSetData($tParaFormat, "dySpaceBefore", $iBefore * $__g_iRTFTwipsPeSpaceUnit)
  2459. EndIf
  2460. If $iAfter <> Default Then
  2461. $iMask = BitOR($iMask, $PFM_SPACEAFTER)
  2462. DllStructSetData($tParaFormat, "dySpaceAfter", $iAfter * $__g_iRTFTwipsPeSpaceUnit)
  2463. EndIf
  2464. If $iMask <> 0 Then
  2465. DllStructSetData($tParaFormat, "dwMask", $iMask)
  2466. Return _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*") <> 0
  2467. Else
  2468. Return True
  2469. EndIf
  2470. EndFunc ;==>_GUICtrlRichEdit_SetParaSpacing
  2471. ; #FUNCTION# ====================================================================================================================
  2472. ; Authors........: Chris Haslam (c.haslam)
  2473. ; Modified ......:
  2474. ; ===============================================================================================================================
  2475. Func _GUICtrlRichEdit_SetParaTabStops($hWnd, $sTabStops)
  2476. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2477. Local $tParaFormat = DllStructCreate($tagPARAFORMAT2)
  2478. DllStructSetData($tParaFormat, "cbSize", DllStructGetSize($tParaFormat))
  2479. If $sTabStops = "" Then
  2480. DllStructSetData($tParaFormat, "cTabCount", 0)
  2481. Else
  2482. Local $asTabs = StringSplit($sTabStops, ";")
  2483. If $asTabs[0] > $MAX_TAB_STOPS Then Return SetError(1021, 0, False)
  2484. Local $asAtab, $i, $s, $iN, $iP
  2485. For $iTab = 1 To $asTabs[0]
  2486. $asAtab = StringSplit($asTabs[$iTab], "") ; split into characters
  2487. $i = 1
  2488. While $i <= $asAtab[0] And StringInStr("01234567890.", $asAtab[$i]) <> 0
  2489. $i += 1
  2490. WEnd
  2491. If $i = 1 Then Return SetError(1021, $iTab, False)
  2492. $s = StringLeft($asTabs[$iTab], $i - 1)
  2493. If Not __GCR_IsNumeric($s, ">=0") Then Return SetError(1021, $iTab, False)
  2494. $iN = $s * $__g_iRTFTwipsPeSpaceUnit
  2495. If $i <= $asAtab[0] Then
  2496. $iP = StringInStr("lcrdb", $asAtab[$i])
  2497. If $iP = 0 Then Return SetError(1022, $iTab, False)
  2498. $iN = BitOR($iN, BitShift($iP - 1, -24))
  2499. EndIf
  2500. $i += 1
  2501. If $i <= $asAtab[0] Then
  2502. $iP = StringInStr(" .-_t=", $asAtab[$i])
  2503. If $iP = 0 Then Return SetError(1023, $iTab, False)
  2504. $iN = BitOR($iN, BitShift($iP - 1, -28))
  2505. EndIf
  2506. DllStructSetData($tParaFormat, "rgxTabs", $iN, $iTab)
  2507. Next
  2508. DllStructSetData($tParaFormat, "cTabCount", $asTabs[0])
  2509. EndIf
  2510. DllStructSetData($tParaFormat, "dwMask", $PFM_TABSTOPS)
  2511. Return _SendMessage($hWnd, $EM_SETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*") <> 0
  2512. EndFunc ;==>_GUICtrlRichEdit_SetParaTabStops
  2513. ; #FUNCTION# ====================================================================================================================
  2514. ; Author ........: Gary Frost
  2515. ; Modified.......: Chris Haslam (c.haslam)
  2516. ; ===============================================================================================================================
  2517. Func _GUICtrlRichEdit_SetPasswordChar($hWnd, $sDisplayChar = "*")
  2518. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2519. If Not IsString($sDisplayChar) Then SetError(102, 0, False)
  2520. If $sDisplayChar = "" Then
  2521. _SendMessage($hWnd, $EM_SETPASSWORDCHAR)
  2522. Else
  2523. _SendMessage($hWnd, $EM_SETPASSWORDCHAR, Asc($sDisplayChar))
  2524. EndIf
  2525. Return True
  2526. EndFunc ;==>_GUICtrlRichEdit_SetPasswordChar
  2527. ; #FUNCTION# ====================================================================================================================
  2528. ; Author ........: Gary Frost (gafrost)
  2529. ; Modified.......: Chris Haslam (c.haslam)
  2530. ; ===============================================================================================================================
  2531. Func _GUICtrlRichEdit_SetReadOnly($hWnd, $bState = True)
  2532. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2533. If Not IsBool($bState) Then Return SetError(102, 0, False)
  2534. Local $iRet = _SendMessage($hWnd, $EM_SETREADONLY, $bState)
  2535. If $iRet = 0 Then Return SetError(700, 0, False)
  2536. Return True
  2537. EndFunc ;==>_GUICtrlRichEdit_SetReadOnly
  2538. ; #FUNCTION# ====================================================================================================================
  2539. ; Authors........: Prog@ndy
  2540. ; Modified ......: Chris Haslam (c.haslam)
  2541. ; ===============================================================================================================================
  2542. Func _GUICtrlRichEdit_SetScrollPos($hWnd, $iX, $iY)
  2543. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2544. If Not __GCR_IsNumeric($iX, ">=0") Then Return SetError(102, 0, False)
  2545. If Not __GCR_IsNumeric($iY, ">=0") Then Return SetError(103, 0, False)
  2546. Local $tPoint = DllStructCreate($tagPOINT)
  2547. DllStructSetData($tPoint, 1, $iX)
  2548. DllStructSetData($tPoint, 2, $iY)
  2549. Return _SendMessage($hWnd, $EM_SETSCROLLPOS, 0, $tPoint, 0, "wparam", "struct*") <> 0
  2550. EndFunc ;==>_GUICtrlRichEdit_SetScrollPos
  2551. ; #FUNCTION# ====================================================================================================================
  2552. ; Author ........: Chris Haslam (c.haslam)
  2553. ; Modified.......: jpm
  2554. ; ===============================================================================================================================
  2555. Func _GUICtrlRichEdit_SetSel($hWnd, $iAnchor, $iActive, $bHideSel = False)
  2556. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2557. If Not __GCR_IsNumeric($iAnchor, ">=0,-1") Then Return SetError(102, 0, False)
  2558. If Not __GCR_IsNumeric($iActive, ">=0,-1") Then Return SetError(103, 0, False)
  2559. If Not IsBool($bHideSel) Then Return SetError(104, 0, False)
  2560. _SendMessage($hWnd, $EM_SETSEL, $iAnchor, $iActive)
  2561. If $bHideSel Then _SendMessage($hWnd, $EM_HIDESELECTION, $bHideSel)
  2562. _WinAPI_SetFocus($hWnd) ; need to have the selection updated
  2563. Return True
  2564. EndFunc ;==>_GUICtrlRichEdit_SetSel
  2565. ; #FUNCTION# ====================================================================================================================
  2566. ; Author ........: Chris Haslam (c.haslam)
  2567. ; Modified.......:
  2568. ; ===============================================================================================================================
  2569. Func _GUICtrlRichEdit_SetSpaceUnit($sUnit)
  2570. Switch StringLower($sUnit)
  2571. Case "in"
  2572. $__g_iRTFTwipsPeSpaceUnit = 1440
  2573. Case "cm"
  2574. $__g_iRTFTwipsPeSpaceUnit = 567
  2575. Case "mm"
  2576. $__g_iRTFTwipsPeSpaceUnit = 56.7
  2577. Case "pt"
  2578. $__g_iRTFTwipsPeSpaceUnit = 20
  2579. Case "tw"
  2580. $__g_iRTFTwipsPeSpaceUnit = 1
  2581. Case Else
  2582. Return SetError(1, 0, False)
  2583. EndSwitch
  2584. Return True
  2585. EndFunc ;==>_GUICtrlRichEdit_SetSpaceUnit
  2586. ; #FUNCTION# ====================================================================================================================
  2587. ; Authors........: Gary Frost (gafrost (custompcs@charter.net))
  2588. ; Modified ......: Prog@ndy, Chris Haslam (c.haslam)
  2589. ; ===============================================================================================================================
  2590. Func _GUICtrlRichEdit_SetText($hWnd, $sText)
  2591. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2592. Local $tSetText = DllStructCreate($tagSETTEXTEX)
  2593. ; DllStructSetData($tSetText, 1, $ST_KEEPUNDO)
  2594. DllStructSetData($tSetText, 1, $ST_DEFAULT)
  2595. DllStructSetData($tSetText, 2, $CP_ACP)
  2596. Local $iRet
  2597. If StringLeft($sText, 5) <> "{\rtf" And StringLeft($sText, 5) <> "{urtf" Then
  2598. DllStructSetData($tSetText, 2, $CP_UNICODE)
  2599. $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "wstr")
  2600. Else
  2601. $iRet = _SendMessage($hWnd, $EM_SETTEXTEX, $tSetText, $sText, 0, "struct*", "STR")
  2602. EndIf
  2603. If Not $iRet Then Return SetError(700, 0, False)
  2604. Return True
  2605. EndFunc ;==>_GUICtrlRichEdit_SetText
  2606. ; #FUNCTION# ====================================================================================================================
  2607. ; Authors........: Chris Haslam (c.haslam)
  2608. ; Modified ......:
  2609. ; ===============================================================================================================================
  2610. Func _GUICtrlRichEdit_SetUndoLimit($hWnd, $iLimit)
  2611. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2612. If Not __GCR_IsNumeric($iLimit, ">=0") Then Return SetError(102, 0, False)
  2613. Return _SendMessage($hWnd, $EM_SETUNDOLIMIT, $iLimit) <> 0 Or $iLimit = 0
  2614. EndFunc ;==>_GUICtrlRichEdit_SetUndoLimit
  2615. ; #FUNCTION# ====================================================================================================================
  2616. ; Authors........: Chris Haslam (c.haslam)
  2617. ; Modified ......: mLipok
  2618. ; ===============================================================================================================================
  2619. Func _GUICtrlRichEdit_StreamFromFile($hWnd, $sFileSpec, $iFileEncoding = Default)
  2620. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2621. Local $tEditStream = DllStructCreate($tagEDITSTREAM)
  2622. DllStructSetData($tEditStream, "pfnCallback", DllCallbackGetPtr($__g_pGRC_StreamFromFileCallback))
  2623. If $iFileEncoding = Default Then $iFileEncoding = 0
  2624. Local $hFile = FileOpen($sFileSpec, $FO_READ + $iFileEncoding)
  2625. If $hFile = -1 Then Return SetError(1021, 0, False)
  2626. Local $sBuf = FileRead($hFile, 5)
  2627. FileClose($hFile)
  2628. $hFile = FileOpen($sFileSpec, $FO_READ + $iFileEncoding) ; reopen it at the start
  2629. DllStructSetData($tEditStream, "dwCookie", $hFile) ; -> Send handle to CallbackFunc
  2630. Local $wParam = ($sBuf == "{\rtf" Or $sBuf == "{urtf") ? $SF_RTF : $SF_TEXT
  2631. $wParam = BitOR($wParam, $SFF_SELECTION)
  2632. If Not _GUICtrlRichEdit_IsTextSelected($hWnd) Then
  2633. _GUICtrlRichEdit_SetText($hWnd, "")
  2634. EndIf
  2635. Local $iQchs = _SendMessage($hWnd, $EM_STREAMIN, $wParam, $tEditStream, 0, "wparam", "struct*")
  2636. FileClose($hFile)
  2637. Local $iError = DllStructGetData($tEditStream, "dwError")
  2638. If $iError <> 0 Then Return SetError(700, $iError, False)
  2639. If $iQchs = 0 Then
  2640. If FileGetSize($sFileSpec) = 0 Then Return SetError(1022, 0, False)
  2641. Return SetError(700, $iError, False)
  2642. EndIf
  2643. Return True
  2644. EndFunc ;==>_GUICtrlRichEdit_StreamFromFile
  2645. ; #FUNCTION# ====================================================================================================================
  2646. ; Authors........: Chris Haslam (c.haslam)
  2647. ; Modified ......: mLipok
  2648. ; ===============================================================================================================================
  2649. Func _GUICtrlRichEdit_StreamFromVar($hWnd, $sVar)
  2650. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2651. Local $tEditStream = DllStructCreate($tagEDITSTREAM)
  2652. DllStructSetData($tEditStream, "pfnCallback", DllCallbackGetPtr($__g_pGRC_StreamFromVarCallback))
  2653. $__g_pGRC_sStreamVar = $sVar
  2654. Local $s = StringLeft($sVar, 5)
  2655. Local $wParam = ($s == "{\rtf" Or $s == "{urtf") ? $SF_RTF : $SF_TEXT
  2656. $wParam = BitOR($wParam, $SFF_SELECTION)
  2657. If Not _GUICtrlRichEdit_IsTextSelected($hWnd) Then
  2658. _GUICtrlRichEdit_SetText($hWnd, "")
  2659. EndIf
  2660. _SendMessage($hWnd, $EM_STREAMIN, $wParam, $tEditStream, 0, "wparam", "struct*")
  2661. Local $iError = DllStructGetData($tEditStream, "dwError")
  2662. If $iError <> 0 Then Return SetError(700, $iError, False)
  2663. Return True
  2664. EndFunc ;==>_GUICtrlRichEdit_StreamFromVar
  2665. ; #FUNCTION# ====================================================================================================================
  2666. ; Authors........: Chris Haslam (c.haslam)
  2667. ; Modified ......: mLipok
  2668. ; ===============================================================================================================================
  2669. Func _GUICtrlRichEdit_StreamToFile($hWnd, $sFileSpec, $bIncludeCOM = True, $iOpts = 0, $iCodePage = 0, $iFileEncoding = Default)
  2670. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2671. Local $wParam
  2672. If StringRight($sFileSpec, 4) = ".rtf" Then
  2673. $wParam = ($bIncludeCOM ? $SF_RTF : $SF_RTFNOOBJS)
  2674. Else
  2675. $wParam = ($bIncludeCOM ? $SF_TEXTIZED : $SF_TEXT)
  2676. If BitAND($iOpts, $SFF_PLAINRTF) Then Return SetError(1041, 0, False)
  2677. EndIf
  2678. ; only opts are $SFF_PLAINRTF and $SF_UNICODE
  2679. If BitAND($iOpts, BitNOT(BitOR($SFF_PLAINRTF, $SF_UNICODE))) Then Return SetError(1042, 0, False)
  2680. If BitAND($iOpts, $SF_UNICODE) Then
  2681. If Not BitAND($wParam, $SF_TEXT) Then Return SetError(1043, 0, False)
  2682. EndIf
  2683. If _GUICtrlRichEdit_IsTextSelected($hWnd) Then $wParam = BitOR($wParam, $SFF_SELECTION)
  2684. $wParam = BitOR($wParam, $iOpts)
  2685. If $iCodePage <> 0 Then
  2686. $wParam = BitOR($wParam, $SF_USECODEPAGE, BitShift($iCodePage, -16))
  2687. EndIf
  2688. Local $tEditStream = DllStructCreate($tagEDITSTREAM)
  2689. DllStructSetData($tEditStream, "pfnCallback", DllCallbackGetPtr($__g_pGRC_StreamToFileCallback))
  2690. If $iFileEncoding = Default Then $iFileEncoding = 0
  2691. Local $hFile = FileOpen($sFileSpec, $FO_OVERWRITE + $iFileEncoding)
  2692. If $hFile = -1 Then Return SetError(102, 0, False)
  2693. DllStructSetData($tEditStream, "dwCookie", $hFile) ; -> Send handle to CallbackFunc
  2694. _SendMessage($hWnd, $EM_STREAMOUT, $wParam, $tEditStream, 0, "wparam", "struct*")
  2695. FileClose($hFile)
  2696. Local $iError = DllStructGetData($tEditStream, "dwError")
  2697. If $iError <> 0 Then Return SetError(700, $iError, False)
  2698. Return True
  2699. EndFunc ;==>_GUICtrlRichEdit_StreamToFile
  2700. ; #FUNCTION# ====================================================================================================================
  2701. ; Authors........: Chris Haslam (c.haslam)
  2702. ; Modified ......: mLipok
  2703. ; ===============================================================================================================================
  2704. Func _GUICtrlRichEdit_StreamToVar($hWnd, $bRtf = True, $bIncludeCOM = True, $iOpts = 0, $iCodePage = 0)
  2705. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, "")
  2706. Local $wParam
  2707. If $bRtf Then
  2708. $wParam = ($bIncludeCOM ? $SF_RTF : $SF_RTFNOOBJS)
  2709. Else
  2710. $wParam = ($bIncludeCOM ? $SF_TEXTIZED : $SF_TEXT)
  2711. If BitAND($iOpts, $SFF_PLAINRTF) Then Return SetError(1041, 0, "")
  2712. EndIf
  2713. ; only opts are $SFF_PLAINRTF and $SF_UNICODE
  2714. If BitAND($iOpts, BitNOT(BitOR($SFF_PLAINRTF, $SF_UNICODE))) Then Return SetError(1042, 0, "")
  2715. If BitAND($iOpts, $SF_UNICODE) Then
  2716. If Not BitAND($wParam, $SF_TEXT) Then Return SetError(1043, 0, "")
  2717. EndIf
  2718. If _GUICtrlRichEdit_IsTextSelected($hWnd) Then $wParam = BitOR($wParam, $SFF_SELECTION)
  2719. $wParam = BitOR($wParam, $iOpts)
  2720. If $iCodePage <> 0 Then
  2721. $wParam = BitOR($wParam, $SF_USECODEPAGE, BitShift($iCodePage, -16))
  2722. EndIf
  2723. Local $tEditStream = DllStructCreate($tagEDITSTREAM)
  2724. DllStructSetData($tEditStream, "pfnCallback", DllCallbackGetPtr($__g_pGRC_StreamToVarCallback))
  2725. $__g_pGRC_sStreamVar = ""
  2726. _SendMessage($hWnd, $EM_STREAMOUT, $wParam, $tEditStream, 0, "wparam", "struct*")
  2727. Local $iError = DllStructGetData($tEditStream, "dwError")
  2728. If $iError <> 0 Then Return SetError(700, $iError, "")
  2729. Return $__g_pGRC_sStreamVar
  2730. EndFunc ;==>_GUICtrlRichEdit_StreamToVar
  2731. ; #FUNCTION# ====================================================================================================================
  2732. ; Authors........: Prog@ndy
  2733. ; Modified ......: Chris Haslam (c.haslam)
  2734. ; ===============================================================================================================================
  2735. Func _GUICtrlRichEdit_Undo($hWnd)
  2736. If Not _WinAPI_IsClassName($hWnd, $__g_sRTFClassName) Then Return SetError(101, 0, False)
  2737. Return _SendMessage($hWnd, $EM_UNDO, 0, 0) <> 0
  2738. EndFunc ;==>_GUICtrlRichEdit_Undo
  2739. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2740. ; Name...........: __GCR_Init
  2741. ; Description ...: Sets global variables $__g_sRTFClassName, $__g_sRTFVersion, $__g_sGRE_CF_RTF and $__g_sGRE_CF_RETEXTOBJ
  2742. ; Syntax.........: __GCR_Init { }
  2743. ; Parameters ....:
  2744. ; Return values .:
  2745. ; Author ........: Prog@ndy
  2746. ; Modified.......: Chris Haslam (c.haslam)
  2747. ; Remarks .......:
  2748. ; Related .......:
  2749. ; Link ..........:
  2750. ; Example .......:
  2751. ; ===============================================================================================================================
  2752. Func __GCR_Init()
  2753. Local $ah_GUICtrlRTF_lib = DllCall("kernel32.dll", "ptr", "LoadLibraryW", "wstr", "MSFTEDIT.DLL")
  2754. If $ah_GUICtrlRTF_lib[0] <> 0 Then
  2755. $__g_sRTFClassName = "RichEdit50W"
  2756. $__g_sRTFVersion = 4.1
  2757. Else
  2758. ;RICHED20.DLL
  2759. $ah_GUICtrlRTF_lib = DllCall("kernel32.dll", "ptr", "LoadLibraryW", "wstr", "RICHED20.DLL")
  2760. $__g_sRTFVersion = FileGetVersion(@SystemDir & "\riched20.dll", "ProductVersion")
  2761. Switch $__g_sRTFVersion
  2762. Case 3.0
  2763. $__g_sRTFClassName = "RichEdit20W"
  2764. Case 5.0
  2765. $__g_sRTFClassName = "RichEdit50W"
  2766. Case 6.0
  2767. $__g_sRTFClassName = "RichEdit60W"
  2768. EndSwitch
  2769. EndIf
  2770. $__g_sGRE_CF_RTF = _ClipBoard_RegisterFormat("Rich Text Format")
  2771. $__g_sGRE_CF_RETEXTOBJ = _ClipBoard_RegisterFormat("Rich Text Format with Objects")
  2772. EndFunc ;==>__GCR_Init
  2773. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2774. ; Name...........: __GCR_StreamFromFileCallback
  2775. ; Description ...: Callback function for streaming in from a file
  2776. ; Syntax.........: __GCR_StreamFromFileCallback ( $hFile, $pBuf, $iBuflen, $pQbytes )
  2777. ; Parameters ....: $hFile - Handle to the file
  2778. ; $pBuf - pointer to a buffer in the control
  2779. ; $iBuflen - length of this buffer
  2780. ; $pQbytes - pointer to number of bytes set in buffer
  2781. ; Return values .: More bytes to "return" - 0
  2782. ; All bytes have been "returned" - 1
  2783. ; Author ........: Prog@ndy
  2784. ; Modified.......: Chris Haslam (c.haslam)
  2785. ; Remarks .......:
  2786. ; Related .......:
  2787. ; Link ..........: @@MsdnLink@@ EditStreamCallback Function
  2788. ; Example .......:
  2789. ; ===============================================================================================================================
  2790. Func __GCR_StreamFromFileCallback($hFile, $pBuf, $iBuflen, $pQbytes)
  2791. Local $tQbytes = DllStructCreate("long", $pQbytes)
  2792. DllStructSetData($tQbytes, 1, 0)
  2793. Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
  2794. Local $sBuf = FileRead($hFile, $iBuflen - 1)
  2795. If @error Then Return 1
  2796. DllStructSetData($tBuf, 1, $sBuf)
  2797. DllStructSetData($tQbytes, 1, StringLen($sBuf))
  2798. Return 0
  2799. EndFunc ;==>__GCR_StreamFromFileCallback
  2800. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2801. ; Name...........: __GCR_StreamFromVarCallback
  2802. ; Description ...: Callback function for streaming in from a variable
  2803. ; Syntax.........: __GCR_StreamFromVarCallback ( $iCookie, $pBuf, $iBufLen, $pQbytes )
  2804. ; Parameters ....: $iCookie - not used
  2805. ; $pBuf - pointer to a buffer in the control
  2806. ; $iBuflen - length of this buffer
  2807. ; $pQbytes - pointer to number of bytes set in buffer
  2808. ; Return values .: More bytes to "return" - 0
  2809. ; All bytes have been "returned" - 1
  2810. ; Author ........: Chris Haslam (c.haslam)
  2811. ; Modified.......:
  2812. ; Remarks .......:
  2813. ; Related .......:
  2814. ; Link ..........: @@MsdnLink@@ EditStreamCallback Function
  2815. ; Example .......:
  2816. ; ===============================================================================================================================
  2817. Func __GCR_StreamFromVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)
  2818. #forceref $iCookie
  2819. Local $tQbytes = DllStructCreate("long", $pQbytes)
  2820. DllStructSetData($tQbytes, 1, 0)
  2821. Local $tCtl = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
  2822. Local $sCtl = StringLeft($__g_pGRC_sStreamVar, $iBuflen - 1)
  2823. If $sCtl = "" Then Return 1
  2824. DllStructSetData($tCtl, 1, $sCtl)
  2825. Local $iLen = StringLen($sCtl)
  2826. DllStructSetData($tQbytes, 1, $iLen)
  2827. $__g_pGRC_sStreamVar = StringMid($__g_pGRC_sStreamVar, $iLen + 1)
  2828. Return 0
  2829. EndFunc ;==>__GCR_StreamFromVarCallback
  2830. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2831. ; Name...........: __GCR_StreamFToFileCallback
  2832. ; Description ...: Callback function for streaming out to a file
  2833. ; Syntax.........: __GCR_StreamToFileCallback ( $hFile, $pBuf, $iBuflen, $pQbytes )
  2834. ; Parameters ....: $hFile - Handle to the file
  2835. ; $pBuf - pointer to a buffer in the control
  2836. ; $iBuflen - length of this buffer
  2837. ; $pQbytes - pointer to number of bytes set in buffer
  2838. ; Return values .: 0
  2839. ; Author ........: Prog@ndy
  2840. ; Modified.......: Chris Haslam (c.haslam)
  2841. ; Remarks .......:
  2842. ; Related .......:
  2843. ; Link ..........: @@MsdnLink@@ EditStreamCallback Function
  2844. ; Example .......:
  2845. ; ===============================================================================================================================
  2846. Func __GCR_StreamToFileCallback($hFile, $pBuf, $iBuflen, $pQbytes)
  2847. Local $tQbytes = DllStructCreate("long", $pQbytes)
  2848. DllStructSetData($tQbytes, 1, 0)
  2849. Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
  2850. Local $s = DllStructGetData($tBuf, 1)
  2851. FileWrite($hFile, $s)
  2852. DllStructSetData($tQbytes, 1, StringLen($s))
  2853. Return 0
  2854. EndFunc ;==>__GCR_StreamToFileCallback
  2855. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2856. ; Name...........: __GCR_StreamFToVarCallback
  2857. ; Description ...: Callback function for streaming out to a variable
  2858. ; Syntax.........: __GCR_StreamToVarCallback ( $iCookie, $pBuf, $iBufLen, $pQbytes )
  2859. ; Parameters ....: $iCookie - not used
  2860. ; $pBuf - pointer to a buffer in the control
  2861. ; $iBuflen - length of this buffer
  2862. ; $pQbytes - pointer to number of bytes set in buffer
  2863. ; Return values .: 0
  2864. ; Author ........: Chris Haslam (c.haslam)
  2865. ; Modified.......: guinness
  2866. ; Remarks .......:
  2867. ; Related .......:
  2868. ; Link ..........: @@MsdnLink@@ EditStreamCallback Function
  2869. ; Example .......:
  2870. ; ===============================================================================================================================
  2871. Func __GCR_StreamToVarCallback($iCookie, $pBuf, $iBuflen, $pQbytes)
  2872. #forceref $iCookie
  2873. Local $tQbytes = DllStructCreate("long", $pQbytes)
  2874. DllStructSetData($tQbytes, 1, 0)
  2875. Local $tBuf = DllStructCreate("char[" & $iBuflen & "]", $pBuf)
  2876. Local $s = DllStructGetData($tBuf, 1)
  2877. $__g_pGRC_sStreamVar &= $s
  2878. Return 0
  2879. EndFunc ;==>__GCR_StreamToVarCallback
  2880. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2881. ; Name...........: __GCR_ConvertTwipsToSpaceUnit
  2882. ; Description ...: Converts Twips (1/1440 inch) to user space units
  2883. ; Syntax.........: __GCR_ConvertTwipsToSpaceUnit ( $nIn )
  2884. ; Parameters ....: $nIn - space in twips
  2885. ; Return values .: Success - value in space units (inches, cm, mm, points or twips)
  2886. ; Author ........: Chris Haslam (c.haslam)
  2887. ; Modified.......:
  2888. ; Remarks .......:
  2889. ; Related .......:
  2890. ; Link ..........:
  2891. ; Example .......:
  2892. ; ===============================================================================================================================
  2893. Func __GCR_ConvertTwipsToSpaceUnit($nIn)
  2894. Local $sRet
  2895. Switch $__g_iRTFTwipsPeSpaceUnit
  2896. Case 1440, 567 ; inches, cm
  2897. $sRet = StringFormat("%.2f", $nIn / $__g_iRTFTwipsPeSpaceUnit)
  2898. If $sRet = "-0.00" Then $sRet = "0.00"
  2899. Case 56.7, 72 ; mm, points
  2900. $sRet = StringFormat("%.1f", $nIn / $__g_iRTFTwipsPeSpaceUnit)
  2901. If $sRet = "-0.0" Then $sRet = "0.0"
  2902. Case Else
  2903. $sRet = $nIn
  2904. EndSwitch
  2905. Return $sRet
  2906. EndFunc ;==>__GCR_ConvertTwipsToSpaceUnit
  2907. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2908. ; Name...........: __GCR_IsNumeric
  2909. ; Description ...: Does a variable contain a numeric value?
  2910. ; Syntax.........: __GCR_IsNumeric ( $vN )
  2911. ; Parameters ....: $VN - the variable
  2912. ; $SRange - ">0", ">=0", ">0,-1", ">=0,-1"
  2913. ; Return values .: Success - True or False
  2914. ; Failure - can't fail
  2915. ; Author ........: Chris Haslam (c.haslam)
  2916. ; Modified.......:
  2917. ; Remarks .......:
  2918. ; Related .......:
  2919. ; Link ..........:
  2920. ; Example .......:
  2921. ; ===============================================================================================================================
  2922. Func __GCR_IsNumeric($vN, $sRange = "")
  2923. If Not (IsNumber($vN) Or StringIsInt($vN) Or StringIsFloat($vN)) Then Return False
  2924. Switch $sRange
  2925. Case ">0"
  2926. If $vN <= 0 Then Return False
  2927. Case ">=0"
  2928. If $vN < 0 Then Return False
  2929. Case ">0,-1"
  2930. If Not ($vN > 0 Or $vN = -1) Then Return False
  2931. Case ">=0,-1"
  2932. If Not ($vN >= 0 Or $vN = -1) Then Return False
  2933. EndSwitch
  2934. Return True
  2935. EndFunc ;==>__GCR_IsNumeric
  2936. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2937. ; Name...........: __GCR_GetParaScopeChar
  2938. ; Description ...: Gets the scope to which paragraph format settings apply
  2939. ; Syntax.........: __GCR_GetParaScopeChar ( $hWnd, $iMask, $iPFM )
  2940. ; Parameters ....: $hWnd - handle to control
  2941. ; $iMask - mask returned by _SendMessage
  2942. ; Return values .: Success - the scope character
  2943. ; Failure - can't fail
  2944. ; Author ........: Chris Haslam (c.haslam)
  2945. ; Modified.......:
  2946. ; Remarks .......: Takes advantage of an undocumented feature of EM_GETPARAFORMAT
  2947. ; Related .......:
  2948. ; Link ..........:
  2949. ; Example .......:
  2950. ; ===============================================================================================================================
  2951. Func __GCR_GetParaScopeChar($hWnd, $iMask, $iPFM)
  2952. If Not _GUICtrlRichEdit_IsTextSelected($hWnd) Then
  2953. Return "c"
  2954. ElseIf BitAND($iMask, $iPFM) = $iPFM Then
  2955. Return "a"
  2956. Else
  2957. Return "f"
  2958. EndIf
  2959. EndFunc ;==>__GCR_GetParaScopeChar
  2960. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  2961. ; Name...........: __GCR_ParseParaNumberingStyle
  2962. ; Description ...: For _GUICtrlRichEdit_SetParaNumbering(), parses $vStyle
  2963. ; Syntax.........: __GCR_ParseParaNumberingStyle ($sIn, $bForceRoman, ByRef $iPFM, ByRef $iWNumbering, ByRef $iWnumStart, ByRef $iWnumStyle, ByRef $iQspaces )
  2964. ; Parameters ....: $sIn - style string: see _GUICtrlRichEdit_SetParaNumbering()
  2965. ; $bForceRoman - If $vStyle contains numner i, interpret as Roman one else as letter i
  2966. ; $iPFM - BitOR combination of $PFM_ constants (Returned)
  2967. ; $iWNumbering - wNumbering member of PARAFORMAT2 structure
  2968. ; $iWnumStart - wNumbering Start member of PARAFORMAT2 structure (Returned)
  2969. ; $iWNumStyle - wNumberingStyle member of PARAFORMAT2 structure (Returned)
  2970. ; $iQspaces - for wNumberingTab member of PARAFORMAT2 structure (Returned)
  2971. ; Return values .: Success - True
  2972. ; Failure - False and sets @error:
  2973. ; |102 - $sIn is invalid
  2974. ; Author ........: Chris Haslam (c.haslam)
  2975. ; Modified.......:
  2976. ; Remarks .......:
  2977. ; Related .......: GuiCtrlRichEdit_SetParaNumbering()
  2978. ; Link ..........: @@MsdnLink@@ EM_PARAMFORMAT
  2979. ; Example .......:
  2980. ; ===============================================================================================================================
  2981. Func __GCR_ParseParaNumberingStyle($sIn, $bForceRoman, ByRef $iPFM, ByRef $iWNumbering, ByRef $iWnumStart, ByRef $iWnumStyle, ByRef $iQspaces)
  2982. Local Const $sRoman = "mdclxviMDCLXVI", $iRpar = 0, $i2par = 0x100, $iPeriod = 0x200, $iNbrOnly = 0x300
  2983. If $sIn = "" Then
  2984. $iWNumbering = 0
  2985. $iPFM = $PFM_NUMBERING
  2986. Else
  2987. Local $s = StringStripWS($sIn, $STR_STRIPTRAILING) ; trialing whitespace
  2988. $iQspaces = StringLen($sIn) - StringLen($s)
  2989. $sIn = $s
  2990. $iPFM = $PFM_NUMBERINGTAB
  2991. If $sIn = "." Then
  2992. $iWNumbering = $PFN_BULLET
  2993. $iPFM = BitOR($iPFM, $PFM_NUMBERING)
  2994. ElseIf $sIn = "=" Then
  2995. $iWnumStyle = 0x400
  2996. $iPFM = BitOR($iPFM, $PFM_NUMBERINGSTYLE)
  2997. Else
  2998. Switch StringRight($sIn, 1)
  2999. Case ")"
  3000. If StringLeft($sIn, 1) = "(" Then
  3001. $iWnumStyle = $i2par
  3002. $sIn = StringTrimLeft($sIn, 1)
  3003. Else
  3004. $iWnumStyle = $iRpar
  3005. EndIf
  3006. Case "."
  3007. $iWnumStyle = $iPeriod
  3008. Case Else ; display only number
  3009. $iWnumStyle = $iNbrOnly
  3010. EndSwitch
  3011. $iPFM = BitOR($iPFM, $PFM_NUMBERINGSTYLE)
  3012. If $iWnumStyle <> 0x300 Then $sIn = StringTrimRight($sIn, 1)
  3013. If StringIsDigit($sIn) Then
  3014. $iWnumStart = Number($sIn)
  3015. $iWNumbering = 2
  3016. $iPFM = BitOR($iPFM, $PFM_NUMBERINGSTART, $PFM_NUMBERING)
  3017. Else
  3018. Local $bMayBeRoman = True
  3019. For $i = 1 To StringLen($sIn)
  3020. If Not StringInStr($sRoman, StringMid($sIn, $i, 1)) Then
  3021. $bMayBeRoman = False
  3022. ExitLoop
  3023. EndIf
  3024. Next
  3025. Local $bIsRoman
  3026. If $bMayBeRoman Then
  3027. $bIsRoman = $bForceRoman
  3028. Else
  3029. $bIsRoman = False
  3030. EndIf
  3031. Switch True
  3032. Case $bIsRoman
  3033. $iWnumStart = __GCR_ConvertRomanToNumber($sIn)
  3034. If $iWnumStart = -1 Then Return SetError(102, 0, False)
  3035. $iWNumbering = (StringIsLower($sIn) ? 5 : 6)
  3036. $iPFM = BitOR($iPFM, $PFM_NUMBERINGSTART, $PFM_NUMBERING)
  3037. Case StringIsAlpha($sIn)
  3038. If StringIsLower($sIn) Then
  3039. $iWNumbering = 3
  3040. Else
  3041. $iWNumbering = 4
  3042. $sIn = StringLower($sIn)
  3043. EndIf
  3044. $iWnumStart = 0
  3045. Local $iN
  3046. For $iP = 1 To StringLen($sIn)
  3047. $iN = Asc(StringMid($sIn, $i))
  3048. If $iN >= Asc("a") And $iN <= Asc("z") Then
  3049. $iWnumStart = $iWnumStart * 26 + ($iN - Asc("a") + 1)
  3050. EndIf
  3051. Next
  3052. $iPFM = BitOR($iPFM, $PFM_NUMBERINGSTART, $PFM_NUMBERING)
  3053. Case Else
  3054. Return SetError(102, 0, False)
  3055. EndSwitch
  3056. EndIf
  3057. EndIf
  3058. EndIf
  3059. Return True
  3060. EndFunc ;==>__GCR_ParseParaNumberingStyle
  3061. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3062. ; Name...........: __GCR_ConvertRomanToNumber
  3063. ; Description ...: Converts a Roman number to a number
  3064. ; Syntax.........: __GCR_ConvertRomanToNumber ( $sRnum )
  3065. ; Parameters ....: $sRnum - string containing Roman number
  3066. ; Return values .: Success - the (Arabic) number
  3067. ; Failure - -1
  3068. ; Author ........: Chris Haslam (c.haslam)
  3069. ; Modified.......:
  3070. ; Remarks .......: Is case-insensitive
  3071. ; Related .......:
  3072. ; Link ..........:
  3073. ; Example .......:
  3074. ; ===============================================================================================================================
  3075. Func __GCR_ConvertRomanToNumber($sRnum)
  3076. Local Enum $e9, $e5, $e4, $e1, $eMult, $eHigher
  3077. Local Const $aV[3][6] = [["cm", "d", "cd", "c", 100, "m"], ["xc", "l", "xl", "x", 10, "mdc"], ["ix", "v", "iv", "i", 1, "mdclx"]]
  3078. $sRnum = StringLower($sRnum)
  3079. Local $i = 1
  3080. While StringMid($sRnum, $i, 1) = "m"
  3081. $i += 1
  3082. WEnd
  3083. Local $iDigit, $iQ1s, $iRet = ($i - 1) * 1000
  3084. For $j = 0 To 2
  3085. $iDigit = 0
  3086. If StringMid($sRnum, $i, 2) = $aV[$j][$e9] Then
  3087. $iDigit = 9
  3088. $i += 2
  3089. ElseIf StringMid($sRnum, $i, 1) = $aV[$j][$e5] Then
  3090. $iDigit = 5
  3091. $i += 1
  3092. ElseIf StringMid($sRnum, $i, 2) = $aV[$j][$e4] Then
  3093. $iDigit = 4
  3094. $i += 2
  3095. ElseIf StringInStr($aV[$j][$eHigher], StringMid($sRnum, $i, 1)) Then
  3096. Return -1
  3097. EndIf
  3098. If $iDigit = 0 Or $iDigit = 5 Then
  3099. $iQ1s = 0
  3100. While StringMid($sRnum, $i, 1) = $aV[$j][$e1]
  3101. $iQ1s += 1
  3102. If $iQ1s > 3 Then Return 0
  3103. $i += 1
  3104. WEnd
  3105. $iDigit += $iQ1s
  3106. EndIf
  3107. $iRet += $iDigit * $aV[$j][$eMult]
  3108. Next
  3109. If $i <= StringLen($sRnum) Then Return -1
  3110. Return $iRet
  3111. EndFunc ;==>__GCR_ConvertRomanToNumber
  3112. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3113. ; Name...........: __GCR_SendGetCharFormatMessage
  3114. ; Description ...: Gets character format of character just after the anchor point (if text is selected) or after the inserton point
  3115. ; Syntax.........: __GCR_SendGetCharFormatMessage ( $hWnd, $tCharFormat )
  3116. ; Parameters ....: $hWnd - handle of control
  3117. ; : $tCharFormat - CHARFORMAT or CHARFORMAT2 structure
  3118. ; Return values .: Success - True
  3119. ; Failure - error of _SendMessage EM_GETCHARFORMAT SCF_SELECTION
  3120. ; Author ........: Chris Haslam (c.haslam)
  3121. ; Modified.......:
  3122. ; Remarks .......: If there is a selection, restores it before returning, with the anchor and actove positions correct,
  3123. ; even if active < anchor
  3124. ; Related .......:
  3125. ; Link ..........: @@MsdnLink@@ EM_GETCHARFORMAT
  3126. ; Example .......:
  3127. ; ===============================================================================================================================
  3128. Func __GCR_SendGetCharFormatMessage($hWnd, $tCharFormat)
  3129. Return _SendMessage($hWnd, $EM_GETCHARFORMAT, $SCF_SELECTION, $tCharFormat, 0, "wparam", "struct*")
  3130. EndFunc ;==>__GCR_SendGetCharFormatMessage
  3131. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3132. ; Name...........: __GCR_SendGetParaFormatMessage
  3133. ; Description ...: Gets format of (first) selected paragraph or, if no selection, of the paragraph containing the insertion point
  3134. ; Syntax.........: __GCR_SendGetParaFormatMessage ( $hWnd, $tParaFormat )
  3135. ; Parameters ....: $hWnd - handle of control
  3136. ; : $tParaFormat - PARAFORMAT or PARAFORMAT2 structure
  3137. ; Return values .: Success - True
  3138. ; Failure - error of _SendMessage EM_PARAFORMAT
  3139. ; Author ........: Chris Haslam (c.haslam)
  3140. ; Modified.......: guinness
  3141. ; Remarks .......:
  3142. ; Related .......:
  3143. ; Link ..........: @@MsdnLink@@ EM_PARAFORMAT
  3144. ; Example .......:
  3145. ; ===============================================================================================================================
  3146. Func __GCR_SendGetParaFormatMessage($hWnd, $tParaFormat)
  3147. Local $bIsSel = _GUICtrlRichEdit_IsTextSelected($hWnd)
  3148. Local $iInsPt = 0
  3149. If Not $bIsSel Then
  3150. Local $aS = _GUICtrlRichEdit_GetSel($hWnd)
  3151. $iInsPt = $aS[0]
  3152. Local $iN = _GUICtrlRichEdit_GetFirstCharPosOnLine($hWnd)
  3153. _GUICtrlRichEdit_SetSel($hWnd, $iN, $iN + 1, True)
  3154. EndIf
  3155. _SendMessage($hWnd, $EM_GETPARAFORMAT, 0, $tParaFormat, 0, "wparam", "struct*")
  3156. If @error Then Return SetError(@error, @extended, False)
  3157. If Not $bIsSel Then _GUICtrlRichEdit_SetSel($hWnd, $iInsPt, $iInsPt)
  3158. Return True
  3159. EndFunc ;==>__GCR_SendGetParaFormatMessage
  3160. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3161. ; Name...........: __GCR_SetOLECallback
  3162. ; Description....: Enables OLE-relationed functionality
  3163. ; Syntax.........: _GUICtrlRichEdit_SetOLECallback ( $hWnd )
  3164. ; Parameters.....: $hWnd - Handle to the control
  3165. ; Return values..: Success - True
  3166. ; Failure - False and set @error:
  3167. ; |101 - $hWnd is not a handle
  3168. ; |700 - internal error
  3169. ; Authors........: Prog@ndy
  3170. ; Modified ......: Chris Haslam (c.haslam)
  3171. ; Remarks .......:
  3172. ; Related .......:
  3173. ; Link ..........: @@MsdnLink@@ EM_SETOLECALLBACK
  3174. ; Example .......:
  3175. ; ===============================================================================================================================
  3176. Func __GCR_SetOLECallback($hWnd)
  3177. If Not IsHWnd($hWnd) Then Return SetError(101, 0, False)
  3178. ;// Initialize the OLE part.
  3179. If Not $__g_pObj_RichCom Then
  3180. $__g_tCall_RichCom = DllStructCreate("ptr[20]"); '(With some extra space for the future)
  3181. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_QueryInterface), 1)
  3182. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_AddRef), 2)
  3183. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_Release), 3)
  3184. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_GetNewStorage), 4)
  3185. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_GetInPlaceContext), 5)
  3186. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_ShowContainerUI), 6)
  3187. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_QueryInsertObject), 7)
  3188. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_DeleteObject), 8)
  3189. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_QueryAcceptData), 9)
  3190. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_ContextSensitiveHelp), 10)
  3191. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_GetClipboardData), 11)
  3192. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_GetDragDropEffect), 12)
  3193. DllStructSetData($__g_tCall_RichCom, 1, DllCallbackGetPtr($__g_pRichCom_Object_GetContextMenu), 13)
  3194. DllStructSetData($__g_tObj_RichComObject, 1, DllStructGetPtr($__g_tCall_RichCom))
  3195. DllStructSetData($__g_tObj_RichComObject, 2, 1)
  3196. $__g_pObj_RichCom = DllStructGetPtr($__g_tObj_RichComObject)
  3197. EndIf
  3198. Local Const $EM_SETOLECALLBACK = 0x400 + 70
  3199. If _SendMessage($hWnd, $EM_SETOLECALLBACK, 0, $__g_pObj_RichCom) = 0 Then Return SetError(700, 0, False)
  3200. Return True
  3201. EndFunc ;==>__GCR_SetOLECallback
  3202. ; /////////////////////////////////////
  3203. ; // OLE stuff, don't use yourself..
  3204. ; /////////////////////////////////////
  3205. ; // Useless procedure, never called..
  3206. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3207. ; Name...........: __RichCom_Object_QueryInterface
  3208. ; Description ...:
  3209. ; Syntax.........: __RichCom_Object_QueryInterface ( $pObject, $RiEFIID, $pPvObj )
  3210. ; Parameters ....:
  3211. ; Return values .:
  3212. ; Author ........:
  3213. ; Modified.......:
  3214. ; Remarks .......:
  3215. ; Related .......:
  3216. ; Link ..........:
  3217. ; Example .......:
  3218. ; ===============================================================================================================================
  3219. Func __RichCom_Object_QueryInterface($pObject, $iREFIID, $pPvObj)
  3220. #forceref $pObject, $iREFIID, $pPvObj
  3221. Return $_GCR_S_OK
  3222. EndFunc ;==>__RichCom_Object_QueryInterface
  3223. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3224. ; Name...........: __RichCom_Object_AddRef
  3225. ; Description ...:
  3226. ; Syntax.........: __RichCom_Object_AddRef ( $pObject )
  3227. ; Parameters ....:
  3228. ; Return values .:
  3229. ; Author ........:
  3230. ; Modified.......:
  3231. ; Remarks .......:
  3232. ; Related .......:
  3233. ; Link ..........:
  3234. ; Example .......:
  3235. ; ===============================================================================================================================
  3236. Func __RichCom_Object_AddRef($pObject)
  3237. ;Exit Function
  3238. Local $tData = DllStructCreate("ptr;dword", $pObject)
  3239. DllStructSetData($tData, 2, DllStructGetData($tData, 2) + 1)
  3240. Return DllStructGetData($tData, 2)
  3241. EndFunc ;==>__RichCom_Object_AddRef
  3242. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3243. ; Name...........: __RichCom_Object_Release
  3244. ; Description ...:
  3245. ; Syntax.........: __RichCom_Object_Release ( $pObject )
  3246. ; Parameters ....:
  3247. ; Return values .:
  3248. ; Author ........:
  3249. ; Modified.......:
  3250. ; Remarks .......:
  3251. ; Related .......:
  3252. ; Link ..........:
  3253. ; Example .......:
  3254. ; ===============================================================================================================================
  3255. Func __RichCom_Object_Release($pObject)
  3256. ;Exit Function
  3257. Local $tData = DllStructCreate("ptr;dword", $pObject)
  3258. If DllStructGetData($tData, 2) > 0 Then
  3259. DllStructSetData($tData, 2, DllStructGetData($tData, 2) - 1)
  3260. Return DllStructGetData($tData, 2)
  3261. EndIf
  3262. ;If @pObject[1] > 0 Then
  3263. ;Decr @pObject[1]
  3264. ;Func = @pObject[1]
  3265. ;Else
  3266. ;pObject = 0
  3267. ;End If
  3268. EndFunc ;==>__RichCom_Object_Release
  3269. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3270. ; Name...........: __RichCom_Object_GetInPlaceContext
  3271. ; Description ...:
  3272. ; Syntax.........: __RichCom_Object_GetInPlaceContext ( $pObject, $pPFrame, $pPDoc, $pFrameInfo )
  3273. ; Parameters ....:
  3274. ; Return values .:
  3275. ; Author ........:
  3276. ; Modified.......:
  3277. ; Remarks .......:
  3278. ; Related .......:
  3279. ; Link ..........:
  3280. ; Example .......:
  3281. ; ===============================================================================================================================
  3282. Func __RichCom_Object_GetInPlaceContext($pObject, $pPFrame, $pPDoc, $pFrameInfo)
  3283. #forceref $pObject, $pPFrame, $pPDoc, $pFrameInfo
  3284. Return $_GCR_E_NOTIMPL
  3285. EndFunc ;==>__RichCom_Object_GetInPlaceContext
  3286. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3287. ; Name...........: __RichCom_Object_ShowContainerUI
  3288. ; Description ...:
  3289. ; Syntax.........: __RichCom_Object_ShowContainerUI ( $pObject, $bShow )
  3290. ; Parameters ....:
  3291. ; Return values .:
  3292. ; Author ........:
  3293. ; Modified.......:
  3294. ; Remarks .......:
  3295. ; Related .......:
  3296. ; Link ..........:
  3297. ; Example .......:
  3298. ; ===============================================================================================================================
  3299. Func __RichCom_Object_ShowContainerUI($pObject, $bShow)
  3300. #forceref $pObject, $bShow
  3301. Return $_GCR_E_NOTIMPL
  3302. EndFunc ;==>__RichCom_Object_ShowContainerUI
  3303. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3304. ; Name...........: __RichCom_Object_QueryInsertObject
  3305. ; Description ...:
  3306. ; Syntax.........: __RichCom_Object_QueryInsertObject ( $pObject, $pClsid, $tStg, $vCp )
  3307. ; Parameters ....:
  3308. ; Return values .:
  3309. ; Author ........:
  3310. ; Modified.......:
  3311. ; Remarks .......:
  3312. ; Related .......:
  3313. ; Link ..........:
  3314. ; Example .......:
  3315. ; ===============================================================================================================================
  3316. Func __RichCom_Object_QueryInsertObject($pObject, $pClsid, $tStg, $vCp)
  3317. #forceref $pObject, $pClsid, $tStg, $vCp
  3318. Return $_GCR_S_OK
  3319. EndFunc ;==>__RichCom_Object_QueryInsertObject
  3320. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3321. ; Name...........: __RichCom_Object_DeleteObject
  3322. ; Description ...:
  3323. ; Syntax.........: __RichCom_Object_DeleteObject ( $pObject, $pOleobj )
  3324. ; Parameters ....:
  3325. ; Return values .:
  3326. ; Author ........:
  3327. ; Modified.......:
  3328. ; Remarks .......:
  3329. ; Related .......:
  3330. ; Link ..........:
  3331. ; Example .......:
  3332. ; ===============================================================================================================================
  3333. Func __RichCom_Object_DeleteObject($pObject, $pOleobj)
  3334. #forceref $pObject, $pOleobj
  3335. Return $_GCR_E_NOTIMPL
  3336. EndFunc ;==>__RichCom_Object_DeleteObject
  3337. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3338. ; Name...........: __RichCom_Object_QueryAcceptData
  3339. ; Description ...:
  3340. ; Syntax.........: __RichCom_Object_QueryAcceptData ( $pObject, $pDataobj, $pCfFormat, $vReco, bReally, $hMetaPict )
  3341. ; Parameters ....:
  3342. ; Return values .:
  3343. ; Author ........:
  3344. ; Modified.......:
  3345. ; Remarks .......:
  3346. ; Related .......:
  3347. ; Link ..........:
  3348. ; Example .......:
  3349. ; ===============================================================================================================================
  3350. Func __RichCom_Object_QueryAcceptData($pObject, $pDataobj, $pCfFormat, $vReco, $bReally, $hMetaPict)
  3351. #forceref $pObject, $pDataobj, $pCfFormat, $vReco, $bReally, $hMetaPict
  3352. Return $_GCR_S_OK
  3353. EndFunc ;==>__RichCom_Object_QueryAcceptData
  3354. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3355. ; Name...........: __RichCom_Object_ContextSensitiveHelp
  3356. ; Description ...:
  3357. ; Syntax.........: __RichCom_Object_ContextSensitiveHelp ( $pObject, $bEnterMode )
  3358. ; Parameters ....:
  3359. ; Return values .:
  3360. ; Author ........:
  3361. ; Modified.......:
  3362. ; Remarks .......:
  3363. ; Related .......:
  3364. ; Link ..........:
  3365. ; Example .......:
  3366. ; ===============================================================================================================================
  3367. Func __RichCom_Object_ContextSensitiveHelp($pObject, $bEnterMode)
  3368. #forceref $pObject, $bEnterMode
  3369. Return $_GCR_E_NOTIMPL
  3370. EndFunc ;==>__RichCom_Object_ContextSensitiveHelp
  3371. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3372. ; Name...........: __RichCom_Object_GetClipboardData
  3373. ; Description ...:
  3374. ; Syntax.........: __RichCom_Object_GetClipboardData ( $pObject, $pChrg, $vReco, $pPdataobj )
  3375. ; Parameters ....:
  3376. ; Return values .:
  3377. ; Author ........:
  3378. ; Modified.......:
  3379. ; Remarks .......:
  3380. ; Related .......:
  3381. ; Link ..........:
  3382. ; Example .......:
  3383. ; ===============================================================================================================================
  3384. Func __RichCom_Object_GetClipboardData($pObject, $pChrg, $vReco, $pPdataobj)
  3385. #forceref $pObject, $pChrg, $vReco, $pPdataobj
  3386. Return $_GCR_E_NOTIMPL
  3387. EndFunc ;==>__RichCom_Object_GetClipboardData
  3388. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3389. ; Name...........: __RichCom_Object_GetDragDropEffect
  3390. ; Description ...:
  3391. ; Syntax.........: __RichCom_Object_GetDragDropEffect ( $pObject, $bDrag, $iGrfKeyState, $piEffect )
  3392. ; Parameters ....:
  3393. ; Return values .:
  3394. ; Author ........:
  3395. ; Modified.......:
  3396. ; Remarks .......:
  3397. ; Related .......:
  3398. ; Link ..........:
  3399. ; Example .......:
  3400. ; ===============================================================================================================================
  3401. Func __RichCom_Object_GetDragDropEffect($pObject, $bDrag, $iGrfKeyState, $piEffect)
  3402. #forceref $pObject, $bDrag, $iGrfKeyState, $piEffect
  3403. Return $_GCR_E_NOTIMPL
  3404. EndFunc ;==>__RichCom_Object_GetDragDropEffect
  3405. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3406. ; Name...........: __RichCom_Object_GetContextMenu
  3407. ; Description ...:
  3408. ; Syntax.........: __RichCom_Object_GetContextMenu ( $pObject, $iSeltype, $pOleobj, $pChrg, $pHmenu )
  3409. ; Parameters ....:
  3410. ; Return values .:
  3411. ; Author ........:
  3412. ; Modified.......:
  3413. ; Remarks .......:
  3414. ; Related .......:
  3415. ; Link ..........:
  3416. ; Example .......:
  3417. ; ===============================================================================================================================
  3418. Func __RichCom_Object_GetContextMenu($pObject, $iSeltype, $pOleobj, $pChrg, $pHmenu)
  3419. #forceref $pObject, $iSeltype, $pOleobj, $pChrg, $pHmenu
  3420. Return $_GCR_E_NOTIMPL
  3421. EndFunc ;==>__RichCom_Object_GetContextMenu
  3422. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  3423. ; Name...........: __RichCom_Object_GetNewStorage
  3424. ; Description ...:
  3425. ; Syntax.........: __RichCom_Object_GetNewStorage ( $pObject, $pPstg )
  3426. ; Parameters ....:
  3427. ; Return values .:
  3428. ; Author ........:
  3429. ; Modified.......:
  3430. ; Remarks .......:
  3431. ; Related .......:
  3432. ; Link ..........:
  3433. ; Example .......:
  3434. ; ===============================================================================================================================
  3435. Func __RichCom_Object_GetNewStorage($pObject, $pPstg)
  3436. #forceref $pObject
  3437. ;If pCall_RichCom_CreateILockBytesOnHGlobal = 0 Or pCall_RichCom_StgCreateDocfileOnILockBytes = 0 Then Exit Function
  3438. Local $aSc = DllCall($__g_hLib_RichCom_OLE32, "dword", "CreateILockBytesOnHGlobal", "hwnd", 0, "int", 1, "ptr*", 0)
  3439. Local $pLockBytes = $aSc[3]
  3440. $aSc = $aSc[0]
  3441. ;Call Dword pCall_RichCom_CreateILockBytesOnHGlobal Using _
  3442. ;RichCom_CreateILockBytesOnHGlobal( ByVal 0&, ByVal 1&, lpLockBytes ) To sc
  3443. If $aSc Then Return $aSc
  3444. $aSc = DllCall($__g_hLib_RichCom_OLE32, "dword", "StgCreateDocfileOnILockBytes", "ptr", $pLockBytes, "dword", BitOR(0x10, 2, 0x1000), "dword", 0, "ptr*", 0)
  3445. Local $tStg = DllStructCreate("ptr", $pPstg)
  3446. DllStructSetData($tStg, 1, $aSc[4])
  3447. $aSc = $aSc[0]
  3448. ;Call Dword pCall_RichCom_StgCreateDocfileOnILockBytes Using _
  3449. ;RichCom_StgCreateDocfileOnILockBytes( _
  3450. ;@lpLockBytes _
  3451. ;, ByVal %STGM_SHARE_EXCLUSIVE Or %STGM_READWRITE Or %STGM_CREATE _
  3452. ;, ByVal 0& _
  3453. ;, lplpstg _
  3454. ;) To sc
  3455. If $aSc Then ; Call IUnknown->Release on $pLockBytes
  3456. Local $tObj = DllStructCreate("ptr", $pLockBytes) ; prepare access to vTable
  3457. Local $tUnknownFuncTable = DllStructCreate("ptr[3]", DllStructGetData($tObj, 1)) ; access IUnknown vTable
  3458. Local $pReleaseFunc = DllStructGetData($tUnknownFuncTable, 3) ; get address of IUnknwon->Release
  3459. DllCallAddress("long", $pReleaseFunc, "ptr", $pLockBytes) ; call release
  3460. EndIf
  3461. ;If sc Then Call Dword @@lpLockBytes[2] Using __RichCom_Object_Release( @lpLockBytes )
  3462. Return $aSc
  3463. EndFunc ;==>__RichCom_Object_GetNewStorage