Projects > MasmBasic & the RichMasm IDE

Uncle Tom, the RichEdit control's little helper


Our buggy friend, the RichEdit control, has lots of more or less useful messages. And it has a second option for communicating with you: the Text Object Model alias TOM.

Now, if you think "that smells suspiciously of COM", you are absolutely right. For example, a proc that inserts a string into a given range might look like this (actually a workaround for the infamous EM_EXSETSEL bug):

--- Code: ---_TomRepSel proc uses esi edi pChrg, _Insert$ ; ptr to CHARRANGE, string to insert
  call TomInit ; load ITextDocument interface into edi
  mov ecx, pChrg
  mov eax, [ecx.CHARRANGE.cpMax]
  push eax ; cpMax
  push eax ; cpMin=cpMax for EXSETSEL below
  CoInvoke pInterface, ITextDocument.Range, [ecx.CHARRANGE.cpMin], eax, addr ReTom.mbtRange
  lea edi, ReTom.mbtRange
  CoInvoke pInterface, ITextRange.SetFormattedText, ReTom.mbtRange ; set the range to formatted (otherwise shortcuts fail)
  CoInvoke pInterface, ITextRange.SetText, Ole$(_Insert$)
  invoke SendMessage, _hRE, EM_EXSETSEL, 0, esp ; no bug for end of selection
  pop edx
  pop ecx
_TomRepSel endp
--- End code ---

That looks evil indeed, and it needs the latest MasmBasic version. For the time being, I have used TOM only to get and set text (see attachment), but it looks promising. There are a wealth of new functions to study (and some crispy new bugs, pardon: features).

\Masm32\MasmBasic\ has implemented the most important interfaces; look below MbTOM. I'll continue playing if I find the time, and maybe keep you posted ;-)


[0] Message Index

Go to full version