Sign in to follow this  
Followers 0
Luigi

Live character's counter when is typing with _GUICtrlRichtEdit

10 posts in this topic

Hi Forum!

In this example, it work with _GUICtrlRichtEdit, how to implemente a character's total counter when is typing?

I try with GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY') without success.

Thank you.

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

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 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")
    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

m(o.O)m

Share this post


Link to post
Share on other sites



It's not WM_NOTIFY but WM_COMMAND with EN_UPDATE or EN_CHANGE message IIRC.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Detefon,

How about this: :)

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

Global $hRichEdit, $cLabel

Example()

Func Example()
    Local $hGui, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    ConsoleWrite($hRichEdit & @CRLF)
    $cLabel = GUICtrlCreateLabel("", 10, 250, 200, 20)
    GUICtrlSetData($cLabel, _GUICtrlRichEdit_GetTextLength($hRichEdit, True, True))
    GUISetState(@SW_SHOW)

    ; Tell RichEdit to send EN_CHANGE messages <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    _SendMessage($hRichEdit, $EM_SETEVENTMASK, 0, $ENM_CHANGE)

    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

    $nBegin = TimerInit()

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

        If TimerDiff($nBegin) > 1000 Then
            _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
            $nBegin = TimerInit()
        EndIf

    WEnd
EndFunc   ;==>Example

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16) ;HiWord
    If $lParam = $hRichEdit And $iCode = $EN_CHANGE Then
        GUICtrlSetData($cLabel, _GUICtrlRichEdit_GetTextLength($hRichEdit, True, True))
    EndIf
EndFunc   ;==>_WM_COMMAND
Please ask if you have any questions. :)

M23

1 person likes this

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

Melba,

No need of _SendMessage if as Firefox suggested $EN_UPDATE is used in the _WM_COMMAND func

Share this post


Link to post
Share on other sites

mikell,

 

No need of _SendMessage

Have you tried running the code without that line? :huh:

You might want to read the Remarks on this MSDN page. ;)

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

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

Global $hRichEdit, $cLabel

Example()

Func Example()
    Local $hGui, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    ConsoleWrite($hRichEdit & @CRLF)
    $cLabel = GUICtrlCreateLabel("", 10, 250, 200, 20)
    GUICtrlSetData($cLabel, _GUICtrlRichEdit_GetTextLength($hRichEdit, True, True))
    GUISetState(@SW_SHOW)

    ; Tell RichEdit to send EN_CHANGE messages <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  ;  _SendMessage($hRichEdit, $EM_SETEVENTMASK, 0, $ENM_CHANGE)

    GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

    $nBegin = TimerInit()

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

        If TimerDiff($nBegin) > 1000 Then
            _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
            $nBegin = TimerInit()
        EndIf

    WEnd
EndFunc   ;==>Example

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    Local $iCode = BitShift($wParam, 16) ;HiWord
    If $lParam = $hRichEdit And $iCode = $EN_UPDATE Then
        GUICtrlSetData($cLabel, _GUICtrlRichEdit_GetTextLength($hRichEdit, True, True))
    EndIf
EndFunc   ;==>_WM_COMMAND

:)

1 person likes this

Share this post


Link to post
Share on other sites

mikell,

So there are 2 ways of doing it. :P

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

#8 ·  Posted (edited)

@FireFox, thank you!

@Melba23, thank you again!  :bye:

@mikell, thank you too!

I am so sorry, I want mark the two scripts with solved (@Melba and @mikell) but I have only one option.

@Melba23, I have thounsands of doubts! Is the better one question by day! ^^

Edited by Detefon

m(o.O)m

Share this post


Link to post
Share on other sites

Detefon,

 

It is important or irrelevant?

_WM_COMMAND and WM_COMMAND are the same commands/functions?

Completely irrelevant - you could name the handler function "Fred" if you so desired. What is important is the message you are registering ($WM_COMMAND) as otherwise you will not intercept the Windows message stream and the code will not work. ;)

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

@Melba23, exactly! I understand it, but, you confirm!


m(o.O)m

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
Sign in to follow this  
Followers 0