Shaggi Posted September 26, 2010 Share Posted September 26, 2010 Hello So im having an editbox, where i got a statusbar that says where the current writing position is. I know how to calculate this, however i would like it to only update when something changed. I could do it in the main loop, however it would much rather like the calculating function to be called through GuiRegisterMsg(). Problem is, i dont know which "windows message code" i should look after. I tried a lot of the codes as described in the helpfile, but can't find the one im looking for, and they arent really documented anywhere other than something like this:WM_ACTIVATE | 0x0006 This picture probably describes it a lot better. Basically, the statusbar should update itself when the cursor position changes, like this:Right now it updates on WM_SIZE...So does anyone know which message code would be smart? Or anyone has a nifty idea on how to solve it? Regards Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 26, 2010 Moderators Share Posted September 26, 2010 Shaggi,You need to look for the $EN_UPDATE message - like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hEdit = GUICtrlCreateEdit("", 10, 10, 200, 200) $hLabel = GUICtrlCreateLabel("", 10, 400, 200, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "On_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func On_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) If $nNotifyCode = 0x400 Then GUICtrlSetData($hLabel, @SEC) ;$EN_UPDATE EndFuncJust add or delete text from the edit and the label updates. You would run your cursor position code at that point. 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...
Shaggi Posted September 26, 2010 Author Share Posted September 26, 2010 Shaggi, You need to look for the $EN_UPDATE message - like this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Test", 500, 500) $hEdit = GUICtrlCreateEdit("", 10, 10, 200, 200) $hLabel = GUICtrlCreateLabel("", 10, 400, 200, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "On_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func On_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) If $nNotifyCode = 0x400 Then GUICtrlSetData($hLabel, @SEC) ;$EN_UPDATE EndFunc Just add or delete text from the edit and the label updates. You would run your cursor position code at that point. M23 I tried that, and though it works correctly as you type it doesn't trigger when you move cursor manually, like original notepad does. Try open up notepad, activate statusbar, type some text and click around in the text. You'll notice that the number changes in the statusbar, it's that functionality i want Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 26, 2010 Moderators Share Posted September 26, 2010 Shaggi,it's that functionality i wantThen why not state it clearly in the first place and not waste my time producing something you do not need? As you already have code to detect the cursor position, why not poll it from time to time (either via Adlib or TimerDiff) and update if required. Seems a simple enough solution to your problem. 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...
Mat Posted September 26, 2010 Share Posted September 26, 2010 Richedits get EN_SELCHANGE... AutoIt Project Listing Link to comment Share on other sites More sharing options...
Shaggi Posted September 26, 2010 Author Share Posted September 26, 2010 (edited) Shaggi,Then why not state it clearly in the first place and not waste my time producing something you do not need? As you already have code to detect the cursor position, why not poll it from time to time (either via Adlib or TimerDiff) and update if required. Seems a simple enough solution to your problem. M23i thought i explained it pretty thoroughly in first post... w/e sorry then. i could easily do that, but i just thought this would be nicer and be less demanding on cpu power.Richedits get EN_SELCHANGE...but standard edits dont? Edited September 26, 2010 by Shaggi Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 26, 2010 Moderators Share Posted September 26, 2010 Shaggi,This uses virtually no CPU on my system: #include <GUIConstantsEx.au3> #Include <GuiEdit.au3> $hGUI = GUICreate("Test", 500, 500) $hEdit = GUICtrlCreateEdit("", 10, 10, 200, 200) $hEdit_Handle = GUICtrlGetHandle(-1) $hLabel_Line = GUICtrlCreateLabel("-1", 10, 400, 200, 20) $hLabel_Col = GUICtrlCreateLabel("-1", 10, 420, 200, 20) GUISetState() $iBegin = TimerInit() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If TimerDiff($iBegin) > 100 Then ; This way we only update at a reasonable rate and do not eat the CPU ; Of course you can put your own code here if you wish $iLine = ControlCommand($hGUI, "", "Edit1", "GetCurrentLine", "") If GUICtrlRead($hLabel_Line) <> $iLine Then GUICtrlSetData($hLabel_Line, $iLine) $aPos = _GUICtrlEdit_GetSel($hEdit_Handle) $iCol = $aPos[0] - _GUICtrlEdit_LineIndex($hEdit_Handle, -1) If GUICtrlRead($hLabel_Col) <> $iCol Then GUICtrlSetData($hLabel_Col, $iCol) $iBegin = TimerInit() EndIf WEndM23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. 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...
Mat Posted September 26, 2010 Share Posted September 26, 2010 but standard edits dont? Nope. AutoIt Project Listing 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