tags:

views:

342

answers:

2

I saw this picture and now wondering if/how you can do this in Delphi. The highlighted/selected text shows two forms of formatting, i.e. highlight color and hash lines.

+1  A: 

I've done something very similar recently in a bible application, also done in Delphi.

The user can select a single verse and single words of the selected verses. (But this feature is not released yet, so don't bother looking for it)

I used the web browser control from Microsoft and added my own kind of selection handling.

I've done the formatting by enclosing the relevant parts with span elements and changing their CSS style. When the selection gets removed, I also remove the enclosing elements.

The hard part was backing the "visual" selections with a selection data structure and handling all the selection events (clicking, shift-clicking, shift-ctrl-clicking, ...)

DR
A: 

Embedding IE seems to be an easier way to do this as DR says, but you can also do this manually by drawing it all on a canvas, an easy way would be to create two bitmaps (one without a selection and another selected (could be as complicated as you like - dashed, colored, ... )), and you need to know the positions/rects of all your characters which would be somewhat difficult for long texts.

You basically show the unselected bitmap, and overlap the selected parts by portions of the second image.

You would also need to handle the selection manually by OnMouseDown, OnMouseMove, OnMouseUp...

Osama ALASSIRY