Kirjautuminen

Haku

Tehtävät

Keskustelu: Koodit: VB6: Scintilla, monipuolinen tekstilaatikko

Sivun loppuun

Merri [08.07.2006 14:45:01]

#

Scintilla on monipuolinen tekstilaatikko, joka mahdollistaa mm. koodin värjäyksen, klikattavien sanojen teon sekä Unicoden käytön. Käytännössä siis erittäin hyödyllinen komponentti monenlaisiin ohjelmiin.

Tämä koodiesimerkki on keskeneräinen user control, jossa on pari perusominaisuutta kunnossa. Lisää voi rakentaa omien tarpeiden mukaisesti, esim. lähteä kustomoimaan laatikkoa vaikka chattikäyttöön tai vaihtoehtoisesti tekstieditoria varten.

Tarvitset SciLexer.dll-nimisen tiedoston. Tämän löytää lataamalla Sciten:
http://scintilla.sourceforge.net/SciTEDownload.html
Sijoita tiedosto projektihakemiston juureen.

Scintillan dokumentaatio löytyy osoitteesta http://scintilla.sourceforge.net/ScintillaDoc.html

Koodin käyttö

Aloita uusi user control ja laita sen nimeksi vaikka Scintilla. Joitakin kontrollin asetuksia täytyy ehkä säätää, mutta en pitänyt aikanaan kirjaa niistä muutoksista, joten en tähän osaa tarkkoja säätöjä kertoa; ne vaikuttavat kuitenkin lähinnä vain pieniin yksityiskohtiin.

Koodin pasteamisen jälkeen lisää kontrolli testiksi lomakkeeseen, sen pitäisi ilmestyä siihen nätisti näkyville. Ominaisuuksien muuttamisen vaikutukset pitäisi näkyä saman tien.

Jotta kaiken voisi toteuttaa, pitäisi user control subclassata, koska se vastaanottaa kaikki Scintillan lähettämät komennot, kuten tietoa käyttäjän toimista.

Koodi

Option Explicit

Public Enum SCINTILLA_CODEPAGE
    sciCP_UTF8 = 65001
    sciWinCP_Japanese_ShiftJIS = 932
    sciWinCP_Simplified_Chinese_GBK = 936
    sciWinCP_Korean_Unified_Hangul = 949
    sciWinCP_Traditional_Chinese_BIG5 = 950
    sciWinCP_Korean_Johab = 1361
    sciGTKCP_Japanese_EUC = 1
End Enum

Public Enum SCINTILLA_WORDWRAP
    sciWordWrapNone = 0
    sciWordWrapNormal = 1
    sciWordWrapSimple = 2
End Enum

Private Const WS_CHILD = &H40000000
Private Const WS_VISIBLE = &H10000000

Private Const INVALID_POSITION = -1
Private Const SCI_START = 2000
Private Const SCI_OPTIONAL_START = 3000
Private Const SCI_LEXER_START = 4000
Private Const SCI_ADDTEXT = 2001
Private Const SCI_ADDSTYLEDTEXT = 2002
Private Const SCI_INSERTTEXT = 2003
Private Const SCI_CLEARALL = 2004
Private Const SCI_CLEARDOCUMENTSTYLE = 2005
Private Const SCI_GETLENGTH = 2006
Private Const SCI_GETCHARAT = 2007
Private Const SCI_GETCURRENTPOS = 2008
Private Const SCI_GETANCHOR = 2009
Private Const SCI_GETSTYLEAT = 2010
Private Const SCI_REDO = 2011
Private Const SCI_SETUNDOCOLLECTION = 2012
Private Const SCI_SELECTALL = 2013
Private Const SCI_SETSAVEPOINT = 2014
Private Const SCI_GETSTYLEDTEXT = 2015
Private Const SCI_CANREDO = 2016
Private Const SCI_MARKERLINEFROMHANDLE = 2017
Private Const SCI_MARKERDELETEHANDLE = 2018
Private Const SCI_GETUNDOCOLLECTION = 2019
Private Const SCWS_INVISIBLE = 0
Private Const SCWS_VISIBLEALWAYS = 1
Private Const SCWS_VISIBLEAFTERINDENT = 2
Private Const SCI_GETVIEWWS = 2020
Private Const SCI_SETVIEWWS = 2021
Private Const SCI_POSITIONFROMPOINT = 2022
Private Const SCI_POSITIONFROMPOINTCLOSE = 2023
Private Const SCI_GOTOLINE = 2024
Private Const SCI_GOTOPOS = 2025
Private Const SCI_SETANCHOR = 2026
Private Const SCI_GETCURLINE = 2027
Private Const SCI_GETENDSTYLED = 2028
Private Const SC_EOL_CRLF = 0
Private Const SC_EOL_CR = 1
Private Const SC_EOL_LF = 2
Private Const SCI_CONVERTEOLS = 2029
Private Const SCI_GETEOLMODE = 2030
Private Const SCI_SETEOLMODE = 2031
Private Const SCI_STARTSTYLING = 2032
Private Const SCI_SETSTYLING = 2033
Private Const SCI_GETBUFFEREDDRAW = 2034
Private Const SCI_SETBUFFEREDDRAW = 2035
Private Const SCI_SETTABWIDTH = 2036
Private Const SCI_GETTABWIDTH = 2121
Private Const SC_CP_UTF8 = 65001
Private Const SC_CP_DBCS = 1
Private Const SCI_SETCODEPAGE = 2037
Private Const SCI_SETUSEPALETTE = 2039
Private Const MARKER_MAX = 31
Private Const SC_MARK_CIRCLE = 0
Private Const SC_MARK_ROUNDRECT = 1
Private Const SC_MARK_ARROW = 2
Private Const SC_MARK_SMALLRECT = 3
Private Const SC_MARK_SHORTARROW = 4
Private Const SC_MARK_EMPTY = 5
Private Const SC_MARK_ARROWDOWN = 6
Private Const SC_MARK_MINUS = 7
Private Const SC_MARK_PLUS = 8
Private Const SC_MARK_VLINE = 9
Private Const SC_MARK_LCORNER = 10
Private Const SC_MARK_TCORNER = 11
Private Const SC_MARK_BOXPLUS = 12
Private Const SC_MARK_BOXPLUSCONNECTED = 13
Private Const SC_MARK_BOXMINUS = 14
Private Const SC_MARK_BOXMINUSCONNECTED = 15
Private Const SC_MARK_LCORNERCURVE = 16
Private Const SC_MARK_TCORNERCURVE = 17
Private Const SC_MARK_CIRCLEPLUS = 18
Private Const SC_MARK_CIRCLEPLUSCONNECTED = 19
Private Const SC_MARK_CIRCLEMINUS = 20
Private Const SC_MARK_CIRCLEMINUSCONNECTED = 21
Private Const SC_MARK_BACKGROUND = 22
Private Const SC_MARK_DOTDOTDOT = 23
Private Const SC_MARK_ARROWS = 24
Private Const SC_MARK_PIXMAP = 25
Private Const SC_MARK_FULLRECT = 26
Private Const SC_MARK_CHARACTER = 10000
Private Const SC_MARKNUM_FOLDEREND = 25
Private Const SC_MARKNUM_FOLDEROPENMID = 26
Private Const SC_MARKNUM_FOLDERMIDTAIL = 27
Private Const SC_MARKNUM_FOLDERTAIL = 28
Private Const SC_MARKNUM_FOLDERSUB = 29
Private Const SC_MARKNUM_FOLDER = 30
Private Const SC_MARKNUM_FOLDEROPEN = 31
Private Const SC_MASK_FOLDERS = &HFE000000
Private Const SCI_MARKERDEFINE = 2040
Private Const SCI_MARKERSETFORE = 2041
Private Const SCI_MARKERSETBACK = 2042
Private Const SCI_MARKERADD = 2043
Private Const SCI_MARKERDELETE = 2044
Private Const SCI_MARKERDELETEALL = 2045
Private Const SCI_MARKERGET = 2046
Private Const SCI_MARKERNEXT = 2047
Private Const SCI_MARKERPREVIOUS = 2048
Private Const SCI_MARKERDEFINEPIXMAP = 2049
Private Const SC_MARGIN_SYMBOL = 0
Private Const SC_MARGIN_NUMBER = 1
Private Const SCI_SETMARGINTYPEN = 2240
Private Const SCI_GETMARGINTYPEN = 2241
Private Const SCI_SETMARGINWIDTHN = 2242
Private Const SCI_GETMARGINWIDTHN = 2243
Private Const SCI_SETMARGINMASKN = 2244
Private Const SCI_GETMARGINMASKN = 2245
Private Const SCI_SETMARGINSENSITIVEN = 2246
Private Const SCI_GETMARGINSENSITIVEN = 2247
Private Const STYLE_DEFAULT = 32
Private Const STYLE_LINENUMBER = 33
Private Const STYLE_BRACELIGHT = 34
Private Const STYLE_BRACEBAD = 35
Private Const STYLE_CONTROLCHAR = 36
Private Const STYLE_INDENTGUIDE = 37
Private Const STYLE_LASTPREDEFINED = 39
Private Const STYLE_MAX = 127
Private Const SC_CHARSET_ANSI = 0
Private Const SC_CHARSET_DEFAULT = 1
Private Const SC_CHARSET_BALTIC = 186
Private Const SC_CHARSET_CHINESEBIG5 = 136
Private Const SC_CHARSET_EASTEUROPE = 238
Private Const SC_CHARSET_GB2312 = 134
Private Const SC_CHARSET_GREEK = 161
Private Const SC_CHARSET_HANGUL = 129
Private Const SC_CHARSET_MAC = 77
Private Const SC_CHARSET_OEM = 255
Private Const SC_CHARSET_RUSSIAN = 204
Private Const SC_CHARSET_CYRILLIC = 1251
Private Const SC_CHARSET_SHIFTJIS = 128
Private Const SC_CHARSET_SYMBOL = 2
Private Const SC_CHARSET_TURKISH = 162
Private Const SC_CHARSET_JOHAB = 130
Private Const SC_CHARSET_HEBREW = 177
Private Const SC_CHARSET_ARABIC = 178
Private Const SC_CHARSET_VIETNAMESE = 163
Private Const SC_CHARSET_THAI = 222
Private Const SC_CHARSET_8859_15 = 1000
Private Const SCI_STYLECLEARALL = 2050
Private Const SCI_STYLESETFORE = 2051
Private Const SCI_STYLESETBACK = 2052
Private Const SCI_STYLESETBOLD = 2053
Private Const SCI_STYLESETITALIC = 2054
Private Const SCI_STYLESETSIZE = 2055
Private Const SCI_STYLESETFONT = 2056
Private Const SCI_STYLESETEOLFILLED = 2057
Private Const SCI_STYLERESETDEFAULT = 2058
Private Const SCI_STYLESETUNDERLINE = 2059
Private Const SC_CASE_MIXED = 0
Private Const SC_CASE_UPPER = 1
Private Const SC_CASE_LOWER = 2
Private Const SCI_STYLESETCASE = 2060
Private Const SCI_STYLESETCHARACTERSET = 2066
Private Const SCI_STYLESETHOTSPOT = 2409
Private Const SCI_SETSELFORE = 2067
Private Const SCI_SETSELBACK = 2068
Private Const SCI_SETCARETFORE = 2069
Private Const SCI_ASSIGNCMDKEY = 2070
Private Const SCI_CLEARCMDKEY = 2071
Private Const SCI_CLEARALLCMDKEYS = 2072
Private Const SCI_SETSTYLINGEX = 2073
Private Const SCI_STYLESETVISIBLE = 2074
Private Const SCI_GETCARETPERIOD = 2075
Private Const SCI_SETCARETPERIOD = 2076
Private Const SCI_SETWORDCHARS = 2077
Private Const SCI_BEGINUNDOACTION = 2078
Private Const SCI_ENDUNDOACTION = 2079
Private Const INDIC_MAX = 7
Private Const INDIC_PLAIN = 0
Private Const INDIC_SQUIGGLE = 1
Private Const INDIC_TT = 2
Private Const INDIC_DIAGONAL = 3
Private Const INDIC_STRIKE = 4
Private Const INDIC_HIDDEN = 5
Private Const INDIC_BOX = 6
Private Const INDIC0_MASK = &H20
Private Const INDIC1_MASK = &H40
Private Const INDIC2_MASK = &H80
Private Const INDICS_MASK = &HE0
Private Const SCI_INDICSETSTYLE = 2080
Private Const SCI_INDICGETSTYLE = 2081
Private Const SCI_INDICSETFORE = 2082
Private Const SCI_INDICGETFORE = 2083
Private Const SCI_SETWHITESPACEFORE = 2084
Private Const SCI_SETWHITESPACEBACK = 2085
Private Const SCI_SETSTYLEBITS = 2090
Private Const SCI_GETSTYLEBITS = 2091
Private Const SCI_SETLINESTATE = 2092
Private Const SCI_GETLINESTATE = 2093
Private Const SCI_GETMAXLINESTATE = 2094
Private Const SCI_GETCARETLINEVISIBLE = 2095
Private Const SCI_SETCARETLINEVISIBLE = 2096
Private Const SCI_GETCARETLINEBACK = 2097
Private Const SCI_SETCARETLINEBACK = 2098
Private Const SCI_STYLESETCHANGEABLE = 2099
Private Const SCI_AUTOCSHOW = 2100
Private Const SCI_AUTOCCANCEL = 2101
Private Const SCI_AUTOCACTIVE = 2102
Private Const SCI_AUTOCPOSSTART = 2103
Private Const SCI_AUTOCCOMPLETE = 2104
Private Const SCI_AUTOCSTOPS = 2105
Private Const SCI_AUTOCSETSEPARATOR = 2106
Private Const SCI_AUTOCGETSEPARATOR = 2107
Private Const SCI_AUTOCSELECT = 2108
Private Const SCI_AUTOCSETCANCELATSTART = 2110
Private Const SCI_AUTOCGETCANCELATSTART = 2111
Private Const SCI_AUTOCSETFILLUPS = 2112
Private Const SCI_AUTOCSETCHOOSESINGLE = 2113
Private Const SCI_AUTOCGETCHOOSESINGLE = 2114
Private Const SCI_AUTOCSETIGNORECASE = 2115
Private Const SCI_AUTOCGETIGNORECASE = 2116
Private Const SCI_USERLISTSHOW = 2117
Private Const SCI_AUTOCSETAUTOHIDE = 2118
Private Const SCI_AUTOCGETAUTOHIDE = 2119
Private Const SCI_AUTOCSETDROPRESTOFWORD = 2270
Private Const SCI_AUTOCGETDROPRESTOFWORD = 2271
Private Const SCI_REGISTERIMAGE = 2405
Private Const SCI_CLEARREGISTEREDIMAGES = 2408
Private Const SCI_AUTOCGETTYPESEPARATOR = 2285
Private Const SCI_AUTOCSETTYPESEPARATOR = 2286
Private Const SCI_AUTOCSETMAXWIDTH = 2208
Private Const SCI_AUTOCGETMAXWIDTH = 2209
Private Const SCI_AUTOCSETMAXHEIGHT = 2210
Private Const SCI_AUTOCGETMAXHEIGHT = 2211
Private Const SCI_SETINDENT = 2122
Private Const SCI_GETINDENT = 2123
Private Const SCI_SETUSETABS = 2124
Private Const SCI_GETUSETABS = 2125
Private Const SCI_SETLINEINDENTATION = 2126
Private Const SCI_GETLINEINDENTATION = 2127
Private Const SCI_GETLINEINDENTPOSITION = 2128
Private Const SCI_GETCOLUMN = 2129
Private Const SCI_SETHSCROLLBAR = 2130
Private Const SCI_GETHSCROLLBAR = 2131
Private Const SCI_SETINDENTATIONGUIDES = 2132
Private Const SCI_GETINDENTATIONGUIDES = 2133
Private Const SCI_SETHIGHLIGHTGUIDE = 2134
Private Const SCI_GETHIGHLIGHTGUIDE = 2135
Private Const SCI_GETLINEENDPOSITION = 2136
Private Const SCI_GETCODEPAGE = 2137
Private Const SCI_GETCARETFORE = 2138
Private Const SCI_GETUSEPALETTE = 2139
Private Const SCI_GETREADONLY = 2140
Private Const SCI_SETCURRENTPOS = 2141
Private Const SCI_SETSELECTIONSTART = 2142
Private Const SCI_GETSELECTIONSTART = 2143
Private Const SCI_SETSELECTIONEND = 2144
Private Const SCI_GETSELECTIONEND = 2145
Private Const SCI_SETPRINTMAGNIFICATION = 2146
Private Const SCI_GETPRINTMAGNIFICATION = 2147
Private Const SC_PRINT_NORMAL = 0
Private Const SC_PRINT_INVERTLIGHT = 1
Private Const SC_PRINT_BLACKONWHITE = 2
Private Const SC_PRINT_COLOURONWHITE = 3
Private Const SC_PRINT_COLOURONWHITEDEFAULTBG = 4
Private Const SCI_SETPRINTCOLOURMODE = 2148
Private Const SCI_GETPRINTCOLOURMODE = 2149
Private Const SCFIND_WHOLEWORD = 2
Private Const SCFIND_MATCHCASE = 4
Private Const SCFIND_WORDSTART = &H100000
Private Const SCFIND_REGEXP = &H200000
Private Const SCFIND_POSIX = &H400000
Private Const SCI_FINDTEXT = 2150
Private Const SCI_FORMATRANGE = 2151
Private Const SCI_GETFIRSTVISIBLELINE = 2152
Private Const SCI_GETLINE = 2153
Private Const SCI_GETLINECOUNT = 2154
Private Const SCI_SETMARGINLEFT = 2155
Private Const SCI_GETMARGINLEFT = 2156
Private Const SCI_SETMARGINRIGHT = 2157
Private Const SCI_GETMARGINRIGHT = 2158
Private Const SCI_GETMODIFY = 2159
Private Const SCI_SETSEL = 2160
Private Const SCI_GETSELTEXT = 2161
Private Const SCI_GETTEXTRANGE = 2162
Private Const SCI_HIDESELECTION = 2163
Private Const SCI_POINTXFROMPOSITION = 2164
Private Const SCI_POINTYFROMPOSITION = 2165
Private Const SCI_LINEFROMPOSITION = 2166
Private Const SCI_POSITIONFROMLINE = 2167
Private Const SCI_LINESCROLL = 2168
Private Const SCI_SCROLLCARET = 2169
Private Const SCI_REPLACESEL = 2170
Private Const SCI_SETREADONLY = 2171
Private Const SCI_NULL = 2172
Private Const SCI_CANPASTE = 2173
Private Const SCI_CANUNDO = 2174
Private Const SCI_EMPTYUNDOBUFFER = 2175
Private Const SCI_UNDO = 2176
Private Const SCI_CUT = 2177
Private Const SCI_COPY = 2178
Private Const SCI_PASTE = 2179
Private Const SCI_CLEAR = 2180
Private Const SCI_SETTEXT = 2181
Private Const SCI_GETTEXT = 2182
Private Const SCI_GETTEXTLENGTH = 2183
Private Const SCI_GETDIRECTFUNCTION = 2184
Private Const SCI_GETDIRECTPOINTER = 2185
Private Const SCI_SETOVERTYPE = 2186
Private Const SCI_GETOVERTYPE = 2187
Private Const SCI_SETCARETWIDTH = 2188
Private Const SCI_GETCARETWIDTH = 2189
Private Const SCI_SETTARGETSTART = 2190
Private Const SCI_GETTARGETSTART = 2191
Private Const SCI_SETTARGETEND = 2192
Private Const SCI_GETTARGETEND = 2193
Private Const SCI_REPLACETARGET = 2194
Private Const SCI_REPLACETARGETRE = 2195
Private Const SCI_SEARCHINTARGET = 2197
Private Const SCI_SETSEARCHFLAGS = 2198
Private Const SCI_GETSEARCHFLAGS = 2199
Private Const SCI_CALLTIPSHOW = 2200
Private Const SCI_CALLTIPCANCEL = 2201
Private Const SCI_CALLTIPACTIVE = 2202
Private Const SCI_CALLTIPPOSSTART = 2203
Private Const SCI_CALLTIPSETHLT = 2204
Private Const SCI_CALLTIPSETBACK = 2205
Private Const SCI_CALLTIPSETFORE = 2206
Private Const SCI_CALLTIPSETFOREHLT = 2207
Private Const SCI_VISIBLEFROMDOCLINE = 2220
Private Const SCI_DOCLINEFROMVISIBLE = 2221
Private Const SCI_WRAPCOUNT = 2235
Private Const SC_FOLDLEVELBASE = &H400
Private Const SC_FOLDLEVELWHITEFLAG = &H1000
Private Const SC_FOLDLEVELHEADERFLAG = &H2000
Private Const SC_FOLDLEVELBOXHEADERFLAG = &H4000
Private Const SC_FOLDLEVELBOXFOOTERFLAG = &H8000
Private Const SC_FOLDLEVELCONTRACTED = &H10000
Private Const SC_FOLDLEVELUNINDENT = &H20000
Private Const SC_FOLDLEVELNUMBERMASK = &HFFF
Private Const SCI_SETFOLDLEVEL = 2222
Private Const SCI_GETFOLDLEVEL = 2223
Private Const SCI_GETLASTCHILD = 2224
Private Const SCI_GETFOLDPARENT = 2225
Private Const SCI_SHOWLINES = 2226
Private Const SCI_HIDELINES = 2227
Private Const SCI_GETLINEVISIBLE = 2228
Private Const SCI_SETFOLDEXPANDED = 2229
Private Const SCI_GETFOLDEXPANDED = 2230
Private Const SCI_TOGGLEFOLD = 2231
Private Const SCI_ENSUREVISIBLE = 2232
Private Const SC_FOLDFLAG_LINEBEFORE_EXPANDED = &H2
Private Const SC_FOLDFLAG_LINEBEFORE_CONTRACTED = &H4
Private Const SC_FOLDFLAG_LINEAFTER_EXPANDED = &H8
Private Const SC_FOLDFLAG_LINEAFTER_CONTRACTED = &H10
Private Const SC_FOLDFLAG_LEVELNUMBERS = &H40
Private Const SC_FOLDFLAG_BOX = &H1
Private Const SCI_SETFOLDFLAGS = 2233
Private Const SCI_ENSUREVISIBLEENFORCEPOLICY = 2234
Private Const SCI_SETTABINDENTS = 2260
Private Const SCI_GETTABINDENTS = 2261
Private Const SCI_SETBACKSPACEUNINDENTS = 2262
Private Const SCI_GETBACKSPACEUNINDENTS = 2263
Private Const SC_TIME_FOREVER = 10000000
Private Const SCI_SETMOUSEDWELLTIME = 2264
Private Const SCI_GETMOUSEDWELLTIME = 2265
Private Const SCI_WORDSTARTPOSITION = 2266
Private Const SCI_WORDENDPOSITION = 2267
Private Const SC_WRAP_NONE = 0
Private Const SC_WRAP_WORD = 1
Private Const SC_WRAP_CHAR = 2
Private Const SCI_SETWRAPMODE = 2268
Private Const SCI_GETWRAPMODE = 2269
Private Const SC_WRAPVISUALFLAG_NONE = &H0
Private Const SC_WRAPVISUALFLAG_END = &H1
Private Const SC_WRAPVISUALFLAG_START = &H2
Private Const SCI_SETWRAPVISUALFLAGS = 2460
Private Const SCI_GETWRAPVISUALFLAGS = 2461
Private Const SC_WRAPVISUALFLAGLOC_DEFAULT = &H0
Private Const SC_WRAPVISUALFLAGLOC_END_BY_TEXT = &H1
Private Const SC_WRAPVISUALFLAGLOC_START_BY_TEXT = &H2
Private Const SCI_SETWRAPVISUALFLAGSLOCATION = 2462
Private Const SCI_GETWRAPVISUALFLAGSLOCATION = 2463
Private Const SCI_SETWRAPSTARTINDENT = 2464
Private Const SCI_GETWRAPSTARTINDENT = 2465
Private Const SC_CACHE_NONE = 0
Private Const SC_CACHE_CARET = 1
Private Const SC_CACHE_PAGE = 2
Private Const SC_CACHE_DOCUMENT = 3
Private Const SCI_SETLAYOUTCACHE = 2272
Private Const SCI_GETLAYOUTCACHE = 2273
Private Const SCI_SETSCROLLWIDTH = 2274
Private Const SCI_GETSCROLLWIDTH = 2275
Private Const SCI_TEXTWIDTH = 2276
Private Const SCI_SETENDATLASTLINE = 2277
Private Const SCI_GETENDATLASTLINE = 2278
Private Const SCI_TEXTHEIGHT = 2279
Private Const SCI_SETVSCROLLBAR = 2280
Private Const SCI_GETVSCROLLBAR = 2281
Private Const SCI_APPENDTEXT = 2282
Private Const SCI_GETTWOPHASEDRAW = 2283
Private Const SCI_SETTWOPHASEDRAW = 2284
Private Const SCI_TARGETFROMSELECTION = 2287
Private Const SCI_LINESJOIN = 2288
Private Const SCI_LINESSPLIT = 2289
Private Const SCI_SETFOLDMARGINCOLOUR = 2290
Private Const SCI_SETFOLDMARGINHICOLOUR = 2291
Private Const SCI_LINEDOWN = 2300
Private Const SCI_LINEDOWNEXTEND = 2301
Private Const SCI_LINEUP = 2302
Private Const SCI_LINEUPEXTEND = 2303
Private Const SCI_CHARLEFT = 2304
Private Const SCI_CHARLEFTEXTEND = 2305
Private Const SCI_CHARRIGHT = 2306
Private Const SCI_CHARRIGHTEXTEND = 2307
Private Const SCI_WORDLEFT = 2308
Private Const SCI_WORDLEFTEXTEND = 2309
Private Const SCI_WORDRIGHT = 2310
Private Const SCI_WORDRIGHTEXTEND = 2311
Private Const SCI_HOME = 2312
Private Const SCI_HOMEEXTEND = 2313
Private Const SCI_LINEEND = 2314
Private Const SCI_LINEENDEXTEND = 2315
Private Const SCI_DOCUMENTSTART = 2316
Private Const SCI_DOCUMENTSTARTEXTEND = 2317
Private Const SCI_DOCUMENTEND = 2318
Private Const SCI_DOCUMENTENDEXTEND = 2319
Private Const SCI_PAGEUP = 2320
Private Const SCI_PAGEUPEXTEND = 2321
Private Const SCI_PAGEDOWN = 2322
Private Const SCI_PAGEDOWNEXTEND = 2323
Private Const SCI_EDITTOGGLEOVERTYPE = 2324
Private Const SCI_CANCEL = 2325
Private Const SCI_DELETEBACK = 2326
Private Const SCI_TAB = 2327
Private Const SCI_BACKTAB = 2328
Private Const SCI_NEWLINE = 2329
Private Const SCI_FORMFEED = 2330
Private Const SCI_VCHOME = 2331
Private Const SCI_VCHOMEEXTEND = 2332
Private Const SCI_ZOOMIN = 2333
Private Const SCI_ZOOMOUT = 2334
Private Const SCI_DELWORDLEFT = 2335
Private Const SCI_DELWORDRIGHT = 2336
Private Const SCI_LINECUT = 2337
Private Const SCI_LINEDELETE = 2338
Private Const SCI_LINETRANSPOSE = 2339
Private Const SCI_LINEDUPLICATE = 2404
Private Const SCI_LOWERCASE = 2340
Private Const SCI_UPPERCASE = 2341
Private Const SCI_LINESCROLLDOWN = 2342
Private Const SCI_LINESCROLLUP = 2343
Private Const SCI_DELETEBACKNOTLINE = 2344
Private Const SCI_HOMEDISPLAY = 2345
Private Const SCI_HOMEDISPLAYEXTEND = 2346
Private Const SCI_LINEENDDISPLAY = 2347
Private Const SCI_LINEENDDISPLAYEXTEND = 2348
Private Const SCI_HOMEWRAP = 2349
Private Const SCI_HOMEWRAPEXTEND = 2450
Private Const SCI_LINEENDWRAP = 2451
Private Const SCI_LINEENDWRAPEXTEND = 2452
Private Const SCI_VCHOMEWRAP = 2453
Private Const SCI_VCHOMEWRAPEXTEND = 2454
Private Const SCI_LINECOPY = 2455
Private Const SCI_MOVECARETINSIDEVIEW = 2401
Private Const SCI_LINELENGTH = 2350
Private Const SCI_BRACEHIGHLIGHT = 2351
Private Const SCI_BRACEBADLIGHT = 2352
Private Const SCI_BRACEMATCH = 2353
Private Const SCI_GETVIEWEOL = 2355
Private Const SCI_SETVIEWEOL = 2356
Private Const SCI_GETDOCPOINTER = 2357
Private Const SCI_SETDOCPOINTER = 2358
Private Const SCI_SETMODEVENTMASK = 2359
Private Const EDGE_NONE = 0
Private Const EDGE_LINE = 1
Private Const EDGE_BACKGROUND = 2
Private Const SCI_GETEDGECOLUMN = 2360
Private Const SCI_SETEDGECOLUMN = 2361
Private Const SCI_GETEDGEMODE = 2362
Private Const SCI_SETEDGEMODE = 2363
Private Const SCI_GETEDGECOLOUR = 2364
Private Const SCI_SETEDGECOLOUR = 2365
Private Const SCI_SEARCHANCHOR = 2366
Private Const SCI_SEARCHNEXT = 2367
Private Const SCI_SEARCHPREV = 2368
Private Const SCI_LINESONSCREEN = 2370
Private Const SCI_USEPOPUP = 2371
Private Const SCI_SELECTIONISRECTANGLE = 2372
Private Const SCI_SETZOOM = 2373
Private Const SCI_GETZOOM = 2374
Private Const SCI_CREATEDOCUMENT = 2375
Private Const SCI_ADDREFDOCUMENT = 2376
Private Const SCI_RELEASEDOCUMENT = 2377
Private Const SCI_GETMODEVENTMASK = 2378
Private Const SCI_SETFOCUS = 2380
Private Const SCI_GETFOCUS = 2381
Private Const SCI_SETSTATUS = 2382
Private Const SCI_GETSTATUS = 2383
Private Const SCI_SETMOUSEDOWNCAPTURES = 2384
Private Const SCI_GETMOUSEDOWNCAPTURES = 2385
Private Const SC_CURSORNORMAL = -1
Private Const SC_CURSORWAIT = 4
Private Const SCI_SETCURSOR = 2386
Private Const SCI_GETCURSOR = 2387
Private Const SCI_SETCONTROLCHARSYMBOL = 2388
Private Const SCI_GETCONTROLCHARSYMBOL = 2389
Private Const SCI_WORDPARTLEFT = 2390
Private Const SCI_WORDPARTLEFTEXTEND = 2391
Private Const SCI_WORDPARTRIGHT = 2392
Private Const SCI_WORDPARTRIGHTEXTEND = 2393
Private Const VISIBLE_SLOP = &H1
Private Const VISIBLE_STRICT = &H4
Private Const SCI_SETVISIBLEPOLICY = 2394
Private Const SCI_DELLINELEFT = 2395
Private Const SCI_DELLINERIGHT = 2396
Private Const SCI_SETXOFFSET = 2397
Private Const SCI_GETXOFFSET = 2398
Private Const SCI_CHOOSECARETX = 2399
Private Const SCI_GRABFOCUS = 2400
Private Const CARET_SLOP = &H1
Private Const CARET_STRICT = &H4
Private Const CARET_JUMPS = &H10
Private Const CARET_EVEN = &H8
Private Const SCI_SETXCARETPOLICY = 2402
Private Const SCI_SETYCARETPOLICY = 2403
Private Const SCI_SETPRINTWRAPMODE = 2406
Private Const SCI_GETPRINTWRAPMODE = 2407
Private Const SCI_SETHOTSPOTACTIVEFORE = 2410
Private Const SCI_SETHOTSPOTACTIVEBACK = 2411
Private Const SCI_SETHOTSPOTACTIVEUNDERLINE = 2412
Private Const SCI_SETHOTSPOTSINGLELINE = 2421
Private Const SCI_PARADOWN = 2413
Private Const SCI_PARADOWNEXTEND = 2414
Private Const SCI_PARAUP = 2415
Private Const SCI_PARAUPEXTEND = 2416
Private Const SCI_POSITIONBEFORE = 2417
Private Const SCI_POSITIONAFTER = 2418
Private Const SCI_COPYRANGE = 2419
Private Const SCI_COPYTEXT = 2420
Private Const SC_SEL_STREAM = 0
Private Const SC_SEL_RECTANGLE = 1
Private Const SC_SEL_LINES = 2
Private Const SCI_SETSELECTIONMODE = 2422
Private Const SCI_GETSELECTIONMODE = 2423
Private Const SCI_GETLINESELSTARTPOSITION = 2424
Private Const SCI_GETLINESELENDPOSITION = 2425
Private Const SCI_LINEDOWNRECTEXTEND = 2426
Private Const SCI_LINEUPRECTEXTEND = 2427
Private Const SCI_CHARLEFTRECTEXTEND = 2428
Private Const SCI_CHARRIGHTRECTEXTEND = 2429
Private Const SCI_HOMERECTEXTEND = 2430
Private Const SCI_VCHOMERECTEXTEND = 2431
Private Const SCI_LINEENDRECTEXTEND = 2432
Private Const SCI_PAGEUPRECTEXTEND = 2433
Private Const SCI_PAGEDOWNRECTEXTEND = 2434
Private Const SCI_STUTTEREDPAGEUP = 2435
Private Const SCI_STUTTEREDPAGEUPEXTEND = 2436
Private Const SCI_STUTTEREDPAGEDOWN = 2437
Private Const SCI_STUTTEREDPAGEDOWNEXTEND = 2438
Private Const SCI_WORDLEFTEND = 2439
Private Const SCI_WORDLEFTENDEXTEND = 2440
Private Const SCI_WORDRIGHTEND = 2441
Private Const SCI_WORDRIGHTENDEXTEND = 2442
Private Const SCI_SETWHITESPACECHARS = 2443
Private Const SCI_SETCHARSDEFAULT = 2444
Private Const SCI_AUTOCGETCURRENT = 2445
Private Const SCI_ALLOCATE = 2446
Private Const SCI_TARGETASUTF8 = 2447
Private Const SCI_SETLENGTHFORENCODE = 2448
Private Const SCI_ENCODEDFROMUTF8 = 2449
Private Const SCI_FINDCOLUMN = 2456
Private Const SCI_GETCARETSTICKY = 2457
Private Const SCI_SETCARETSTICKY = 2458
Private Const SCI_TOGGLECARETSTICKY = 2459
Private Const SCI_STARTRECORD = 3001
Private Const SCI_STOPRECORD = 3002
Private Const SCI_SETLEXER = 4001
Private Const SCI_GETLEXER = 4002
Private Const SCI_COLOURISE = 4003
Private Const SCI_SETPROPERTY = 4004
Private Const KEYWORDSET_MAX = 8
Private Const SCI_SETKEYWORDS = 4005
Private Const SCI_SETLEXERLANGUAGE = 4006
Private Const SCI_LOADLEXERLIBRARY = 4007
Private Const SCI_GETPROPERTY = 4008
Private Const SCI_GETPROPERTYEXPANDED = 4009
Private Const SCI_GETPROPERTYINT = 4010
Private Const SC_MOD_INSERTTEXT = &H1
Private Const SC_MOD_DELETETEXT = &H2
Private Const SC_MOD_CHANGESTYLE = &H4
Private Const SC_MOD_CHANGEFOLD = &H8
Private Const SC_PERFORMED_USER = &H10
Private Const SC_PERFORMED_UNDO = &H20
Private Const SC_PERFORMED_REDO = &H40
Private Const SC_MULTISTEPUNDOREDO = &H80
Private Const SC_LASTSTEPINUNDOREDO = &H100
Private Const SC_MOD_CHANGEMARKER = &H200
Private Const SC_MOD_BEFOREINSERT = &H400
Private Const SC_MOD_BEFOREDELETE = &H800
Private Const SC_MULTILINEUNDOREDO = &H1000
Private Const SC_MODEVENTMASKALL = &H1FFF
Private Const SCEN_CHANGE = 768
Private Const SCEN_SETFOCUS = 512
Private Const SCEN_KILLFOCUS = 256
Private Const SCK_DOWN = 300
Private Const SCK_UP = 301
Private Const SCK_LEFT = 302
Private Const SCK_RIGHT = 303
Private Const SCK_HOME = 304
Private Const SCK_END = 305
Private Const SCK_PRIOR = 306
Private Const SCK_NEXT = 307
Private Const SCK_DELETE = 308
Private Const SCK_INSERT = 309
Private Const SCK_ESCAPE = 7
Private Const SCK_BACK = 8
Private Const SCK_TAB = 9
Private Const SCK_RETURN = 13
Private Const SCK_ADD = 310
Private Const SCK_SUBTRACT = 311
Private Const SCK_DIVIDE = 312
Private Const SCMOD_SHIFT = 1
Private Const SCMOD_CTRL = 2
Private Const SCMOD_ALT = 4
Private Const SCN_STYLENEEDED = 2000
Private Const SCN_CHARADDED = 2001
Private Const SCN_SAVEPOINTREACHED = 2002
Private Const SCN_SAVEPOINTLEFT = 2003
Private Const SCN_MODIFYATTEMPTRO = 2004
Private Const SCN_KEY = 2005
Private Const SCN_DOUBLECLICK = 2006
Private Const SCN_UPDATEUI = 2007
Private Const SCN_MODIFIED = 2008
Private Const SCN_MACRORECORD = 2009
Private Const SCN_MARGINCLICK = 2010
Private Const SCN_NEEDSHOWN = 2011
Private Const SCN_PAINTED = 2013
Private Const SCN_USERLISTSELECTION = 2014
Private Const SCN_URIDROPPED = 2015
Private Const SCN_DWELLSTART = 2016
Private Const SCN_DWELLEND = 2017
Private Const SCN_ZOOM = 2018
Private Const SCN_HOTSPOTCLICK = 2019
Private Const SCN_HOTSPOTDOUBLECLICK = 2020
Private Const SCN_CALLTIPCLICK = 2021
Private Const SCN_AUTOCSELECTION = 2022

Private Const SCI_DLLNAME As String = "SciLexer.DLL"

Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
Private Declare Function SendMessageString Lib "user32" Alias "SendMessageW" (ByVal hwnd As Long, ByVal Msg As Long, ByVal wp As Long, ByVal lp As Any) As Long
Private Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal m As Long, ByVal Left As Long, ByVal Top As Long, ByVal Width As Long, ByVal Height As Long, ByVal Flags As Long) As Long

Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryW" (ByVal lpLibFileName As String) As Long

Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, lpUsedDefaultChar As Long) As Long

Dim m_Text As String

Dim s_Handle As Long
Dim s_hWnd As Long

Dim m_Codepage As SCINTILLA_CODEPAGE
Dim m_WordWrap As SCINTILLA_WORDWRAP

Public Property Get CodePage() As SCINTILLA_CODEPAGE
    CodePage = m_Codepage
End Property
Public Property Let CodePage(ByVal NewValue As SCINTILLA_CODEPAGE)
    m_Codepage = NewValue
    SendMessage s_hWnd, SCI_SETCODEPAGE, m_Codepage, 0&
    PropertyChanged "CodePage"
End Property
Public Property Get Font() As StdFont
    Set Font = UserControl.Font
End Property
Public Property Set Font(ByRef NewValue As StdFont)
    Set UserControl.Font = NewValue
    SendMessageString s_hWnd, SCI_STYLESETFONT, STYLE_DEFAULT, UserControl.Font.Name
    SendMessage s_hWnd, SCI_STYLESETSIZE, STYLE_DEFAULT, CLng(UserControl.Font.Size)
    SendMessage s_hWnd, SCI_STYLESETBOLD, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Bold))
    SendMessage s_hWnd, SCI_STYLESETITALIC, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Italic))
    SendMessage s_hWnd, SCI_STYLESETUNDERLINE, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Underline))
    PropertyChanged "Font"
End Property
Private Function InDebug(ByRef blnResult As Boolean) As Boolean
    blnResult = True
End Function
' you can use this to detect if you are under IDE
Private Function InIDE() As Boolean
    Debug.Assert True Xor InDebug(InIDE)
End Function
' KAFPE = Kill the Annoying Floating Point Error
Private Sub KAFPE()
    If Not InIDE Then Exit Sub
    On Error Resume Next: Debug.Assert CLng(0.1): On Error GoTo 0
End Sub
Public Property Get ScrollWidth() As Long
    ScrollWidth = SendMessage(s_hWnd, SCI_GETSCROLLWIDTH, 0&, 0&)
End Property
Public Property Let ScrollWidth(ByVal NewValue As Long)
    SendMessage s_hWnd, SCI_SETSCROLLWIDTH, NewValue, 0&
    PropertyChanged "ScrollWidth"
End Property
Public Property Get Text() As String
    Static barTemp() As Byte, barOut() As Byte
    Dim lngTemp As Long
    lngTemp = SendMessage(s_hWnd, SCI_GETTEXTLENGTH, 0&, 0&)
    If lngTemp > 0 Then
        ReDim Preserve barTemp(lngTemp)
        barTemp(lngTemp) = 0
        SendMessage s_hWnd, SCI_GETTEXT, lngTemp + 1, VarPtr(barTemp(0))
        ReDim Preserve barOut(lngTemp * 4 - 1)
        lngTemp = MultiByteToWideChar(CLng(m_Codepage), 0&, ByVal VarPtr(barTemp(0)), lngTemp, ByVal VarPtr(barOut(0)), lngTemp * 4)
        If lngTemp > 0 Then
            ReDim Preserve barOut(lngTemp * 2 - 1)
            m_Text = barOut
        Else
            m_Text = vbNullString
        End If
    Else
        m_Text = vbNullString
    End If
    Text = m_Text
End Property
Public Property Let Text(ByRef NewValue As String)
    Static barOut() As Byte
    Dim lngTemp As Long
    If (Not barOut) = -1& Then ReDim Preserve barOut(0)
    KAFPE
    If LenB(NewValue) > 0 Then
        If UBound(barOut) < LenB(NewValue) * 2 - 1 Then ReDim Preserve barOut(LenB(NewValue) * 2 - 1)
        lngTemp = WideCharToMultiByte(CLng(m_Codepage), 0&, ByVal StrPtr(NewValue), Len(NewValue), ByVal VarPtr(barOut(0)), UBound(barOut) + 1, ByVal 0&, ByVal 0&)
        barOut(lngTemp) = 0
    End If
    SendMessage s_hWnd, SCI_SETTEXT, lngTemp, VarPtr(barOut(0))
    PropertyChanged "Text"
End Property
Public Property Get WordWrap() As SCINTILLA_WORDWRAP
    WordWrap = m_WordWrap
End Property
Public Property Let WordWrap(ByVal NewValue As SCINTILLA_WORDWRAP)
    m_WordWrap = NewValue
    SendMessage s_hWnd, SCI_SETWRAPMODE, m_WordWrap, 0&
    PropertyChanged "WordWrap"
End Property
Private Sub UserControl_GotFocus()
    If s_hWnd <> 0 Then SetFocus s_hWnd
End Sub
Private Sub UserControl_Initialize()
    ' set correct scalemode
    UserControl.ScaleMode = vbPixels
    ' load scintilla
    s_Handle = LoadLibrary(StrConv(SCI_DLLNAME, vbUnicode))
    If s_Handle = 0 Then s_Handle = LoadLibrary(StrConv(App.Path & "\" & SCI_DLLNAME, vbUnicode))
    If s_Handle <> 0 Then s_hWnd = CreateWindowEx(0&, "Scintilla", "TEST", WS_CHILD Or WS_VISIBLE, 0&, 0&, UserControl.ScaleWidth, UserControl.ScaleHeight, UserControl.hwnd, 0&, App.hInstance, 0&)
    ' set default settings
    m_Codepage = sciCP_UTF8
    m_WordWrap = sciWordWrapNormal
    ' remove margins
    SendMessage s_hWnd, SCI_SETMARGINWIDTHN, 0&, 0&
    SendMessage s_hWnd, SCI_SETMARGINWIDTHN, 1&, 0&
    SendMessage s_hWnd, SCI_SETMARGINWIDTHN, 2&, 0&
    SendMessage s_hWnd, SCI_SETMARGINWIDTHN, 3&, 0&
    SendMessage s_hWnd, SCI_SETMARGINWIDTHN, 4&, 0&
    ' set Unicode support
    SendMessage s_hWnd, SCI_SETCODEPAGE, m_Codepage, 0&
    ' set word wrapping
    SendMessage s_hWnd, SCI_SETWRAPMODE, m_WordWrap, 0&
    ' set highlight colors
    SendMessage s_hWnd, SCI_SETSELBACK, 1, GetSysColor(vbHighlight And Not &H80000000)
    SendMessage s_hWnd, SCI_SETSELFORE, 1, GetSysColor(vbHighlightText And Not &H80000000)
End Sub
Private Sub UserControl_InitProperties()
    If s_hWnd = 0 Then Exit Sub

    SendMessageString s_hWnd, SCI_STYLESETFONT, STYLE_DEFAULT, UserControl.Font.Name
    SendMessage s_hWnd, SCI_STYLESETSIZE, STYLE_DEFAULT, CLng(UserControl.Font.Size)
    SendMessage s_hWnd, SCI_STYLESETBOLD, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Bold))
    SendMessage s_hWnd, SCI_STYLESETITALIC, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Italic))
    SendMessage s_hWnd, SCI_STYLESETUNDERLINE, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Underline))
End Sub
Private Sub UserControl_Paint()
    If s_hWnd <> 0 Then Exit Sub
    ' show a message we failed to load Scintilla
    UserControl.Cls
    UserControl.CurrentX = 2
    UserControl.CurrentY = 2
    Print SCI_DLLNAME & " is missing!"
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    If s_hWnd = 0 Then Exit Sub

    ' codepage
    m_Codepage = PropBag.ReadProperty("Codepage", sciCP_UTF8)
    SendMessage s_hWnd, SCI_SETCODEPAGE, m_Codepage, 0&

    ' font
    Set UserControl.Font = PropBag.ReadProperty("Font", UserControl.Font)
    SendMessageString s_hWnd, SCI_STYLESETFONT, STYLE_DEFAULT, UserControl.Font.Name
    SendMessage s_hWnd, SCI_STYLESETSIZE, STYLE_DEFAULT, CLng(UserControl.Font.Size)
    SendMessage s_hWnd, SCI_STYLESETBOLD, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Bold))
    SendMessage s_hWnd, SCI_STYLESETITALIC, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Italic))
    SendMessage s_hWnd, SCI_STYLESETUNDERLINE, STYLE_DEFAULT, CLng(Abs(UserControl.Font.Underline))

    ' scrollwidth
    SendMessage s_hWnd, SCI_SETSCROLLWIDTH, CLng(PropBag.ReadProperty("ScrollWidth", 2000)), 0&

    ' text
    m_Text = PropBag.ReadProperty("Text", vbNullString)
    If LenB(m_Text) > 0 Then SendMessage s_hWnd, SCI_SETTEXT, Len(m_Text), StrPtr(StrConv(m_Text, vbFromUnicode))

    ' wordwrap
    m_WordWrap = PropBag.ReadProperty("WordWrap", sciWordWrapNormal)
    SendMessage s_hWnd, SCI_SETWRAPMODE, m_WordWrap, 0&
End Sub
Private Sub UserControl_Resize()
    If s_hWnd = 0 Then Exit Sub
    SetWindowPos s_hWnd, 0&, 0&, 0&, UserControl.ScaleWidth, UserControl.ScaleHeight, 0&
End Sub
Private Sub UserControl_Terminate()
    ' clear memory
    If s_hWnd <> 0 Then
        ' remove Scintilla
        DestroyWindow s_hWnd
        FreeLibrary s_Handle
    End If
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Dim lngTemp As Long, barTemp() As Byte

    PropBag.WriteProperty "Codepage", m_Codepage, sciCP_UTF8
    PropBag.WriteProperty "Font", UserControl.Font
    PropBag.WriteProperty "ScrollWidth", SendMessage(s_hWnd, SCI_GETSCROLLWIDTH, 0&, 0&)

    ' text
    lngTemp = SendMessage(s_hWnd, SCI_GETTEXTLENGTH, 0&, 0&)
    If lngTemp > -1 Then
        ReDim barTemp(lngTemp)
        SendMessage s_hWnd, SCI_GETTEXT, lngTemp + 1, VarPtr(barTemp(0))
        m_Text = StrConv(barTemp, vbUnicode)
    Else
        m_Text = vbNullString
    End If
    PropBag.WriteProperty "Text", m_Text, vbNullString

    PropBag.WriteProperty "WordWrap", m_WordWrap, sciWordWrapNormal
End Sub

Basic 6.0 [09.07.2006 12:07:26]

#

No johan on pitkä!

Jorgga [09.07.2006 16:27:53]

#

lainaus:

No johan on pitkä!

Kyllä koodia riittää :D

Merri [10.07.2006 11:42:08]

#

Te ette ilmeisesti ole pitkää nähneetkään! :)

Olennaisen koodin osuus on aika vähäinen, koska noita constant-arvoja on niin paljon. Niiden kaikkien vaan on pakko olla tuolla, ettei niitä tarvitse alkaa aina erikseen lisäilemään tarpeen mukaan kun käyttöä löytyy.

Puhveli [11.07.2006 12:36:55]

#

Vakiot ovat turhia. Kyllä tosimies muistaa nuo parituhatta arvoa ulkoa. Mutta aika monipuoliselta härpäkkeeltä tuo vaikuttaa :o.

tgunner [16.07.2006 01:06:42]

#

Yh tätä VB-koodia, aina niin jännittävää katsella. :)
Ihan hieno loppujenlopuksi, mutta tuo alussa oleva lista vakioista on hirvittävä.

[EDIT]Ai niin! Kommentteja saisi olla enemmän.[/EDIT]

Merri [16.07.2006 08:56:50]

#

Kommentit ovat jääneet vähille ihan sen takia, että suurin osa ajasta meni Scintillan toiminnan ymmärtämiseen, joten rivien kommentointi oli "turhaa" kun rivit kuitenkin muuttuivat varsin vilkkaasti. Nyt kun tuo toimii täysin, niin kommentit olisivat toki paikallaan.

moptim [04.08.2006 11:35:09]

#

ja mites tää koodi sit värjätään?

Merri [06.08.2006 03:28:46]

#

SendMessagella lisäät tekstiä käyttäen komentoa SCI_ADDSTYLEDTEXT - jokaisen merkin jälkeen täytyy sitten tulla tyylitavu, josta viisi alinta bittiä on varattu tyyliluvulle ja kolme ylempää bittiä on vielä semmoisia, joiden merkitystä en ole selvittänyt itselleni. Erilaisia tyylejä voi kuitenkin olla yhteensä 128, joten näiden bittien merkitystä voi selvästikin säätää erillisellä komennolla (tyylit 32-39 on oletuksena erikoistehtäviin varattuja; 32 on oletustyyli).

Jotta tyyleinumeron vaihtamisella on jotain merkitystä, täytyy tyylejä toki muutella käyttäen SCI_STYLESET* komentoja. Eli hommaa riittää säätämisessä, mutta jos alkuun pääsee niin eiköhän noista selviä.

Dokumentaatio vielä kertauksena:
http://scintilla.sourceforge.net/ScintillaDoc.html


Sivun alkuun

Vastaus

Aihe on jo aika vanha, joten et voi enää vastata siihen.

Tietoa sivustosta