Sign in to follow this  
Followers 0

Caret's Column In An Edit Control

1 post in this topic

Larry/Jon/team, please consider this un-official submission for obtaining the current column in an edit control. It seems to work, but there may be bugs

Addition to ControlCommand documentation:

"GetCurrentCol", ""
    Returns the column # where the caret is in an Edit

Example usage:

; Shows coordinates of caret cursor in Notepad
Opt("WinTitleMatchMode", 2)
While 1
   $x = ControlCommand("Notepad", "", "Edit1", "getCurrentLine", "" )
   $y = ControlCommand("Notepad", "", "Edit1", "getCurrentCol", "" )
   ToolTip("Ln " & $x & " , Col " & $y,  0,0)

Add this code like this to the Win_ControlCommand() function in file script_win.cpp

if ( strcmpi(szCmd,"GETCURRENTCOL")==0 )
    uint nStart, nEnd, nOriginal;
    int  nLine;
    nOriginal = nStart;  //the charcter index

    //Decrement the character index until the row changes
    //Difference between this char index and original is the column.

    nLine = (int)SendMessage(m_ControlSearchHWND,EM_LINEFROMCHAR,(WPARAM)nStart,0);
    if (nLine >= 1)
        while (nLine == (int)SendMessage(m_ControlSearchHWND,EM_LINEFROMCHAR,(WPARAM)nStart,0))
        vResult = (int)nOriginal - (int)nStart;  //no off-by one error :)
        vResult = (int)nStart + 1;  //add 1 because first char index is 0

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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