Hi,
I am subclassing the PDFViewCtrl to enable caret browsing.
I have a method that I use to set a caret.
It works perfectly for all words on the first page. I assume I need
the client coördinates for the function "SetCaretPos".
It's a User32 function native to windows. How to I get from the
canvaspt to the client coördinate system?
Code below:
private void SetCaret(TextExtractor.Word Word)
{
double x1 = caretWoord.GetBBox().x1;
double y1 = caretWoord.GetBBox().y1;
double x2 = caretWoord.GetBBox().x2;
double y2 = caretWoord.GetBBox().y2;
ConvPagePtToCanvasPt( ref x1, ref y1, pageNumber );
ConvPagePtToCanvasPt( ref x2, ref y2, pageNumber );
double zoom = GetZoom();
x1 = x1 * GetZoom();
y1 = y1 * GetZoom();
x2 = x2 * GetZoom();
y2 = y2 * GetZoom();
int caretHeight = (int)(y1 - y2);
// create the caret.
CreateCaret( this.Handle, IntPtr.Zero, 2, caretHeight );
// position caret on beginnning of the word.
SetCaretPos( (int)x1, (int)y2 );
// show the caret.
ShowCaret( this.Handle );
}
Kind regards,
Tom