Sign in to follow this  
Followers 0
Shaggi

Message Code on selection move.

8 posts in this topic

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:

Posted Image

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

Share this post


Link to post
Share on other sites



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


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

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. :shocked:

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

Share this post


Link to post
Share on other sites

Shaggi,

it's that functionality i want

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. ;)

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

#6 ·  Posted (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. ;)

M23

i 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 by Shaggi

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites

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

WEnd

M23

P.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._______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

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