Results 1 to 9 of 9

Thread: Scintilla Source Code editor OCX for VB

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2015

    Scintilla Source Code editor OCX for VB

    I noticed the board didn't have much on the Scintilla source code editor so wanted to make sure a copy of this got saved.

    Scintilla is a source code editor component that includes source code highlighting, code folding, line numbering, bookmarks, built in intellisense etc. It is a great control if you want to create a source code editor or debugger UI.

    Name:  screenshot.jpg
Views: 575
Size:  14.5 KB

    Its a free component written in C and builds as SciLexer.dll. You can download the source files here:


    The source attached here, scivb2.ocx, is a vb6 control that makes using it quite easy. This is an update to Stewarts great scivb.ocx control that is part of his cEditXP souce code editor.


    I spent some time inside of it and adapted it for what I needed so I could use it as a debugger UI You can see an example of it in action here:


    I have attached a copy of the ocx source. I have been using this for several years now and has proven stable. Any updates will be in the git repo below.


    public methods:
    Event NewLine()
    Event MouseDwellEnd(lline As Long, Position As Long)
    Event MouseDwellStart(lline As Long, Position As Long)
    Event MarginClick(lline As Long, Position As Long, margin As Long, modifiers As Long)
    Event AutoCSelection(Text As String)                        'Auto Completed selected
    Event CallTipClick(Position As Long)                        'Clicked a calltip
    Event UserListSelection(listType As Long, Text As String)   'Selected AutoComplete
    Event LineChanged(Position As Long)
    Event OnModified(Position As Long, modificationType As Long)
    Event DoubleClick()
    Event MouseUp(Button As Integer, Shift As Integer, x As Long, y As Long)
    Event MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long)
    Event key(ch As Long, modifiers As Long)
    Event KeyUp(KeyCode As Long, Shift As Long)
    Event KeyDown(KeyCode As Long, Shift As Long)
    Event DebugMsg(Msg As String)
    Event KeyPress(Char As Long)
    Event AutoCompleteEvent(className As String)
    Property FoldComment() As Boolean
    Property FoldAtElse() As Boolean
    Property FoldMarker() As FoldingStyle
    Property Folding() As Boolean    'If true folding will be automatically handled.
    Property DisplayCallTips() As Boolean   'If this is set to true then calltips will be displayed.  To use this you must also use <B>LoadAPIFile</b> to load an external API file which contains simple instructions to the editor on what calltips to display.
    Property SelFore() As OLE_COLOR  'The allows you to control the fore color of the selected color.
    Property SelBack() As OLE_COLOR  'This allow's you to set the backcolor for selected text.
    Property WordWrap() As Boolean 'If set to true the document will wrap lines which are longer than itself.  If false then it will dsiplay normally.
    Property ShowFlags() As Boolean  'If this is true the second gutter will be displayed and Flags/Bookmarks will be displayed.
    Property isDirty() As Boolean   'This is a read only property.  It allows you to get the modified status of the Scintilla window.
    Property ReadOnly() As Boolean  'This property allows you to set the readonly status of Scintilla.  When in readonly you can scroll the document, but no editing can be done.
    Property LineNumbers() As Boolean    'If this is set to true then the first gutter will be visible and display line numbers.  If this is false then the first gutter will remain hidden.
    Property ContextMenu() As Boolean    'If set to true then the default Scintilla context menu will be displayed when a user right clicks on the window.  If this is set to false then no context menu will be displayed.  If you are utilizing a customer context menu then this should be set to false.
    Property AutoCompleteString() As String  'This store's the list which autocomplete will use.  Each word needs to be seperated by a space.
    Property IndentWidth() As Long   'This controls the number of spaces Tab will indent.  IndentWidth only applies if <B>TabIndents</b> is set to false.
    Property BackSpaceUnIndents() As Boolean 'If tabindents is set to false, and BackSpaceUnIndents is set to true then the backspaceunindents will remove the same number of spaces as tab inserts.  If it's set to false then it will work normally.
    Property UseTabIndents() As Boolean 'If this is true tab inserts indent characters.  If it is set to false tab will insert spaces.
    Property useTabs() As Boolean
    Property ShowIndentationGuide() As Boolean   'If true indention guide's will be displayed.
    Property MaintainIndentation() As Boolean 'If this is set to true the editor will automatically keep the previous line's indentation.
    Property HighLightActiveLine() As Boolean    'When set to true the active line will be highlighted using the color selected from LineBackColor.
    Property ActiveLineBackColor() As OLE_COLOR    'Allows you to control the backcolor of the active line.
    Property SelText() As String 'Allows you to get and set the seltext of the scintilla window.
    Property Text() As String    'Allows you to get and set the text of the scintilla window.
    Property SelLength() As Long
    Property SelEnd() As Long
    Property SelStart() As Long
    Property codePage() As SC_CODETYPE
    Property TotalLines() As Long
    Property VisibleLines() As Long
    Property FirstVisibleLine() As Long
    Property AutoCloseQuotes() As Boolean    'When set to true quotes will automatically be closed.
    Property AutoCloseBraces() As Boolean    'When this is set to true braces <B>{, [, (</b> will be closed automatically.
    Property Version() As String
    Property currentHighlighter() As String
    Property sciHWND() As Long
    Friend Property Let ReplaceFormActive(x As Boolean)
    Function isMouseOverCallTip() As Boolean
    Sub LockEditor(Optional locked As Boolean = True)
    Function WordUnderMouse(pos As Long, Optional ignoreWhiteSpace As Boolean = False) As String
    Sub ShowGoto()
    Sub ShowAbout()
    Function ShowFindReplace() As Object
    Function FindNext(Optional wrap As Boolean = False) As Long
    Function Find(sSearch As String, _
    Function FindAll(sSearch As String, _
    Function ReplaceAll(strSearchFor As String, _
    Function ReplaceText(strSearchFor As String, _
    Sub MarkAll(strFind As String)
    Sub SetMarker(iLine As Long, Optional iMarkerNum As Long = 2)
    Sub DeleteAllMarkers(Optional marknum As Long = 2)
    Sub PrevMarker(lline As Long, Optional marknum As Long = 2)
    Sub NextMarker(lline As Long, Optional marknum As Long = 2)
    Sub DeleteMarker(iLine As Long, Optional marknum As Long = 2)
    Sub ToggleMarker(Optional line As Long = -1)
    Sub FoldAll()
    Sub ShowCallTip(strVal As String)
    Sub StopCallTip()
    Function AddCallTip(functionPrototype As String)
    Function LoadCallTips(strFile As String) As Long
    Function LoadFile(strFile As String) As Boolean
    Function SaveFile(strFile As String) As Boolean
    Function PreviousWord() As String
    Function CurrentWord() As String
    Sub ShowAutoComplete(strVal As String)
    Function GetCaretInLine() As Long
    Function CurrentLine() As Long
    Sub SetCurrentPosition(lval As Long)
    Function PositionFromLine(lline As Long) As Long
    Sub ClearUndoBuffer()
    Function SelectLine() As Long
    Function SelectAll() As Long
    Function Paste() As Long
    Function Copy() As Long
    Function Cut() As Long
    Function Undo() As Long
    Function Redo() As Long
    Function SetFocus() As Long
    Function GotoCol(Column As Long) As Long
    Sub GotoLineColumn(iLine As Long, iCol As Long)
    Function GotoLine(line As Long) As Long
    Function GetLineText(ByVal lline As Long) As String
    Function FileExists(strFile As String) As Boolean
    Function FolderExists(path) As Boolean
    Sub GotoLineCentered(ByVal line As Long, Optional selected As Boolean = True)
    Function hilightWord(sSearch As String, Optional color As Long = 0, Optional compare As VbCompareMethod = vbTextCompare) As Long
    Sub hilightClear()
    Sub UncommentBlock()
    Sub CommentBlock()
    Function ExportToHTML(filePath As String) As Boolean
    Function LoadHighlightersDir(dirPath As String) As Long
    Function HighlighterForExtension(fPath As String) As String
    Function LoadHighlighter(filePath As String, Optional andSetActive As Boolean = True) As Boolean
    Function SetHighlighter(langName As String) As Boolean
    The main object has two other public classes accessible.

    Public misc As New CMiscSettings
    Public DirectSCI As New cDirectSCI

    Property MarkerFore() As OLE_COLOR   'Allows you to configure the forecolor of the folding marker.
    Property MarkerBack() As OLE_COLOR   'Allows you to configure the backcolor of the folding markers.
    Property GutterWidth(g As Gutters) As Long
    Property GutterType(g As Gutters) As GutterTypes
    Property BraceBadBack() As OLE_COLOR
    Property BraceMatchBack() As OLE_COLOR
    Property BraceMatchUnderline() As Boolean
    Property BraceMatchItalic() As Boolean
    Property BraceMatchBold() As Boolean
    Property BraceBadFore() As OLE_COLOR
    Property BraceMatchFore() As OLE_COLOR
    Public Function CurrentFunction()
    Function SendEditor(ByVal Msg As Long, Optional ByVal wParam As Long = 0, Optional ByVal lParam = 0) As Long
    Sub SetCaretPolicy(caretPolicy As Long, caretSlop As Long)
    Function GetStyleBitsNeeded() As Long
    Function GetPropertyInt() As Long
    Function GetPropertyExpanded(Buf As String) As Long
    Function GetProperty(Buf As String) As Long
    Sub LoadLexerLibrary(path As String)
    Sub SetLexerLanguage(language As String)
    Sub SetKeyWords(keywordSet As Long, Keywords As String)
    Sub SetProperty(key As String, Value As String)
    Sub Colourise(starts As Long, ends As Long)
    Function GetLexer() As Long
    Sub SetLexer(Lexer As Long)
    Sub StopRecord()
    Sub StartRecord()
    Sub SelectionDuplicate()
    Function GetPasteConvertEndings() As Boolean
    Sub SetPasteConvertEndings(convert As Boolean)
    Sub ToggleCaretSticky()
    Sub SetCaretSticky(useCaretStickyBehaviour As Boolean)
    Function GetCaretSticky() As Boolean
    Function FindColumn(line As Long, Column As Long) As Long
    Function EncodedFromUTF8(encoded As String) As Long
    Sub SetLengthForEncode(bytes As Long)
    Function TargetAsUTF8(S As String) As Long
    Sub Allocate(bytes As Long)
    Function AutoCGetCurrent() As Long
    Sub SetCharsDefault()
    Sub SetWhitespaceChars(characters As String)
    Sub WordRightEndExtend()
    Sub WordRightEnd()
    Sub WordLeftEndExtend()
    Sub WordLeftEnd()
    Sub StutteredPageDownExtend()
    Sub StutteredPageDown()
    Sub StutteredPageUpExtend()
    Sub StutteredPageUp()
    Sub PageDownRectExtend()
    Sub PageUpRectExtend()
    Sub LineEndRectExtend()
    Sub VCHomeRectExtend()
    Sub HomeRectExtend()
    Sub CharRightRectExtend()
    Sub CharLeftRectExtend()
    Sub LineUpRectExtend()
    Sub LineDownRectExtend()
    Function GetSelectionMode() As Long
    Sub SetSelectionMode(mode As Long)
    Sub CopyText(length As Long, Text As String)
    Sub CopyRange(starts As Long, ends As Long)
    Sub ParaUpExtend()
    Sub ParaUp()
    Sub ParaDownExtend()
    Sub ParaDown()
    Sub SetHotspotSingleLine(singleLine As Boolean)
    Sub SetHotspotActiveUnderline(underline As Boolean)
    Sub SetHotspotActiveBack(useSetting As Boolean, back As Long)
    Sub SetHotspotActiveFore(useSetting As Boolean, fore As Long)
    Function GetPrintWrapMode() As Long
    Sub SetPrintWrapMode(mode As Long)
    Sub SetYCaretPolicy(caretPolicy As Long, caretSlop As Long)
    Sub SetXCaretPolicy(caretPolicy As Long, caretSlop As Long)
    Sub GrabFocus()
    Sub ChooseCaretX()
    Function GetXOffset() As Long
    Sub SetXOffset(newOffset As Long)
    Sub DelLineRight()
    Sub DelLineLeft()
    Sub SetVisiblePolicy(visiblePolicy As Long, visibleSlop As Long)
    Sub WordPartRightExtend()
    Sub WordPartRight()
    Sub WordPartLeftExtend()
    Sub WordPartLeft()
    Function GetControlCharSymbol() As Long
    Sub SetControlCharSymbol(symbol As Long)
    Function GetCursor() As Long
    Sub SetCursor(cursorType As Long)
    Function GetMouseDownCaptures() As Boolean
    Sub SetMouseDownCaptures(captures As Boolean)
    Function GetStatus() As Long
    Sub SetStatus(statusCode As Long)
    Function GetFocus() As Boolean
    Sub SetFocus()
    Function GetModEventMask() As Long
    Sub ReleaseDocument(doc As Long)
    Sub AddRefDocument(doc As Long)
    Function CreateDocument() As Long
    Function GetZoom() As Long
    Sub SetZoom(Zoom As Long)
    Function SelectionIsRectangle() As Boolean
    Sub UsePopUp(allowPopUp As Boolean)
    Function LinesOnScreen() As Long
    Function SearchPrev(flags As Long, Text As String) As Long
    Function SearchNext(flags As Long, Text As String) As Long
    Sub SearchAnchor()
    Sub SetEdgeColour(edgeColour As Long)
    Sub SetEdgeMode(mode As Long)
    Function GetEdgeMode() As Long
    Sub SetEdgeColumn(Column As Long)
    Function GetEdgeColumn() As Long
    Sub SetModEventMask(mask As Long)
    Sub SetDocPointer(pointer As Long)
    Function GetDocPointer() As Long
    Sub SetViewEOL(visible As Boolean)
    Function GetViewEOL() As Boolean
    Sub BraceBadLight(pos As Long)
    Sub BraceHighlight(pos1 As Long, pos2 As Long)
    Function LineLength(line As Long) As Long
    Sub MoveCaretInsideView()
    Sub LineCopy()
    Sub VCHomeWrapExtend()
    Sub VCHomeWrap()
    Sub LineEndWrapExtend()
    Sub LineEndWrap()
    Sub HomeWrapExtend()
    Sub HomeWrap()
    Sub LineEndDisplayExtend()
    Sub LineEndDisplay()
    Sub HomeDisplayExtend()
    Sub HomeDisplay()
    Sub DeleteBackNotLine()
    Sub LineScrollUp()
    Sub LineScrollDown()
    Sub UpperCase()
    Sub LowerCase()
    Sub LineDuplicate()
    Sub LineTranspose()
    Sub LineDelete()
    Sub LineCut()
    Sub DelWordRight()
    Sub DelWordLeft()
    Sub ZoomOut()
    Sub ZoomIn()
    Sub VCHomeExtend()
    Sub VCHome()
    Sub FormFeed()
    Sub NewLine()
    Sub BackTab()
    Sub Indent()
    Sub DeleteBack()
    Sub Cancel()
    Sub EditToggleOvertype()
    Sub PageDownExtend()
    Sub PageDown()
    Sub PageUpExtend()
    Sub PageUp()
    Sub DocumentEndExtend()
    Sub DocumentEnd()
    Sub DocumentStartExtend()
    Sub DocumentStart()
    Sub LineEndExtend()
    Sub LineEnd()
    Sub HomeExtend()
    Sub Home()
    Sub WordRightExtend()
    Sub WordRight()
    Sub WordLeftExtend()
    Sub WordLeft()
    Sub CharRightExtend()
    Sub CharRight()
    Sub CharLeftExtend()
    Sub CharLeft()
    Sub LineUpExtend()
    Sub LineUp()
    Sub LineDownExtend()
    Sub LineDown()
    Sub SetFoldMarginHiColour(useSetting As Boolean, fore As Long)
    Sub SetFoldMarginColour(useSetting As Boolean, back As Long)
    Sub LinesSplit(pixelWidth As Long)
    Sub LinesJoin()
    Sub TargetFromSelection()
    Sub SetTwoPhaseDraw(twoPhase As Boolean)
    Function GetTwoPhaseDraw() As Boolean
    Sub AppendText(length As Long, Text As String)
    Function GetVScrollBar() As Boolean
    Sub SetVScrollBar(show As Boolean)
    Function GetEndAtLastLine() As Boolean
    Sub SetEndAtLastLine(EndAtLastLine As Boolean)
    Function GetScrollWidth() As Long
    Sub SetScrollWidth(pixelWidth As Long)
    Function GetLayoutCache() As Long
    Sub SetLayoutCache(mode As Long)
    Function GetWrapStartIndent() As Long
    Sub SetWrapStartIndent(Indent As Long)
    Function GetWrapVisualFlagsLocation() As Long
    Sub SetWrapVisualFlagsLocation(wrapVisualFlagsLocation As Long)
    Function GetWrapVisualFlags() As Long
    Sub SetWrapVisualFlags(wrapVisualFlags As Long)
    Function GetWrapMode() As Long
    Sub SetWrapMode(mode As Long)
    Function WordEndPosition(pos As Long, onlyWordCharacters As Boolean) As Long
    Function WordStartPosition(pos As Long, onlyWordCharacters As Boolean) As Long
    Function GetMouseDwellTime() As Long
    Sub SetMouseDwellTime(periodMilliseconds As Long)
    Function GetBackSpaceUnIndents() As Boolean
    Sub SetBackSpaceUnIndents(bsUnIndents As Boolean)
    Function GetTabIndents() As Boolean
    Sub SetTabIndents(TabIndents As Boolean)
    Sub EnsureVisibleEnforcePolicy(line As Long)
    Sub SetFoldFlags(flags As Long)
    Sub EnsureVisible(line As Long)
    Sub ToggleFold(line As Long)
    Function GetFoldExpanded(line As Long) As Boolean
    Sub SetFoldExpanded(line As Long, expanded As Boolean)
    Function GetLineVisible(line As Long) As Boolean
    Sub HideLines(lineStart As Long, LineEnd As Long)
    Sub ShowLines(lineStart As Long, LineEnd As Long)
    Function GetFoldParent(line As Long) As Long
    Function GetLastChild(line As Long, level As Long) As Long
    Function GetFoldLevel(line As Long) As Long
    Sub SetFoldLevel(line As Long, level As Long)
    Function WrapCount(line As Long) As Long
    Function DocLineFromVisible(lineDisplay As Long) As Long
    Function VisibleFromDocLine(line As Long) As Long
    Sub CallTipSetForeHlt(fore As Long)
    Sub CallTipSetFore(fore As Long)
    Sub CallTipSetBack(back As Long)
    Sub CallTipSetHlt(starts As Long, ends As Long)
    Function CallTipActive() As Boolean
    Sub CallTipCancel()
    Sub CallTipShow(pos As Long, definition As String)
    Function GetSearchFlags() As Long
    Sub SetSearchFlags(flags As Long)
    Function SearchInTarget(length As Long, Text As String) As Long
    Function ReplaceTargetRE(length As Long, Text As String) As Long
    Function ReplaceTarget(length As Long, Text As String) As Long
    Sub SetTargetEnd(pos As Long)
    Sub SetTargetStart(pos As Long)
    Function GetCaretWidth() As Long
    Sub SetCaretWidth(pixelWidth As Long)
    Function GetOvertype() As Boolean
    Sub SetOvertype(OverType As Boolean)
    Function GetDirectPointer() As Long
    Function GetDirectFunction() As Long
    Function GetTextLength() As Long
    Function GetText() As String
    Sub SetText(Text As String)
    Sub Clear()
    Sub Paste()
    Sub Copy()
    Sub Cut()
    Sub Undo()
    Sub EmptyUndoBuffer()
    Function CanUndo() As Boolean
    Function CanPaste() As Boolean
    Sub Nulls()
    Sub SetReadOnly(ReadOnly As Boolean)
    Sub ReplaceSel(Text As String)
    Sub ScrollCaret()
    Sub LineScroll(columns As Long, lines As Long)
    Function LineFromPosition(pos As Long) As Long
    Function PointYFromPosition(pos As Long) As Long
    Function PointXFromPosition(pos As Long) As Long
    Sub HideSelection(normal As Boolean)
    Function GetTextRange() As Long
    Function GetSelText() As String
    Function GetSelectionLength() As Long
    Function GetSelectionStart() As Long
    Function GetSelectionEnd() As Long
    Sub SetSel(starts As Long, ends As Long)
    Function GetModify() As Boolean
    Function GetMarginRight() As Long
    Sub SetMarginRight(pixelWidth As Long)
    Function GetMarginLeft() As Long
    Sub SetMarginLeft(pixelWidth As Long)
    Function GetLineCount() As Long
    Function GetLine(line As Long, Text As String) As Long
    Function GetFirstVisibleLine() As Long
    Function GetPrintColourMode() As Long
    Sub SetPrintColourMode(mode As Long)
    Function GetPrintMagnification() As Long
    Sub SetPrintMagnification(magnification As Long)
    Sub SetSelectionEnd(pos As Long)
    Sub SetSelectionStart(pos As Long)
    Sub SetCurrentPos(pos As Long)
    Function GetReadOnly() As Boolean
    Function GetUsePalette() As Boolean
    Function GetCodePage() As Long
    Function GetLineEndPosition(line As Long) As Long
    Function GetHighlightGuide() As Long
    Sub SetHighlightGuide(Column As Long)
    Function GetIndentationGuides() As Boolean
    Sub SetIndentationGuides(show As Boolean)
    Function GetHScrollBar() As Boolean
    Sub SetHScrollBar(show As Boolean)
    Function GetColumn()
    Function GetLineIndentation(line As Long) As Long
    Sub SetLineIndentation(line As Long, indentSize As Long)
    Function GetUseTabs() As Boolean
    Sub SetUseTabs(useTabs As Boolean)
    Function GetIndent() As Long
    Sub SetIndent(indentSize As Long)
    Function AutoCGetMaxHeight() As Long
    Sub AutoCSetMaxHeight(rowCount As Long)
    Function AutoCGetMaxWidth() As Long
    Sub AutoCSetMaxWidth(characterCount As Long)
    Sub AutoCSetTypeSeparator(separatorCharacter As Long)
    Function AutoCGetTypeSeparator() As Long
    Sub ClearRegisteredImages()
    Sub RegisterImage(types As Long, xpmData As String)
    Function AutoCGetDropRestOfWord() As Boolean
    Sub AutoCSetDropRestOfWord(dropRestOfWord As Boolean)
    Function AutoCGetAutoHide() As Boolean
    Sub AutoCSetAutoHide(autoHide As Boolean)
    Sub UserListShow(listType As Long, itemList As String)
    Function AutoCGetIgnoreCase() As Boolean
    Sub AutoCSetIgnoreCase(ignoreCase As Boolean)
    Function AutoCGetChooseSingle() As Boolean
    Sub AutoCSetChooseSingle(chooseSingle As Boolean)
    Sub AutoCSetFillUps(characterSet As String)
    Function AutoCGetCancelAtStart() As Boolean
    Sub AutoCSetCancelAtStart(Cancel As Boolean)
    Sub AutoCSelect(Text As String)
    Function AutoCGetSeparator() As Long
    Sub AutoCSetSeparator(separatorCharacter As Long)
    Sub AutoCStops(characterSet As String)
    Sub AutoCComplete()
    Function AutoCActive() As Boolean
    Sub AutoCCancel()
    Sub AutoCShow(lenEntered As Long, itemList As String)
    Sub StyleSetChangeable(Style As Long, changeable As Boolean)
    Sub SetCaretLineBack(back As Long)
    Sub SetCaretLineVisible(show As Boolean)
    Function GetCaretLineVisible() As Boolean
    Function GetMaxLineState() As Long
    Function GetLineState(line As Long) As Long
    Sub SetLineState(line As Long, State As Long)
    Function GetStyleBits() As Long
    Sub StyleSetBits(bits As Long)
    Sub SetWhitespaceBack(useSetting As Boolean, back As Long)
    Sub SetWhitespaceFore(useSetting As Boolean, fore As Long)
    Sub IndicSetFore(indic As Long, fore As Long)
    Function IndicGetStyle(indic As Long) As Long
    Sub IndicStyleSet(indic As Long, Style As Long)
    Sub EndUndoAction()
    Sub BeginUndoAction()
    Sub SetWordChars(characters As String)
    Sub SetCaretPeriod(periodMilliseconds As Long)
    Function GetCaretPeriod() As Long
    Sub StyleSetVisible(Style As Long, visible As Boolean)
    Sub SetStylingEx(length As Long, styles As String)
    Sub ClearAllCmdKeys()
    Sub ClearCmdKey(KeyDef As Long)
    Sub AssignCmdKey(keyDefinition As Long, Msg As Long)
    Sub SetCaretFore(fore As Long)
    Sub SetSelBack(useSetting As Boolean, back As Long)
    Sub SetSelFore(useSetting As Boolean, fore As Long)
    Sub StyleSetHotSpot(Style As Long, hotspot As Boolean)
    Sub StyleSetCharacterSet(Style As Long, characterSet As Long)
    Sub StyleSetCase(Style As Long, caseForce As Long)
    Sub StyleSetUnderline(Style As Long, underline As Boolean)
    Sub StyleResetDefault()
    Sub StyleSetEOLFilled(Style As Long, filled As Boolean)
    Sub StyleSetFont(Style As Long, fontName As String)
    Sub StyleSetSize(Style As Long, sizePoints As Long)
    Sub StyleSetItalic(Style As Long, italic As Boolean)
    Sub StyleSetBold(Style As Long, bold As Boolean)
    Sub StyleSetBack(Style As Long, back As Long)
    Sub StyleSetFore(Style As Long, fore As Long)
    Sub StyleClearAll()
    Function GetMarginSensitiveN(margin As Long) As Boolean
    Sub SetMarginSensitiveN(margin As Long, sensitive As Boolean)
    Function GetMarginMaskN(margin As Long) As Long
    Sub SetMarginMaskN(margin As Long, mask As Long)
    Function GetMarginWidthN(margin As Long) As Long
    Sub SetMarginWidthN(margin As Long, pixelWidth As Long)
    Function GetMarginTypeN(margin As Long) As Long
    Sub SetMarginTypeN(margin As Long, marginType As Long)
    Sub MarkerAddSet(line As Long, sets As Long)
    Sub MarkerDefinePixmap(markerNumber As Long, pixmap As String)
    Function MarkerPrevious(lineStart As Long, markerMask As Long) As Long
    Function MarkerNext(lineStart As Long, markerMask As Long) As Long
    Function MarkerGet(line As Long) As Long
    Sub MarkerDeleteAll(markerNumber As Long)
    Sub MarkerDelete(line As Long, markerNumber As Long)
    Function MarkerAdd(line As Long, markerNumber As Long) As Long
    Sub MarkerSetBack(markerNumber As Long, back As Long)
    Sub MarkerSetFore(markerNumber As Long, fore As Long)
    Sub MarkerDefine(markerNumber As Long, markerSymbol As Long)
    Sub SetUsePalette(usePalette As Boolean)
    Sub SetCodePage(codePage As Long)
    Function GetTabWidth() As Long
    Sub SetTabWidth(TabWidth As Long)
    Sub SetBufferedDraw(buffered As Boolean)
    Function GetBufferedDraw() As Boolean
    Sub SetStyling(length As Long, Style As Long)
    Sub StartStyling(pos As Long, mask As Long)
    Sub SetEOLMode(EOLMode As Long)
    Function GetEOLMode() As Long
    Sub ConvertEOLs(EOLMode As Long)
    Function GetCurLine(length As Long, Text As String) As Long
    Sub SetAnchor(posAnchor As Long)
    Sub GotoPos(pos As Long)
    Sub GotoLine(line As Long)
    Sub SetViewWS(viewWS As Long)
    Function GetViewWS() As Long
    Function GetUndoCollection() As Boolean
    Sub MarkerDeleteHandle(handle As Long)
    Function MarkerLineFromHandle(handle As Long) As Long
    Function CanRedo() As Boolean
    Function GetStyledText() As Long
    Sub SetSavePoint()
    Sub SelectAll()
    Sub SetUndoCollection(collectUndo As Boolean)
    Sub Redo()
    Function GetStyleAt(pos As Long) As Long
    Function GetCharAt(pos As Long) As Long
    Function GetLength() As Long
    Sub ClearDocumentStyle()
    Sub ClearAll()
    Sub InsertText(pos As Long, Text As String)
    Sub AddStyledText(length As Long)
    Sub SetSelText(strVal As String)
    Function CharAtPos(Position As Long) As Long
    Function GetCurPos() As Long
    Sub AddText(length As Long, Text As String)
    Function SendEditor(ByVal Msg As Long, Optional ByVal wParam As Long = 0, Optional ByVal lParam = 0) As Long
    Attached Files Attached Files
    Last edited by dz32; Jul 4th, 2018 at 12:34 PM.

  2. #2
    Join Date
    Jun 2015

    Re: Scintilla Source Code editor OCX for VB

    In case anyone is wondering, this is the editing component used in NotePad++.

  3. #3
    Hyperactive Member
    Join Date
    Aug 2016

    Re: Scintilla Source Code editor OCX for VB

    It is very good to use

  4. #4
    Junior Member
    Join Date
    Oct 2017

    Re: Scintilla Source Code editor OCX for VB


    This looks amazing! I am playing a little with it and works really nice

    I am just struggling a little to find out how to set a different lexer than the javaScript one. In particular I am trying to set up a VBScript lexer. Can this be done with a simple command (SetLexer, ...) or you have to set it up?

    If you have any little tuto or link to find this out it will be really appreciated!

    Thanks a lot!!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2015

    Re: Scintilla Source Code editor OCX for VB

    So far I have primarily only used it with Javascript so set that as the default.
    I do have a project where I set it to use the vb highlighter here:


    You can grab the VB.bin file from the /dependancies folder and set it with something like

    scivb.LoadHighlighter App.path & "\dependancies\vb.bin"

    I am working on a project now where I want to use the asm lexer but have been having some
    problems myself actually. This is one of the areas of the codebase I have not researched in depth yet.

    From what I gather the syntax highlighting is governed by two things, the lexer and the highlighter file.

    the lexer is written in C and compiled into the scintinilla dll. This contains the language's syntax rules
    like what defines a comment or how quoted strings are handled.


    In my repo I have the following lexers compiled in to keep my C dll smallish.

    #define SCLEX_CPP 3
    #define SCLEX_HTML 4
    #define SCLEX_XML 5
    #define SCLEX_SQL 7
    #define SCLEX_VB 8
    #define SCLEX_Asasm 9
    #define SCLEX_ASM 34
    #define SCLEX_CPPNOCASE 35
    #define SCLEX_PHPSCRIPT 69
    the binary highlighter file contains details on which fonts, colors, sizes, keywords etc.
    The language ID field in the highlighter file sets the lexer from the #define constant above.

    Stewarts original scivb.ocx had an interface for modifying these highlighter files built into it. When I went
    through the ocx I stripped it out and moved it over into its own standalone project so it would be easier to
    debug and to make the scivb ocx smaller. You can find the standalone highlight file editor here:


    Name:  screenshot.jpg
Views: 293
Size:  71.7 KB

    More highlighter bin files are available in the following zip in the /highlighters folder


    It contains html, sql, cpp, lua, pascal, vb, java, ruby,python,xml,nsis. The cedit zip from
    psc looks to additionally contain perl, blitz, and asp.

    I will attach here for backup.

    I know scintinilla itself is solid in its syntax highlight routines because many many projects use it successfully, however I personally have not had much luck modifying the highlighter files.

    The javascript one is really all I have needed over the years. I would kinda like to get the asm
    one working for the project I am currently working on though so may spend more time with it.

    If anyone spends any time in this portion of the project it would be great to get feedback on what you found to work and insights you gained. I have no idea what each of the different fields in the hilight editor are for. I did not see a listing of entry number to meaning anywhere.

    Going back into Stewarts original scivb and ceditxp projects may also reveal more details and I could have even boogered something up a little bit when I stripped it out and moved it into its own standalone project.

    Any community help is certainly welcomed and appreciated
    Attached Files Attached Files
    Last edited by dz32; Jul 5th, 2018 at 05:33 AM.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2015

    Re: Scintilla Source Code editor OCX for VB

    in my current project looks like i am using the following to set the highlighter

    b = txtCode.LoadHighlightersDir(App.path)
    b = txtCode.LoadHighlighter(App.path & "\pcode.hilighter", True)
    b = txtCode.SetHighlighter("vb6_pcode")

  7. #7
    Junior Member
    Join Date
    Oct 2017

    Re: Scintilla Source Code editor OCX for VB

    It may be not the best place to put this comment but I just found in the net your Active Script Interface class. Once again thanks a lot dz32 for these codes.

    A little question, is there anywhere available some tutorial to build these interfaces you made to the ActiveScript and Scindilla project?

    Many many thanks again for all your codes

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2015

    Re: Scintilla Source Code editor OCX for VB


    The active script stuff I did is very old. I think olaf has a maintained version of active script access classes in his rich client library that might be a better starting point.

    I never mated the active script and Scintilla. There was a time when I was starting to work on adding debugger support for the active script interfaces but never got it quite right. you can find a copy of that on sandsprite in the CodeStuff directory named vbActiveScript_wDbg_incomplete.zip but you will have to work with modifying / recompiling IDL and then recompiling library many times. It is quite the process and complex interfaces.

    I ended up ditching active script and using the third party DukTape javascript engine. It is a small free open source engine that compiled into 1mb dll and supports a debugging protocol.

    I do not have any tutorials available, but I do have an open source ocx that marries this Scintilla control to the DukTape javascript engine with full debugger support of breakpoints, stepping, mouse over variable values and basic access to VB form/class/COM objects. The object access is a little tricky in that you have to generate custom javascript wrappers for them, but there is a generator app to help.

    The javascript IDE for duktape is a pretty simple ocx where you just drag and drop it into your form and all the heavy lifting is already done. A video demo of it is in the first post. The source code is here:


    The ocx source is in the sub folder vb_examples/full_ocx

    Hope that helps.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jun 2015

    Re: Scintilla Source Code editor OCX for VB

    I also have a copy of this mated to the ms script control which is the active script interfaces.

    This project is kinda big but Form2.frm might help. It also contains some rudimentary features like
    extracting functions from the code editor window into a basic navigator, dynamic hilighting of variables,
    code formatting, and intellisense for objects added to the script control. Also has a series of tools for dealing with obsfuscated javascript but you probably dont need any of those.


    A simpler project would be the original ida jscript. The exe is standalone to examine but it was designed to script IDA disassembler over IPC so that part wont work unless you have ida but the script UI will be fine to just run and test behaviors.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width