delphi - TVirtualStringTree highlight of searching result -


i highlight text node of virtualstringtree according search criteria example bellow:

enter image description here

any suggestion please?

thanks tlama answer (how underline or highlight part of node caption) adjust bit code in order highlight text in middle.

procedure tform_main.vt_maindrawtext(sender: tbasevirtualtree;   targetcanvas: tcanvas; node: pvirtualnode; column: tcolumnindex;   const text: string; const cellrect: trect; var defaultdraw: boolean); var   backmode, position: integer; begin   // if rendered node's text contain text written in tedit control   // called edit, then...   position:= pos(ansilowercase(edit_search.text), ansilowercase(text));   if position > 0   begin     // store current background mode; need use windows api here because     // vt internally uses (so tcanvas object gets out of sync dc)     backmode := getbkmode(targetcanvas.handle);     // setup color , draw rectangle in width of matching text     targetcanvas.brush.color := clyellow;     targetcanvas.fillrect(rect(       cellrect.left + targetcanvas.textwidth(copy(text, 1, position-1)),       cellrect.top + 3,       cellrect.left  + targetcanvas.textwidth(copy(text, 1, position-1)) + targetcanvas.textwidth(copy(text, position, length(edit_search.text))),       cellrect.bottom - 3)     );     // restore original background mode (as modified setting     // brush color)     setbkmode(targetcanvas.handle, backmode);   end; end; 

best wishes tlama!


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -