Jump to content
StMaSi

Richedit Control Options

Recommended Posts

StMaSi

Two questions...

When presenting a form containing a richedit control, is there any way to make the displayed text, within said richedit control, non-selectable?

In addition, is there any way to hide the vertical line cursor, within said richedit control?

Thanx.

Share this post


Link to post
Share on other sites
Melba23

StMaSi,

WinSetState($hRichEdit, "", @SW_DISABLE) should do both for you.

M23 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
StMaSi

Well, that does, in fact, disable the control, but the background now turns from white to grey and the text is greyed out as well. Is there a way to have the control disabled in this manner, but to restore the background and text color to what they were prior to disabling the control?

Share this post


Link to post
Share on other sites
Melba23

StMaSi,

How about a mask like this:

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

Global $hGUI, $hGUI_Mask

Example()

Func Example()
    Local $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")

    $cButton = GUICtrlCreateButton("Test", 10, 300, 80, 30)

    GUISetState(@SW_SHOW)

    $aGUI_Pos = WinGetPos($hGUI)
    $hGUI_Mask = GUICreate("Mask", 300, 220, 0, 0, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI)
    GUISetBkColor(0xCCCCFF) ; Just so you can see the GUI in the example
    WinMove($hGUI_Mask, "", $aGUI_Pos[0] + 10, $aGUI_Pos[1] + 35)
    GUISetState(@SW_SHOWNOACTIVATE, $hGUI_Mask)
    WinSetTrans($hGUI_Mask, "", 100)

    ; Look for the main GUI moving
    GUIRegisterMsg($WM_MOVE, "_WM_MOVE")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
            Case $iMsg = $cButton
                ConsoleWrite("Hit" & @CRLF)
        EndSelect

        If _WinAPI_GetFocus() = $hRichEdit Then
            _WinAPI_SetFocus($hGUI_Mask)
        EndIf

    WEnd

EndFunc   ;==>Example

Func _WM_MOVE($hWnd, $iMsg, $wParam, $lParam)
    ; If the main GUI moves
    If $hWnd = $hGUI Then
        ; Move the child to follow
        Local $aGUI_Pos = WinGetPos($hWnd)
        WinMove($hGUI_Mask, "", $aGUI_Pos[0] + 10, $aGUI_Pos[1] + 35)
    EndIf
EndFunc   ;==>_WM_MOVE

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
StMaSi

Unfortunately, that hides my entire form.

Share this post


Link to post
Share on other sites
Melba23

StMaSi,

No it does not, it only masks the RichEdit control - if it does more than that then you have messed up the sizing code. Please post what you are using and I will take a look.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
StMaSi

Okay. Here's my code...

#include <Date.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiMenu.au3>
#include <GuiRichEdit.au3>
#include <MenuConstants.au3>
#include <Timers.au3>
#include <WindowsConstants.au3>

AutoItSetOption("TrayIconHide", 1)
AutoItSetOption("WinDetectHiddenText", 1)
AutoItSetOption("WinSearchChildren", 1)
AutoItSetOption("WinTitleMatchMode", -2)

Local $COUNTDOWN1 = IniRead(@ScriptDir & "\welcome.ini", "Parameters", "DelayTime", 10)
Local $TIMER1 = $COUNTDOWN1
Local $WINDOWS_ONTOP = 1

HotKeySet("!{F4}", "_HawkingHole")

GUISetIcon(@ScriptDir & "\welcome.ico", -1)
$RICHTEXTFILE1 = FileRead(@ScriptDir & "\welcome.rtf")
$FORM1 = GUICreate("Welcome", 600, 400, -1, -1, $WS_EX_TOPMOST, $WM_SYSCOMMAND + $WS_EX_WINDOWEDGE)
$PICTURE1 = GUICtrlCreatePic(@ScriptDir & "\welcome.bkg.jpg", 0, 0, 594, 371)
GUICtrlSetState(-1, $GUI_DISABLE)
$PICTURE2 = GUICtrlCreatePic(@ScriptDir & "\welcome.bnr.jpg", 2, 2, 157, 331)
GUICtrlSetState(-1, $GUI_DISABLE)
$PROGRESS1 = GUICtrlCreateProgress(230, 348, 170, 10)
$LABEL1 = GUICtrlCreateLabel("* Welcome", 10, 345, 190, 25)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$BUTTON1 = GUICtrlCreateButton("Upgrade", 433, 340, 75, 25)
$BUTTON2 = GUICtrlCreateButton("Defer", 513, 340, 75, 25)
$RICHEDITCONTROL1 = _GUICtrlRichEdit_Create($FORM1, $RICHTEXTFILE1, 175, 1, 415, 185, BitOR($ES_LEFT, $ES_MULTILINE, $ES_WANTRETURN, $ES_READONLY), 0)
_GUICtrlRichEdit_SetText($RICHEDITCONTROL1, $RICHTEXTFILE1)
_GUICtrlEdit_SetSel($RICHEDITCONTROL1, 600, 600)
WinSetState($RICHEDITCONTROL1, "", @SW_DISABLE)
GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND")
DisableButton($FORM1, $SC_CLOSE)
DisableButton($FORM1, $SC_MAXIMIZE)
DisableButton($FORM1, $SC_MINIMIZE)
DisableButton($FORM1, $SC_MOVE)
DisableButton($FORM1, $SC_RESTORE)
DisableButton($FORM1, $SC_SIZE)
_Timer_SetTimer($FORM1, 1000, '_Countdown')
GUISetState(@SW_SHOW)
OnTop()

While 1
    $IMSG = GUIGetMsg()
    Switch $IMSG
        Case $GUI_EVENT_CLOSE
            Exit
        Case $BUTTON1
            $UDATE = _NowCalcDate()
            $UTIME = _NowTime(5)
            $USTRING = @ComputerName & ", " & $UDATE & ", " & $UTIME
            $UFILENAME = "results.txt"
            $UFILEPATH = FileOpen(@ScriptDir & '\_log\' & $UFILENAME, 9)
            FileWrite($UFILEPATH, $USTRING & ", Upgraded" & @CRLF)
            FileClose($UFILEPATH)
            ;GUISetState(@SW_HIDE)
            Run(@ScriptDir & "\02.upgrade.exe")
            ;Exit
        Case $BUTTON2
            $DDATE = _NowCalcDate()
            $DTIME = _NowTime(5)
            $DSTRING = @ComputerName & ", " & $DDATE & ", " & $DTIME
            $DFILENAME = "results.txt"
            $DFILEPATH = FileOpen(@ScriptDir & '\_log\' & $DFILENAME, 9)
            FileWrite($DFILEPATH, $DSTRING & ", Deferred" & @CRLF)
            FileClose($DFILEPATH)
            ;GUISetState(@SW_HIDE)
            Run(@ScriptDir & "\03.defer.exe")
            ;Exit
    EndSwitch
WEnd

Func _HawkingHole()
    ; Disable ALT+F4 key combination
EndFunc   ;==>_HawkingHole

Func On_WM_SYSCOMMAND($FORM1, $MESSAGE1, $WPARAM, $LPARAM)
    If BitAND($WPARAM, 0xFFF0) = $SC_MOVE Then Return False
    Return $GUI_RUNDEFMSG
EndFunc   ;==>On_WM_SYSCOMMAND

Func DisableButton($FORM1, $IBUTTON)
    $HSYSMENU = _GUICtrlMenu_GetSystemMenu($FORM1, 0)
    _GUICtrlMenu_RemoveMenu($HSYSMENU, $IBUTTON, False)
    _GUICtrlMenu_DrawMenuBar($FORM1)
EndFunc   ;==>DisableButton

Func _Countdown($FORM1, $IMSG, $IIDTIMER, $DWTIME)
    $COUNTDOWN1 -= 1
    $PERCENT_VALUE = Floor(($COUNTDOWN1 / $TIMER1) * 100)
    $PERCENT_VALUE = 100 - $PERCENT_VALUE
    If $COUNTDOWN1 > 0 Then
        GUICtrlSetData($PROGRESS1, $PERCENT_VALUE)
    ElseIf $COUNTDOWN1 = 0 Then
        GUICtrlSetData($PROGRESS1, $PERCENT_VALUE)
        _Timer_KillTimer($FORM1, $IIDTIMER)
        ControlClick($FORM1, '', $BUTTON1)
    EndIf
EndFunc   ;==>_Countdown

Func _SecsToTime($ITICKS)
    Local $IHOURS, $IMINUTES, $ISECONDS
    _TicksToTime($ITICKS * 1000, $IHOURS, $IMINUTES, $ISECONDS)
    Return StringFormat("%2i:%02i", $IMINUTES, $ISECONDS)
EndFunc   ;==>_SecsToTime

Func OnTop()
    Global $DISPLAY = WinGetHandle($FORM1)
    WinSetOnTop($DISPLAY, "", $WINDOWS_ONTOP)
EndFunc   ;==>OnTop

When I add the...

WinSetState($RICHEDITCONTROL1, "", @SW_DISABLE)

The richedit control is greyed out. However, when I attempted to incorporate your mask code, the entire form would not display. Like you said, I must be attempting to incorporate your code improperly (it's not currently within this code). Can you assist with the incorporation?

Thanx.

Share this post


Link to post
Share on other sites
InunoTaishou

Here's something a little simpler. I used this when I was working on a console application and wanted to use a rich edit

Creating a label over the area where the richedit control is and setting the label's backcolor to $GUI_BKCOLOR_TRANSPARENT

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

Global $hGUI

Example()

Func Example()
    Local $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $lblMask = GUICtrlCreateLabel("", 10, 10, 300, 220)
    GUICtrlSetBkColor($lblMask, $GUI_BKCOLOR_TRANSPARENT)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
    ; Prevent the richedit from being entered using the 'Tab' key
    _WinAPI_SetWindowLong($hRichEdit, $GWL_STYLE, BitAND(_WinAPI_GetWindowLong($hRichEdit, $GWL_STYLE), BitNOT($WS_TABSTOP)))

    $cButton = GUICtrlCreateButton("Test", 10, 300, 80, 30)
    ; Set the button to focus so the richedit control doesn't have focus (having focus would let someone type in it)
    GUICtrlSetState($cButton, $GUI_FOCUS)

    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
            Case $iMsg = $cButton
                ConsoleWrite("Hit" & @CRLF)
        EndSelect
    WEnd

EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites
Melba23

InunoTaishou,

Great idea and much simpler than mine. I think I became fixated on using a child GUI because I had been working on one earlier on the day.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
StMaSi

When utilizing the following two bits of code from InunoTaishou, the richedit control remains active (not greyed out) and the cursor is not flashing because the focus is on the label:

...
_WinAPI_SetWindowLong($RICHEDITCONTROL1, $GWL_STYLE, BitAND(_WinAPI_GetWindowLong($RICHEDITCONTROL1, $GWL_STYLE), BitNOT($WS_TABSTOP)))
...
GUICtrlSetState($LABEL1, $GUI_FOCUS)
...

However, the richedit control is still selectable...a user can click into it, which exposes the cursor and/or double-click into it and highlight text within. Short of utilizing individual labels for the information that would be contained within one richedit control, is there no other way to "lock down" (for lack of a better term) the richedit control, but avoid disabling it (the graying out)?

Thanx again for all your help, peeps.

Share this post


Link to post
Share on other sites
Melba23

StMaSi,

Quote

However, the richedit control is still selectable...a user can click into it, which exposes the cursor and/or double-click into it and highlight text within

Really? I have just been trying to do just that and I cannot get at the RichEdit at all. How did you manage it?

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
StMaSi

Perhaps my mouse-clicking is more powerful than yours?

 

B)

Share this post


Link to post
Share on other sites
LarsJ

Create the RichEdit in a child window and disable the child window:

Create the RichEdit in a child window and disable the child window:

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

Example()

Func Example()
  $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)

  $hChild = GUICreate( "", 300, 220, 10, 10, $WS_CHILD, -1, $hGui )
  GUISetState( @SW_DISABLE )
  GUISetState()

  $hRichEdit = _GUICtrlRichEdit_Create($hChild, "This is a test.", 0, 0, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
  _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")

  GUISwitch( $hGui )
  GUISetState()

  While GUIGetMsg() <> $GUI_EVENT_CLOSE
  WEnd
EndFunc

 

Share this post


Link to post
Share on other sites
InunoTaishou

I'm going to guess and say that the label you created over the richedit control is not actually over the richedit control. So you're just clicking on the richedit.

Do this and see where your label is actually at

GUICtrlSetBkColor($LABEL1, 0xFF0000)

 

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • badcoder123
      By badcoder123
      Hey, all.  
      I've been looking for a way to change cursor colour but not the cursor itself. I've been looking for a couple hours now and can't find anything.  I also don't even know where to start, if anyone has any tips or examples please comment them.
      Thanks
    • Epic007
      By Epic007
      Hey guys I'm stuck with a program.....I need a make an automation which copies text from a chat bot app and paste it in notepad to log the replies of my chat bot and to analyse stuff....a lil help pls
       
       
       
       
       
       
       
      Thanks in advance
    • nooneclose
      By nooneclose
      I need to send a string of text to this popup and click on the ok button to save it.
      Here is the code I have so far:
      ;Start IE Sleep(7000) $oIE = _IECreate("http://www.google.com") Sleep(500) _IELoadWait($oIE) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window Sleep(500) WinSetState($hIE, "", @SW_MAXIMIZE) ;Wait for a browser page load to complete Sleep(3000) _IENavigate($oIE, "https://properURL.com") Sleep(8000) _IELoadWait($oIE) ;Attach to a browser control embedded in another window $oIE = _IEAttach("https://"properURL.com", url") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & ' Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console Sleep(2000) ;Get the title of the webpage ;Local $wTitle = _IEPropertyGet($oIE, "title") ;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle) ;Clicks the new button Sleep(3000) _IEAction($nWorkOrderB, "focus") _IEAction($nWorkOrderB, "click") Sleep(5000) ;Store the Element names where the important data will be sent ;Store the long description button Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img") ;Store the long Description field id Local $wComments = _IEGetObjById($oIE, "ma6499a9c-rte_iframe") ;Store the ok button id that is in the long description Local $wCommOk = _IEGetObjById($oIE, "m74031266-pb") ;******************************************************************************* ; Send the stored data to the proper field ;******************************************************************************* ;Click the long description button Sleep(300) _IEAction($wLongDButton, "focus") _IEAction($wLongDButton, "click") Sleep(300) ;Sends the Comments Sleep(500) _IEAction($wComments, "focus") _IEAction($wComments, "click") Sleep(500) _IEFormElementSetValue($wComments, "hello darkness my old friend") ;Click the ok button Sleep(500) _IEAction($wCommOk, "focus") _IEAction($wCommOk, "click") Sleep(500)  
      Here is the popup:

    • reida
      By reida
      Hello. Help to write the text.
      <textarea tabindex="4" class="js-input compose__labels__input" style="width: 407px; max-width: 413px;" wrap="off" autocomplete="off" data-original-name="To"></textarea>  I can not make.
      #include <IE.au3> $sLogin = 'adv' $iError = 1 $sUrl = 'https://......' $oIE = _IECreate($sUrl) ;;; _IELoadWait($oIE) $oLogin = _IEGetObjByName($oIE, "To") Sleep(7000) If IsObj($oLogin) Then _IEFormElementSetValue($oLogin, $sLogin) _IELoadWait($oIE) ; EndIf EndIf Through the selector it can be possible?
      #toolkit-154163367424641composeForm > div:nth-child(1) > div > div.compose-head__content.js-collapsed-off > div.compose-head__row-wrapper.compose-head__row-wrapper_to.js-row > div > div > div:nth-child(2) > div > div > div > textarea.js-input.compose__labels__input  
    • cramaboule
      By cramaboule
      Hi all,
       
      I was wondering if it is possible (and how) to put text on video on-the-fly (like VLC displays Title movie at the begining)
      and of course doing that in AutoIt
      Thanks in advance...
       
      C.
×