Jump to content

How to show the line number in <GuiRichEdit.au3>


tkminh
 Share

Recommended Posts

  • Moderators

tkminh,

Easy when you know how! :graduated:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiRichEdit.au3>
#include <WinAPI.au3>

Opt('MustDeclareVars', 1)

Global $lblMsg, $hRichEdit

Global $sText = "ASDF  fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasldsjf llskjlg fsdfsdffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF &  _
                "ABC" & @CRLF &  _
                "ASDF  fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasldsjf llskjlg fsdfsdffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF &  _
                "ABC" & @CRLF &  _
                "ASDF  fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasfj asldj fdsjf ldsjffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF &  _
                "ABC" & @CRLF &  _
                "ASDF  fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasfj asldj fdsjf ldsjffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF &  _
                "ABC" & @CRLF &  _
                "ASDF  fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasfj asldj fdsjf ldsjffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd"

Main()

Func Main()

    Local $hGui = GUICreate("RichEdit Line Finder", 320, 300)

    Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, $sText, 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))

    Local $hButton = GUICtrlCreateButton("Get Line", 10, 250, 80, 30)

    Local $hLabel = GUICtrlCreateLabel("", 100, 250, 85, 20)

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete()
                Exit
            Case $hButton
                Local $iLine = ControlCommand($hGUI, "", $hRichEdit, "GetCurrentLine", "")
                GUICtrlSetData($hLabel, $iLine)
                _WinAPI_SetFocus($hRichEdit)
        EndSwitch
    WEnd
EndFunc

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

  • Moderators

tkminh,

I showed you how to get the line number and now you want me to write a script to show you how to do exactly what you want? :D

That is not how it works around here - I have shown you how to get the line, it is up to you to incorporate that into your script. I am not writing a whole script for you. :(

You have a go yourself first and see how you get on. When you run into problems, then show us what you have tried and we will take a look at the code.

Good luck! :graduated:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

It's quite difficult, and there is no one way to go about it.

The first way is to embed the scite editor using Scilexer.dll (search on the forums)

The second is to Use a seperate control next to it (Harder than it sounds)

The third is owner drawing the richedit control.

Edited by Mat
Link to comment
Share on other sites

It's quite difficult, and there is no one way to go about it.

The first way is to embed the scite editor using Scilexer.dll (search on the forums)

The second is to Use a seperate control next to it (Harder than it sounds)

The third is owner drawing the richedit control.

Erm Mat, he doesn't want the Scintilla control embeded, he just wants line numbers like SciTE does.

Link to comment
Share on other sites

  • Moderators

Mat,

It's quite difficult

I am not sure I agree. If all the OP wants are simple labels on his GUI showing where the cursor is in his RichEdit control, it is 2 ControlCommand lines and 2 GUICtrlSetData lines in a loop with a bit of anti-flickering checking. :graduated:

That is why I suggested he have a go. I do not think he is looking to replicate SciTE. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

I was under the impression he wanted line numbering on the side of the edit control... Is that not correct? If so then embedding scintilla is probably one of the easiest ways :graduated:

If he is trying to make a status bar with line number info then there are better ways (but more complex) than what Melba is suggesting, In this case I wouldn't bother though since it's a real pain (even more so than normal messages IMHO).+

Edit: Lets just clarify what the OP wants...

  • A rich edit with line numbers for each line at the side:

    1   This is the rich edit text
      2   And on the second line
      3   And a third
      4   
      5   Etc. Etc.
  • A rich edit with a bar at the bottom with information such as line number.

    This is the rich edit text
    And on the second line
    And a third|
    
    Etc. Etc
     - - - - - - - - - - - - - - -  - - - - - -
    Line: 3 Col: 11
Edited by Mat
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...