Luigi Posted April 23, 2014 Share Posted April 23, 2014 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 Visit my repository Link to comment Share on other sites More sharing options...
FireFox Posted April 23, 2014 Share Posted April 23, 2014 It's not WM_NOTIFY but WM_COMMAND with EN_UPDATE or EN_CHANGE message IIRC. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2014 Moderators Share Posted April 23, 2014 Detefon,How about this: expandcollapse popup#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_COMMANDPlease ask if you have any questions. M23 Luigi 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted April 23, 2014 Share Posted April 23, 2014 Melba, No need of _SendMessage if as Firefox suggested $EN_UPDATE is used in the _WM_COMMAND func Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 24, 2014 Moderators Share Posted April 24, 2014 mikell, No need of _SendMessageHave you tried running the code without that line? 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Solution mikell Posted April 24, 2014 Solution Share Posted April 24, 2014 expandcollapse popup#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 Luigi 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 24, 2014 Moderators Share Posted April 24, 2014 mikell,So there are 2 ways of doing it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Luigi Posted April 24, 2014 Author Share Posted April 24, 2014 (edited) @FireFox, thank you! @Melba23, thank you again! @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 April 24, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 24, 2014 Moderators Share Posted April 24, 2014 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Luigi Posted April 24, 2014 Author Share Posted April 24, 2014 @Melba23, exactly! I understand it, but, you confirm! Visit my repository Link to comment Share on other sites More sharing options...
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