Jump to content

Recommended Posts

Posted (edited)

I found this haphazardly and used it to my benefit. But I'd like to know why and how it works. ❚ (ChrW(0x0275A)) alone had similar effect, but ▶/❚❚ combination was most suitable for my purpose.

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

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
                    BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_SetFont($hRichEdit, 11, "Arial")
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "1. This is text" & @CRLF & "2. ▶/❚❚ This is more text")
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

 

Edited by CYCho
  • CYCho changed the title to ▶/❚❚ in RichEdit control increases font weight in the middle of text and I don't know why
Posted (edited)


I made this code in order to see the difference between the bold text and the effect created by some unicode characters in the RichEdit control. I can take benefit of this unicode phenomenon, but the problem is that I cannot cancel the effect until the end of the text.

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

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 10, 10, 300, 220, _
                    BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_SetFont($hRichEdit, 12, "Arial")

    Local $sText1 = "2. This is bold text"
    Local $sText2 = "1. This is plain text" & @LF & $sText1 & @LF & "▶/❚❚" & @LF & "3. This is more plain text"
    _GUICtrlRichEdit_AppendText($hRichEdit, $sText2)

    ; Hide "▶/❚❚" in the production
;~  Local $iBegin = StringInStr($sText2, "▶/❚❚") - 1
;~  Local $iEnd = $iBegin + 4
;~  _GUICtrlRichEdit_SetSel($hRichEdit, $iBegin, $iEnd, True)
;~  _GUICtrlRichEdit_SetCharColor($hRichEdit, 0xFFFFFF)
;~  _GUICtrlRichEdit_ChangeFontSize($hRichEdit, -12)

    ; Set 2nd line to bold typeface
    $iBegin = StringInStr($sText2, $sText1) - 1
    $iEnd = $iBegin + StringLen($sText1)
    _GUICtrlRichEdit_SetSel($hRichEdit, $iBegin, $iEnd, True)
    _GUICtrlRichEdit_SetCharAttributes($hRichEdit, "+bo")

    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

image.png.208fba1393ae2eac44ee716e691eed87.png

Edited by CYCho
Posted (edited)

I found that the effect of ▶/❚❚ varies depending on the OS character sets. It was very much noticeable in my computer which has Hangeul character set as default. So if you want to see the same effect as I see, you should use
 

_GUICtrlRichEdit_SetFont($hRichEdit, 12, "Arial", 129)

instead of
 

_GUICtrlRichEdit_SetFont($hRichEdit, 12, "Arial")

in the example above.

Edited by CYCho
  • CYCho changed the title to Why does "▶/❚❚" in RichEdit control increase font weight of the text that follows it?
Posted

Unicode codepoint 0x0275A (❚ HEAVY VERTICAL BAR) has no special effect on subsequent text.

In other codepages, it's difficult to determine out of the blue what the character renderer will do.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

@CYCho today I was able to test your 1st script at my brother's home (Win11 x64)  Here is the display on his computer, using charset 129 :

...
_GUICtrlRichEdit_SetFont($hRichEdit, 14, "Arial", 129) ; $HANGEUL_CHARSET = 129
_GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "1. This is text" & @CRLF & "2. ▶/❚❚ This is more text")
...

Arial14129.png.b2e6b6b6960e16dc27e7e64e89d144e7.png

So the 2nd "This is more text" appears bolder compared to the 1st one (as you noticed)
IIRC charset 130 (the Korean $JOHAB_CHARSET) displayed same as 129
And when no charset parameter was set, then both "This is more text" looked same.
For what it's worth...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...