Scintilla in VB6


Author: Dave
Date: 02.20.14 - 2:02am



Scintilla is a very powerful (and stable) code editing component that supports syntax highlighting, code folding, tool tips and intellisense. Its packaged as a standard dll. Back in 2006 Stu Collier and Stewart released a nice ActiveX control named SCIVB.OCX that makes Scintilla directly usable for VB6 users.

This OCX is giant and complex. The DirectSci class alone is 70k+ lines of code! Also its a non-visual component making it a little more complex to use out of the box. They wrote a lot of code, and had to do a bunch of research into the internals of Scintilla. I have spent about 50hrs in the ocx codebase now and still only have a top level overview of it.

I found the control a couple years ago, and was a heavy end user of it while writing and using PDFStreamDumper. There were a couple nuances of the control that I always wanted to tweak, but never had the time to dive into the project. These last couple weekends I finally found that time and was able to really get into it. It also appears that the authors ceditmx.com website is no longer available, and the SourceForge page is so broken I had to download from a mirror. A Planet Source Code submission of what looks like a slightly older version is also still up. It would be a shame for all this hard work to disappear from the net, so I am including a copy of the original along with this project.

Below is a list of my edits, some rather extensive. I will start with notable bug fixes:
  • Window Handle Not Subclassed In IDE - I would constantly receive a modal Msgbox with this message when working in the IDE. It could pop 3 times right in a row. It may have been because I further wrapped the ocx controls in my own usercontrol. I disabled the message at the source, but after finding what was causing it, it turns out I could have preempted it in the IDE by adding the following to my UserControl_Initilize code: App.StartLogging Empty, vbLogOff . I will leave it disabled at the source because App.logevent causing a MsgBox as default logMode is obscure to me.

  • copy/paste support - the hot keys were unmapped, but they seem to have been buggy anyway. Previously I had to implement these functions myself in KeyPress event code, which was also buggy because Paste seemed to be called twice in a row. I had to track system time to not repeat in a given interval which was annoying. This appears to have been caused by the subclass being hooked into both before and after the original wndProc handler, hence causing the double event to fire.

  • arrow keys sporadically quite - This was a weird bug, I think it was caused by VB6 not knowing there was a manually created control on the user control canvas. It only happened sporadically but was super annoying for code navigation. I think the fix for this was UserControl.ForwardEvents = true. I havent seen it since, but that was super hard to find and I tried loads of stuff before then. Not even subclassing helped.

  • switched to visual component - Previously scivb was two components. A highlighter and a editor, both non visual. You had to drop both on a form and use them together. I have combined them into one visual component so you can just drag and drop it on a form like a normal control. Previously I always included my own usercontrol to wrap the ocx controls for simplicity of use.

  • simplified interface - the editor user control had tons of methods and properties. This increased the learning curve for the control and gave you more to sift through every time you used it. In this build I have removed a great deal of the ones I did not see myself using regularly. Most of these were also readily accessible through the DirectSCI class, Ones that required intimate knowledge of Scintilla internals were moved to a misc helper class. I also removed a bunch of events I didnt see myself using, renamed some functions for clarity, and included procedure attribute descriptions that will show up in the object browser for others.

  • lightened code base - The scivb authors didnt want to have any external ocx dependencies other than scilexer.dll which is smart. The internal options dialog however was pretty heavy with 3rd party user controls and had some other forms built in. I removed all of these from this build and trimmed off 400k in compiled size. I did create an external editor for the syntax files though.

Anyway, I think it is where I want it now so figured I would do a quick blog post on it. I did tentatively set binary compatibility on the component i am calling scivb_lite.ocx . Thanks again to the original authors for their hard work and research!

My modifications, as well as a zip of the original are available in the github repository.

https://github.com/dzzie/scivb_lite







Comments: (0)

 
Leave Comment:
Name:
Email: (not shown)
Message: (Required)
Math Question: 94 + 5 = ? followed by the letter: X 



About Me
More Blogs
Main Site
Posts: (year)
2024 (1)
     RegJump Vb
2023 (9)
     VB6 Virtual Files
     File handles across dlls
     python abort / script timeout
     py4vb
     VB6 Python embed w/debugger
     python embedding
     VB6 IDE Enhancements
     No Sleep
     A2W no ATL
2022 (4)
     More VB6 - C data passing
     Vb6 Asm listing
     Byte Array C to VB6
     Planet Source Code DVDs
2021 (2)
     Obscure VB
     VB6 IDE SP6
2020 (4)
     NTFileSize
     BSTR from C Dll to VB
     Cpp Memory Manipulation
     ActiveX Binary Compatability
2019 (5)
     Console tricks
     FireFox temp dir
     OCX License
     Extract substring
     VB6 Console Apps
2018 (6)
     VB6 UDTs
     VB6 Debugger View As Hex tooltips
     VB6 - C Share registry data
     VB6 Addin Missing Menus
     VB6 Class Init Params
     VB6 isIn function
2017 (6)
     Python and VB6
     Python pros and cons
     download web Dir
     vc rand in python
     VB6 Language Enhancement
     Register .NET as COM
2016 (22)
     VB6 CDECL
     UDT Tricks pt2
     Remote Data Extraction
     Collection Extender
     VB6 FindResource
     CDO.Message
     DirList Single Click
     Reset CheckPoint VPN Policy
     VB6 BSTR Oddities Explained
     SafeArrays in C
     BSTR and Variant in C++
     Property let optional args
     Misc Libs
     Enum Named Pipes
     Vb6 Collection in C++
     VB6 Overloaded Methods
     EXPORT FUNCDNAME Warning
     VB6 Syncronous Socket
     Simple IPC
     VB6 Auto Resize Form Elements
     Mach3 Automation
     Exit For in While
2015 (15)
     C# self register ocx
     VB6 Class Method Pointers
     Duktape Debug Protocol
     QtScript 4 VB
     Vb6 Named Args
     vb6 Addin Part 2
     VB6 Addin vrs Toolbars
     OpenFile Dialog MultiSelect
     Duktape Example
     DukTape JS
     VB6 Unsigned
     .Net version
     TitleBar Height
     .NET again
     VB6 Self Register OCXs
2014 (25)
     Query Last 12 Mos
     Progid from Interface ID
     VB6 to C Array Examples
     Human Readable Variant Type
     ScriptBasic COM Integration
     CodeView Addin
     ScriptBasic - Part 2
     Script Env
     MSCOMCTL Win7 Error
     printf override
     History Combo
     Disable IE
     API Hooking in VB6
     Addin Hook Events
     FastBuild Addin
     VB6 MemoryWindow
     Link C Obj Files into VB6
     Vb6 Standard Dlls
     CStr for Pascal
     Lazarus Review
     asprintf for VS
     VB6 GlobalMultiUse
     Scintilla in VB6
     Dynamic Highlight
     WinVerifyTrust, CryptMsgGetParam VB6
2013 (4)
     MS GLEE Graphing
     printf for VB6
     C# App Config
     Tero DES C# Test
2012 (10)
     VC 2008 Bit Fields
     Speed trap
     C# Db Class Generator
     VB6 vrs .NET (again)
     FireFox Whois Extension
     git and vb6
     Code Additions
     Compiled date to string
     C# ListView Sorter
     VB6 Wish List
2011 (7)
     C# Process Injection
     CAPTCHA Bots
     C# PE Offset Calculator
     VB6 Async Download
     Show Desktop
     coding philosophy
     Code release
2010 (11)
     Dll Not Found in IDE
     Advanced MSScript Control
     random tip
     Clipart / Vector Art
     VB6 Callback from C#
     Binary data from VB6 to C#
     CSharp and MsScriptControl
     HexDumper functions
     Js Beautify From VB6 or C#
     vb6 FormPos
     Inline Asm w VB6
2009 (3)
     The .NET Fiasco
     One rub on computers
     Universal extractor