AndreyS Posted January 8, 2017 Posted January 8, 2017 Please tell me, who knows how to apply and cancel styles in RTF? The following code does not work: #include <GuiRichEdit.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) GUISetState(@SW_SHOW, $hGUI) Sleep(3000) GUICtrlSetStyle($hRichEdit, $ES_RIGHT) Sleep(3000) GUICtrlSetStyle($hRichEdit, -1) Sleep(3000) Thanks!
InunoTaishou Posted January 8, 2017 Posted January 8, 2017 Try _GUICtrlRichEdit_SetParaAlignment($hRichEdit, "r")
AndreyS Posted January 8, 2017 Author Posted January 8, 2017 Thank you for your participation, InunoTaishou! I know that it is possible so to realize. But the problem is not that it is the alignment applied. I need to apply in general any other style, but after the creation of RichEdit.
AndreyS Posted January 10, 2017 Author Posted January 10, 2017 Well, since experts and professionals? Really not apply the styles after creating RichText?
czardas Posted January 10, 2017 Posted January 10, 2017 Did you run the help file example for _GUICtrlRichEdit_SetParaAlignment() as suggested by @InunoTaishou ? The paragraphs are aligned after the creation of the rich edit control. If you read the description, it says: Quote Sets alignment of paragraph(s) in the current selection This is the default behaviour when working with an edit control. The user is supposed to select the paragraph that they want to be aligned. You can also select text automatically if you wish, but the complexity of this operation will depend on context. operator64 ArrayWorkshop
AndreyS Posted January 10, 2017 Author Posted January 10, 2017 )) Well, I'm saying that the style of alignment is just as an example. Well I wrote: "I need to apply in general any other style" Okay in this case show how to apply the style $ WS_EX_TRANSPARENT?
InunoTaishou Posted January 10, 2017 Posted January 10, 2017 $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400, Deafult, $WS_EX_TRANSPARENT) Should work. I don't currently have the time to test it. Most window styles will work with the richedit control. Check out this topic to see what you can do with the richedit https://msdn.microsoft.com/en-us/library/windows/desktop/bb787605(v=vs.85).aspx
AndreyS Posted January 10, 2017 Author Posted January 10, 2017 (edited) Ohhh no! (((( Well, I wrote: " apply the styles after creating RichText?" I know perfectly all the function and styles of RichEdit! I need to use style AFTER creating it! It is necessary for me to apply some styles and other styles to cancel during the program. Edited January 10, 2017 by AndreyS
orbs Posted January 10, 2017 Posted January 10, 2017 @AndreyS, if you refer to windows styles, then no, you cannot change these styles after the control was created (that is true for any type of control). one workaround you can try is to save the RTF stream, destroy the RichEdit control, create it with the new style, and reload the RTF stream. not tested. if you refer to text styles, like paragraph direction, color, font size, etc. then you can change them easily at any time, as demonstrated above. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates WinPose - simultaneous fluent move and resize Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
InunoTaishou Posted January 10, 2017 Posted January 10, 2017 @orbs You can change the styles of windows after a window has been created (richedit is a window) and you can change the styles of any control after it's been created too Here's how you would add a the $WS_EX_TRANSPARENT to your richedit control #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) GUISetState(@SW_SHOW, $hGUI) MsgBox("", "", "Default") _WinAPI_SetWindowLong($hRichEdit, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hRichEdit, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) MsgBox("", "", "WS_EX_TRANSPARENT") If you wanted to change the Style property, not ExStyle, you use $GWL_STYLE. AndreyS 1
AndreyS Posted January 10, 2017 Author Posted January 10, 2017 Oh, here it is the solution! Thank you, InunoTaishou! Why not make it easier, through a more standard functions (GUICtrlSetStyle, GUISetStyle)?
InunoTaishou Posted January 10, 2017 Posted January 10, 2017 Yup, GUISetStyle is a function you could use. I was on lunch and had a brain fart, the only thing I could remember was SetWindowLong lol.
AndreyS Posted January 12, 2017 Author Posted January 12, 2017 Tell me more, please, how to cancel $WS_EX_TRANSPARENT style?
InunoTaishou Posted January 13, 2017 Posted January 13, 2017 (edited) There's a couple ways you can remove the style. This is the easiest (to understand), just save the default styles when the window is created #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) $iExStyle = _WinAPI_GetWindowLong($hRichEdit, $GWL_EXSTYLE) GUISetState(@SW_SHOW, $hGUI) MsgBox("", "", "Default") _WinAPI_SetWindowLong($hRichEdit, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hRichEdit, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) MsgBox("", "", "WS_EX_TRANSPARENT added") _WinAPI_SetWindowLong($hRichEdit, $GWL_EXSTYLE, $iExStyle) MsgBox("", "", "WS_EX_TRANSPARENT removed") The other way is to subtract the style #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) GUISetState(@SW_SHOW, $hGUI) MsgBox("", "", "Default") _WinAPI_SetWindowLong($hRichEdit, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hRichEdit, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) MsgBox("", "", "WS_EX_TRANSPARENT added") _WinAPI_SetWindowLong($hRichEdit, $GWL_EXSTYLE, _WinAPI_GetWindowLong($hRichEdit, $GWL_EXSTYLE) - $WS_EX_TRANSPARENT) ; Or use the BitXO operation ; _WinAPI_SetWindowLong($hRichEdit, $GWL_EXSTYLE, BitXOR(_WinAPI_GetWindowLong($hRichEdit, $GWL_EXSTYLE), $WS_EX_TRANSPARENT)) MsgBox("", "", "WS_EX_TRANSPARENT removed") Or, some easy to use functions #include <GuiRichEdit.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $hGUI = GUICreate("RichEdit Style", 500, 500, -1, -1) $hRichEdit = _GUICtrlRichEdit_Create($hGui, "Test", 20,40,460,400) GUISetState(@SW_SHOW, $hGUI) MsgBox("", "", "Default") GUIAddExStyle($hRichEdit, $WS_EX_TRANSPARENT) MsgBox("", "", "WS_EX_TRANSPARENT added") GUIRemoveExStyle($hRichEdit, $WS_EX_TRANSPARENT) MsgBox("", "", "WS_EX_TRANSPARENT removed") Func GUIAddStyle($hWnd, $iStyle) Return _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $iStyle)) EndFunc Func GUIRemoveStyle($hWnd, $iStyle) Return _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR(_WinAPI_GetWindowLong($hWnd, $GWL_STYLE), $iStyle)) EndFunc Func GUIAddExStyle($hWnd, $iExStyle) Return _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $iExStyle)) EndFunc Func GUIRemoveExStyle($hWnd, $iExStyle) Return _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitXOR(_WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE), $iExStyle)) EndFunc Edited January 18, 2017 by InunoTaishou AndreyS 1
AndreyS Posted January 13, 2017 Author Posted January 13, 2017 Wow! How many variants written! Thank you very much, InunoTaishou! You helped me a lot!
orbs Posted January 18, 2017 Posted January 18, 2017 On 1/10/2017 at 8:31 PM, InunoTaishou said: You can change the styles of windows after a window has been created (richedit is a window) and you can change the styles of any control after it's been created too thank you @InunoTaishou, i did not know this, although i made several attempts to toggle RichEdit styles, for wrapping and for RTL. would you please visit these links, and let me know where i stumbled? Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates WinPose - simultaneous fluent move and resize Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Magic Math - a math puzzle Demos: Title Bar Menu - click the window title to pop-up a menu
InunoTaishou Posted January 18, 2017 Posted January 18, 2017 (edited) 10 hours ago, orbs said: thank you @InunoTaishou, i did not know this, although i made several attempts to toggle RichEdit styles, for wrapping and for RTL. would you please visit these links, and let me know where i stumbled? I had doubts I could do it if Melba wasn't able to, I was right lol. Seems to be a bug (maybe intended? doubt it) with richedit not updating word wrap when the style is removed. Edit: Check your wrapping topic, there is a solution Edited January 19, 2017 by InunoTaishou
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