Raj
2003-08-27 09:23:46 UTC
hi,
I am trying to insert an image in HTML page when the user clicks my
toolbar button at the place where currently cursor is.
It does insert it but after inserting the image, the cursor
is not coming up.
I need to have the cusror come up next to the image. So that I can
type some text.
this is the piece of code i am using:
CComPtr<IHTMLDocument2> spDoc;
/////
////some more code for getting spDoc
//////
//Here is the code for inserting image
POINT point;
GetCaretPos(&point);
CComBSTR cmd = _T("InsertImage");
spDoc->execCommand(cmd, FALSE,CComVariant(myImage) ,0);
CComPtr<IHTMLSelectionObject> selectObj;
spDoc->get_selection(&selectObj);
if (selectObj)
{
selectObj->empty();
CComPtr<IDispatch> iDispRange;
selectObj->createRange(&iDispRange);
CComQIPtr<IHTMLTxtRange> range(iDispRange);
if (range)
{
range->select();
range->collapse(false);
}
}
///////////////////////////////////////
What happens is cursor always comes at the start of the document.
Can nayone tell me how can I get that done ?
Regards
Raj
I am trying to insert an image in HTML page when the user clicks my
toolbar button at the place where currently cursor is.
It does insert it but after inserting the image, the cursor
is not coming up.
I need to have the cusror come up next to the image. So that I can
type some text.
this is the piece of code i am using:
CComPtr<IHTMLDocument2> spDoc;
/////
////some more code for getting spDoc
//////
//Here is the code for inserting image
POINT point;
GetCaretPos(&point);
CComBSTR cmd = _T("InsertImage");
spDoc->execCommand(cmd, FALSE,CComVariant(myImage) ,0);
CComPtr<IHTMLSelectionObject> selectObj;
spDoc->get_selection(&selectObj);
if (selectObj)
{
selectObj->empty();
CComPtr<IDispatch> iDispRange;
selectObj->createRange(&iDispRange);
CComQIPtr<IHTMLTxtRange> range(iDispRange);
if (range)
{
range->select();
range->collapse(false);
}
}
///////////////////////////////////////
What happens is cursor always comes at the start of the document.
Can nayone tell me how can I get that done ?
Regards
Raj