InunoTaishou Posted December 16, 2015 Posted December 16, 2015 I know how to select, set color, then deselect but I'm trying to get more of a Microsoft word style richedit.In word you can Highlight and change color, it only changes color of highlighted text, or you can change the color and it changes the color the text after the caret position.Just doing _GUICtrlRichEdit_SetCharColor($hRichEdit, $color) changes the color for all of the text in the richedit and I'm trying to avoid that.Is this possible?
mLipok Posted December 16, 2015 Posted December 16, 2015 Which version of AutoIt you are using ?in the current 3.3.14.2 you should first select text and then use _GUICtrlRichEdit_SetCharColor($hRichEdit, $color) Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 I can use _GUICtrlRichEdit_SetSel($hRichEdit, $iAnchor, $iActive) to set that specific text but I'm trying to make it so that when I set the char color, all characters after the current point is the color and nothing in front of it is changed.I'm trying to avoid checking the RichEdit control to see if the length has changed and selecting then changing the color
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 Well I guess I just needed a couple of hours of tinkering away and it and going back to one of my old projects.The solution is to use _SendMessageLocal $tCharFormat = DllStructCreate($tagCHARFORMAT) DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat)) DllStructSetData($tCharFormat, 2, $CFM_COLOR) DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6)))) _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat))And here's an example of how to use it.expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Color.au3> #include <Constants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> AutoItSetOption("GuiOnEventMode", 1) Global $frmMain = GUICreate("RichEdit Example", 580, 400) Global $frmColorSelector = CreateColorSelector() Global $rtfEdit = _GUICtrlRichEdit_Create($frmMain, "Default Black Text", 0, 0, 580, 400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $frmMain) GUISetState(@SW_SHOW, $frmMain) GUISetState(@SW_SHOW, $frmColorSelector) While (1) Sleep(100) Wend Func Close() GUIDelete($frmColorSelector) GUIDelete($frmMain) Exit(0) EndFunc Func CreateColorSelector() Local $hWnd_gui = GUICreate("Text color",116,93, 18,20,$WS_POPUP+$WS_BORDER,$WS_EX_MDICHILD,$frmMain) GUICtrlCreateLabel("",2,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x000000") GUICtrlCreateLabel("",2,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x800000") GUICtrlCreateLabel("",2,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF0000") GUICtrlCreateLabel("",2,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF00FF") GUICtrlCreateLabel("",2,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF99CC") GUICtrlCreateLabel("",16,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x993300") GUICtrlCreateLabel("",16,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF6600") GUICtrlCreateLabel("",16,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF9900") GUICtrlCreateLabel("",16,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFCC00") GUICtrlCreateLabel("",16,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFCC99") GUICtrlCreateLabel("",30,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x333300") GUICtrlCreateLabel("",30,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x808000") GUICtrlCreateLabel("",30,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x99CC00") GUICtrlCreateLabel("",30,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFFF00") GUICtrlCreateLabel("",30,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFFF99") GUICtrlCreateLabel("",44,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x003300") GUICtrlCreateLabel("",44,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x008000") GUICtrlCreateLabel("",44,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x339966") GUICtrlCreateLabel("",44,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x00FF00") GUICtrlCreateLabel("",44,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xCCFFCC") GUICtrlCreateLabel("",58,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x003366") GUICtrlCreateLabel("",58,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x008080") GUICtrlCreateLabel("",58,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x33CCCC") GUICtrlCreateLabel("",58,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x00FFFF") GUICtrlCreateLabel("",58,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xCCFFFF") GUICtrlCreateLabel("",72,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x000080") GUICtrlCreateLabel("",72,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x0000FF") GUICtrlCreateLabel("",72,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x3366FF") GUICtrlCreateLabel("",72,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x00CCFF") GUICtrlCreateLabel("",72,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x99CCFF") GUICtrlCreateLabel("",86,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x333399") GUICtrlCreateLabel("",86,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x666699") GUICtrlCreateLabel("",86,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x800080") GUICtrlCreateLabel("",86,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x993366") GUICtrlCreateLabel("",86,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xCC99FF") GUICtrlCreateLabel("",100,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x333333") GUICtrlCreateLabel("",100,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x808080") GUICtrlCreateLabel("",100,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x999999") GUICtrlCreateLabel("",100,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xC0C0C0") GUICtrlCreateLabel("",100,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlCreateLabel("Drag", 0, 72, 116, 20, -1, BitOR($WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG)) Return $hWnd_gui EndFunc Func SetColor() Local $selected_color = GUICtrlGetBkColor(@GUI_CtrlId) If ($selected_color > -1) Then Local $tCharFormat = DllStructCreate($tagCHARFORMAT) DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat)) DllStructSetData($tCharFormat, 2, $CFM_COLOR) DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6)))) _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat)) EndIf _WinAPI_SetFocus($rtfEdit) EndFunc ;==>SetColor Func GUICtrlGetBkColor($iControlID) Local $hHandle = GUICtrlGetHandle($iControlID) Local $hDC = _WinAPI_GetDC($hHandle) Local $bGetBkColor = _WinAPI_GetPixel($hDC, 2, 2) Return $bGetBkColor EndFunc ;==>GUICtrlGetBkColor
mLipok Posted December 16, 2015 Posted December 16, 2015 Which version of AutoIt you are using ?You did not answer.This is important, as in the last relaese there were changes. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 Amazing, looks look in 3.3.14 it did exactly what I needed.Spent 3 hours trying to get this to work, could have just updated and had it fixed in 15 seconds.
mLipok Posted December 16, 2015 Posted December 16, 2015 I told you 2 hours ago Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 I was deep in code lolThanks for the help!
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 Since we're talking about rich edit...Whenever I do _GUICtrlRichEdit_StreamToFile or _GUICtrlRichEdit_StreamFromFile (Idk which is doing it) it will append an extra line to the RichEdit. Any particular reason why? I'm not using any extra parameters other than the handle and the file
mLipok Posted December 16, 2015 Posted December 16, 2015 Make a repro snippet, to show what you mean.btw.Cool idea with this draging color palette. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 Same example as the one above except I added_GUICtrlRichEdit_StreamFromFile($rtfEdit, @ScriptDir & "\Edit.rtf")Right after creating the RichEdit and_GUICtrlRichEdit_StreamToFile($rtfEdit, @ScriptDir & "\Edit.rtf")Right before deleting the GUIOpening and closing it constantly adds an extra new line to the end. I don't know if it's coming from StreamFromFile or StreamToFileexpandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Color.au3> #include <Constants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> AutoItSetOption("GuiOnEventMode", 1) Global $frmMain = GUICreate("RichEdit Example", 580, 400) Global $frmColorSelector = CreateColorSelector() Global $rtfEdit = _GUICtrlRichEdit_Create($frmMain, "Default Black Text", 0, 0, 580, 400, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) _GUICtrlRichEdit_StreamFromFile($rtfEdit, @ScriptDir & "\Edit.rtf") GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $frmMain) GUISetState(@SW_SHOW, $frmMain) GUISetState(@SW_SHOW, $frmColorSelector) While (1) Sleep(100) Wend Func Close() _GUICtrlRichEdit_StreamToFile($rtfEdit, @ScriptDir & "\Edit.rtf") GUIDelete($frmColorSelector) GUIDelete($frmMain) Exit(0) EndFunc Func CreateColorSelector() Local $hWnd_gui = GUICreate("Text color",116,93, 18,20,$WS_POPUP+$WS_BORDER,$WS_EX_MDICHILD,$frmMain) GUICtrlCreateLabel("",2,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x000000") GUICtrlCreateLabel("",2,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x800000") GUICtrlCreateLabel("",2,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF0000") GUICtrlCreateLabel("",2,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF00FF") GUICtrlCreateLabel("",2,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF99CC") GUICtrlCreateLabel("",16,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x993300") GUICtrlCreateLabel("",16,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF6600") GUICtrlCreateLabel("",16,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFF9900") GUICtrlCreateLabel("",16,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFCC00") GUICtrlCreateLabel("",16,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFCC99") GUICtrlCreateLabel("",30,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x333300") GUICtrlCreateLabel("",30,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x808000") GUICtrlCreateLabel("",30,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x99CC00") GUICtrlCreateLabel("",30,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFFF00") GUICtrlCreateLabel("",30,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xFFFF99") GUICtrlCreateLabel("",44,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x003300") GUICtrlCreateLabel("",44,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x008000") GUICtrlCreateLabel("",44,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x339966") GUICtrlCreateLabel("",44,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x00FF00") GUICtrlCreateLabel("",44,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xCCFFCC") GUICtrlCreateLabel("",58,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x003366") GUICtrlCreateLabel("",58,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x008080") GUICtrlCreateLabel("",58,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x33CCCC") GUICtrlCreateLabel("",58,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x00FFFF") GUICtrlCreateLabel("",58,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xCCFFFF") GUICtrlCreateLabel("",72,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x000080") GUICtrlCreateLabel("",72,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x0000FF") GUICtrlCreateLabel("",72,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x3366FF") GUICtrlCreateLabel("",72,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x00CCFF") GUICtrlCreateLabel("",72,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x99CCFF") GUICtrlCreateLabel("",86,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x333399") GUICtrlCreateLabel("",86,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x666699") GUICtrlCreateLabel("",86,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x800080") GUICtrlCreateLabel("",86,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x993366") GUICtrlCreateLabel("",86,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xCC99FF") GUICtrlCreateLabel("",100,2,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x333333") GUICtrlCreateLabel("",100,16,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x808080") GUICtrlCreateLabel("",100,30,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0x999999") GUICtrlCreateLabel("",100,44,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlSetBkColor(-1,"0xC0C0C0") GUICtrlCreateLabel("",100,58,14,14,-1,512) GUICtrlSetOnEvent(-1,"SetColor") GUICtrlCreateLabel("Drag", 0, 72, 116, 20, -1, BitOR($WS_EX_TRANSPARENT, $GUI_WS_EX_PARENTDRAG)) Return $hWnd_gui EndFunc Func SetColor() Local $selected_color = GUICtrlGetBkColor(@GUI_CtrlId) If ($selected_color > -1) Then Local $tCharFormat = DllStructCreate($tagCHARFORMAT) DllStructSetData($tCharFormat, 1, DllStructGetSize($tCharFormat)) DllStructSetData($tCharFormat, 2, $CFM_COLOR) DllStructSetData($tCharFormat, 6, _ColorSetCOLORREF(_ColorGetRGB("0x" & Hex($selected_color, 6)))) _SendMessage($rtfEdit, $EM_SETCHARFORMAT, $SCF_SELECTION, DllStructGetPtr($tCharFormat)) EndIf _WinAPI_SetFocus($rtfEdit) EndFunc ;==>SetColor Func GUICtrlGetBkColor($iControlID) Local $hHandle = GUICtrlGetHandle($iControlID) Local $hDC = _WinAPI_GetDC($hHandle) Local $bGetBkColor = _WinAPI_GetPixel($hDC, 2, 2) Return $bGetBkColor EndFunc ;==>GUICtrlGetBkColor
mLipok Posted December 16, 2015 Posted December 16, 2015 This was asked before:Some other discussion over the internet:http://codeverge.com/embarcadero.delphi.vcl.using/problem-with-trichedit-in-xe5-em/1079375http://www.devsuperpage.com/search/Articles.aspx?G=2&ArtID=106552I have no Idea why, first I can think this is internal MS Component behavior, but I'm not sure. Signature beginning:* Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24
InunoTaishou Posted December 16, 2015 Author Posted December 16, 2015 Kind of annoying but I went ahead and just use StringReplace to replace the last instance of the \par. I guess it's StreamToFile (and StreamToVar) both append an extra new line.StringReplace(_GUICtrlRichEdit_StreamToVar($rtfEdit, True), "\par", "", -1)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now