guti

Determination of the first VISIBLE line of the Scintilla element of the SciTe editor by means of the Autoit

7 posts in this topic

#1 ·  Posted

Whether it is possible to define, in principle, lines of "visible" part

of the text in an element "[CLASS:SciTEWindow]", "", "[CLASS:Scintilla; INSTANCE:1]" ?

(LПервая видимая линия.gifine 37 on the image. How to determinate it?)

If yes, how to set 'topindex' of the element "Scintilla"' with use of Autoit.?

I didn't find anything better, than API Scintilla functions. But how to use them by means of the Autoit?

Excuse for my bad English.

Share this post


Link to post
Share on other sites



#3 ·  Posted

Many thanks, mikell. It works.

_GUICtrlRichEdit_GetNumberOfFirstVisibleLine()

But it is necessary before it to expand all follds, which are before the first visible line . ("Toggle all folds" in the View menu)

If before the visible line folds were collapsed, the result is not correct.

myCode1.gif  

firstVisibleLine-4.gif   

How to calculate the number of lines in the collapsed folds, which are before the first visible line? Naturally using Autoit. I think, it is the following theme for a forum.

Thanks, for spent you time.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well with a little more time I found this : you don't need to expand folders but go back to the Scintilla Api features and dig inside
And this one was not so easy to find   :)

$Sci = ControlGetHandle("[CLASS:SciTEWindow]", "", "[CLASS:Scintilla; INSTANCE:1]")

Global Const $SCI_GETFIRSTVISIBLELINE = 2152
Global Const $SCI_DOCLINEFROMVISIBLE = 2221

$display_visible_line1 =  _Scite_SendMessage($Sci, $SCI_GETFIRSTVISIBLELINE, 0, 0) + 1
$document_visible_line1 = _Scite_SendMessage($Sci, $SCI_DOCLINEFROMVISIBLE, $display_visible_line1, 0)
Msgbox(0,"", $document_visible_line1)


Func _Scite_SendMessage($hwnd, $msg, $wparam, $lparam)
    Local $ret
    $ret = DllCall("user32.dll", "long", "SendMessageA", "long", $hwnd, "int", $msg, "int", $wparam, "int", $lparam)
    If @error Then return SetError(1, 0, 0)
    Return $ret[0]
EndFunc   ;==>_Scite_SendMessage

 

Edited by mikell

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Many thanks, mikell.

Your example led me to "Scintilla.h".
This huge field for researches.
Unfortunately there are no comments for many constants there.
So far I will try to understand in what a difference by a call of your function

$msg = $SCI_GETFIRSTVISIBLELINE ; (= 2152)

$display_visible_line1 = _Scite_SendMessage($Sci, $SCI_GETFIRSTVISIBLELINE, 0, 0) + 1

Func _Scite_SendMessage($hwnd, $msg, $wparam, $lparam)
    $ret = DllCall("user32.dll", "long", "SendMessageA", "long", $hwnd, "int", $msg, "int", $wparam, "int", $lparam)
EndFunc

and such function:

$msg = $EM_GETFIRSTVISIBLELINE ; (= 0xCE)    (from file "EditConstants.au3)

$s = _mySendMessage($Sci, $EM_GETFIRSTVISIBLELINE) + 1

Func _mySendMessage($hwnd, $iMsg, $wparam, $lparam)
    Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hwnd, "uint", $iMsg, "wparam", $wparam, "lparam", $lparam)
EndFunc   ;==>_mySendMessage

Perhaps:  Digital - Hex, "long" - "lresult".

Once again thanks that found time

Edited by guti

Share this post


Link to post
Share on other sites

#6 ·  Posted

As you could notice the Scintilla control formerly was a richedit control, reason why some Edit and RichEdit funcs still work
But the clean way is to use the proper API and the Scintilla.h constants - btw it's very easy to make an Autoit include from it
About the DllCall syntax yours is the good one, I was in a hurry  :>
SendMessageA = force ANSI while W = unicode

Happy search  :P

Share this post


Link to post
Share on other sites

#7 ·  Posted

The question is closed. Thanks for the help.

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