Discussion:
URGENT Help with IHTMLDocument2
(too old to reply)
Raj
2003-08-27 09:23:46 UTC
Permalink
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
Raj
2003-08-28 09:52:21 UTC
Permalink
no one to help ???
where is Igor ???
How can I get the caret to appear next to the inserted image ??
please reply at ur earliest...
thanks
Raj
Post by Raj
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.
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
Loading...