Results 1 to 7 of 7

Thread: VB6 Link-Label-Widget with colored KeyWord-rendering

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,971

    VB6 Link-Label-Widget with colored KeyWord-rendering

    Since it recently came up - here an appropriate Demo with a small Widget-Class,
    which implements this (in cwLinkText.cls).

    Here is what it produces (the colored KeyWords show a "Hand-Cursor" and are clickable):
    Name:  LinkWidget.png
Views: 340
Size:  62.6 KB

    And here's the Sourcecode:
    LinkTextDemo.zip

    Have fun,

    Olaf

  2. #2
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,060

    Re: VB6 Link-Label-Widget with colored KeyWord-rendering

    Widget, cario is by gdiplus.dll Packaging out of the drawing components?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,971

    Re: VB6 Link-Label-Widget with colored KeyWord-rendering

    Quote Originally Posted by xiaoyao View Post
    Widget, cario is by gdiplus.dll Packaging out of the drawing components?
    No, all (RC6)-Cairo-Widgets work independent from gdiplus.dll.
    That's the whole point of the RC6-framework (and why it is "somewhat larger")...

    It tries to work "as MS-independent as possible" -
    (also with the relatively ADO/DAO-compatible cConnection/cRecordset Classes, which work against SQLite).

    Olaf

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,971

    Re: VB6 Link-Label-Widget with colored KeyWord-rendering

    Since it was asked in the main-forum-thread here: https://www.vbforums.com/showthread....=1#post5606648

    The "outline", how the above Demo works, is as follows - starting with the Hierarchy:

    - fTest.frm (which only "knows" and "deals with" the Widget-instances, as provided by cwLinkText.cls)
    ---- cwLinkText.cls (which only "knows" and "deals with" the Class-instance, as provided by cTextSplit.cls)
    -------- cTextSplit.cls (which works at the lowest level, and provides the basic "Word-Splitting"-Services)

    Explanation "from the bottom up" follows:

    Since we want to render a given (longer) Text-String - which might not fit onto a "single line" -
    the first thing we need, is a "word-breaking-algorithm", which takes apart the longer string "row-by-fitting-row".
    (determining, which parts of the longer text belong (after breaking at a given width), into which line-of-text ... and "how many lines will be needed").

    This workd-break-algo is called from within cTextSplit.ParseText -
    which in turn calls an already built-in Context-method: CC.CalcTextRowsInfo Text, AvailableWidth, ..., ...

    So, the first problem (word-breaking, across multiple text-rows) can be solved in a single line of code -
    which is followed by looping over the "SubStrings" for each of the "Lines of just broken Text".
    (we are still in cTextSplit.ParseText here, where this loop is defined).

    We could already "directly render" these split-up TextRow-Substrings directly onto a Cairo-CC now ...
    but since we want "colored, clickable Words" in addition, we first have to "parse for single words" (in each Row of SubText).

    And that's why the "Main-Loop over the Rows" in cTextSplit.ParseText -
    will delegate the Row-SubText into a Sub-Routine called: ParseWords sRow, i
    which further "splits a Line into Words and Non-Word-Parts" (an alternating sequence of those is contained in each TextLine).

    And it is this Sub-Word-Parsing (per Line), which will trigger several "Callbacks" and Events,
    which are in turn received from the hosting Class one level above: cwLinkText
    ... which in the end will store some of the "Word-infos" internally, to be able to Render and MouseHover over "colored Words" correctly.

    Edit: ...forgot to mention, how the Dictionaries in cwTextLink come into play
    (after all that "row-parsing/breaking and word-splitting")...

    In short, the via Event incoming "single Words" can be compared very fast (in a case-insensitive manner),
    via Dictionary.Exists-checks (where these Words were added priorily as "Keys" along with their associated Color-Value).
    Their presence in the Dictionary will make them "Key-Words" in the truest sense - and the rendering-algo (triggered from W_Paint) will react to them properly.

    The Form-Code which is then making use of our two cwLinkText-instances does not need much explanation, I guess.
    (it's similar enough to, how VB-Controls are handled, in case someone creates them dynamically via Controls.Add)

    Olaf
    Last edited by Schmidt; May 24th, 2023 at 07:55 AM.

  5. #5
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    566

    Re: VB6 Link-Label-Widget with colored KeyWord-rendering

    it is really magic and powerful.
    When the form resize to minimum, "Monster" & ChrW(160) & "Girl" lost Red color. Is it normal?

    Can those dlls including RC6.dll etc. being used in C++ ATL? If so, can you make few example?
    Attached Images Attached Images  

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jun 2013
    Posts
    6,971

    Re: VB6 Link-Label-Widget with colored KeyWord-rendering

    Quote Originally Posted by DaveDavis View Post
    it is really magic and powerful.
    When the form resize to minimum, "Monster" & ChrW(160) & "Girl" lost Red color. Is it normal?

    Can those dlls including RC6.dll etc. being used in C++ ATL? If so, can you make few example?
    Have just tried that (in an ATL-project with VisualStudio 2022) -
    and whilst the integrated COMponent-Viewer (the ObjectCatalog) is able to list all RC6-classes just fine...
    an import-statement like: #import "c:\Code\RC6\RC6.dll" no_namespace

    ...will fail, due to problems, translating the typelib-infos into proper *.tlh and *.tli files.
    (partly due to coming in a "legacy typelib-format" - and partly due to missing "sub-typelibs",
    which should be "ignored" (like the ObjectCatalog-tree-listing demonstrates nicely).

    So, if you really want to use it in C++, you'll have to use "old style defines" (involving ClsID and InterfaceIDs) -
    writing dedicated wrappers for the Classes you want to use from it...

    Not a task I'd like to tackle... - using it (from within C++) in "LateBound-mode" via IDispatch-Invoke is probably a bit easier -
    but then you could always go "the other way" - and use the C++ compiler to "contribute fast companion-dlls" -
    which are then used (along with the RC6) directly from VB6/VBA or TwinBasic.

    Olaf

  7. #7
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    566

    Re: VB6 Link-Label-Widget with colored KeyWord-rendering

    Quote Originally Posted by Schmidt View Post
    Have just tried that (in an ATL-project with VisualStudio 2022) -
    and whilst the integrated COMponent-Viewer (the ObjectCatalog) is able to list all RC6-classes just fine...
    an import-statement like: #import "c:\Code\RC6\RC6.dll" no_namespace

    ...will fail, due to problems, translating the typelib-infos into proper *.tlh and *.tli files.
    (partly due to coming in a "legacy typelib-format" - and partly due to missing "sub-typelibs",
    which should be "ignored" (like the ObjectCatalog-tree-listing demonstrates nicely).

    So, if you really want to use it in C++, you'll have to use "old style defines" (involving ClsID and InterfaceIDs) -
    writing dedicated wrappers for the Classes you want to use from it...

    Not a task I'd like to tackle... - using it (from within C++) in "LateBound-mode" via IDispatch-Invoke is probably a bit easier -
    but then you could always go "the other way" - and use the C++ compiler to "contribute fast companion-dlls" -
    which are then used (along with the RC6) directly from VB6/VBA or TwinBasic.

    Olaf
    Thank you very much for this tips. I used RC6 in few VB6 projects to use one of functionalities of SortedDictionary, now I am on the way to convert my VB6 controls to ATL, after I finish the ATL control, I will try RC6 in my new control.

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