Jump to content

Recommended Posts

Posted

 

#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $hGUI, $hRichEdit

$hGUI = GUICreate("Rich Edit Example", 400, 300)

$hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 10, 10, 380, 280, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $WS_HSCROLL, $ES_AUTOHSCROLL))
_GUICtrlRichEdit_SetText($hRichEdit, "Line 1" & @CRLF & _
                        "Line 2" & @CRLF & _
                        "Line 3" & @CRLF & _
                        "Line 4" & @CRLF & _
                        "Line 5" & @CRLF & _
                        "Line 6")

_GUICtrlRichEdit_SetSel($hRichEdit, 0, 6) ; Select the entire text to start
_GUICtrlRichEdit_SetCharAttributes($hRichEdit, "+bo")
_GUICtrlRichEdit_SetFont($hRichEdit, 12, "Comic Sans MS")
_GUICtrlRichEdit_SetParaShading($hRichEdit, 100)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

Seems like the _GUICtrlRichEdit_SetParaShading 2nd parameter is weight but maybe I'm implementing it wrong since it doesn't seem to do anything as I increase or decrease the value.

 

Posted (edited)

Thanks @Nine


To be clear, I am trying to just highlight and thicken the string on line 1 for now which is from char position 0 to 6.

Two strange things I've noticed since playing with this richedit control.

1) Even though the character "1" is the 5th character on that line I need to use 6 as the end position to include it in my selection.

2) The function _GUICtrlRichEdit_SetParaShading doesnt seem to be adjusting the weight nor changing the foreground or background color of the selection.

Strange.

Edited by NassauSky
Posted (edited)

Sorry, I got fooled by the comment on that line.  

1. Help file and  MSDN are not making it very clear.  But I believe it is based on position of character and not character itself.  One thing is clear though :  

Quote

If the cpMin and cpMax members are equal, the range is empty

So character position before 1st char is 0, and character position after 5th char is 6.  I image like bars that are embedding the string, do you see that.

2. _GUICtrlRichEdit_SetParaShading is not working me either (example does not work also).  I will need to invest more time to understand the issue.

edit : help file says "Shading does not show in Rich Edit, but shading created here will show in Word"

reedit : You will need to use EM_SETCHARFORMAT message with the $tagCHARFORMAT2.  The wWeight member is what you are looking for

Edited by Nine

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...