Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TCppWebBrowser

10 views
Skip to first unread message

jadlaxel

unread,
Apr 17, 2008, 9:12:07 AM4/17/08
to
I am using the TCppWebBrowser to display a html page. I want the user
to be able to select text and copy it. I can select the text but I do
not know how to detect what text is selected and how to copy this text
to the clipboard. Does anyone can help me?
Thanks in advance.

zxjra...@gmail.com

unread,
May 19, 2008, 10:50:25 PM5/19/08
to
__fastcall THtmlForm::THtmlForm(TComponent* Owner)
: TForm(Owner)
{

OleInitialize(NULL);

}
//---------------------------------------------------------------------------
__fastcall THtmlForm::~THtmlForm()
{
OleUninitialize;
}
//---------------------------------------------------------------------------
void __fastcall THtmlForm::SelAsTitleBtnClick(TObject *Sender)
{
//TODO:get selected html text
IHTMLDocument2* pDocument ;
IHTMLSelectionObject *SelectObj;
IHTMLTxtRange *TextRang;
HRESULT hr ;
HWND EditFormHanle=NULL;

//Get IHTMLDocument2 interface
hr = CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2,
(void**)&pDocument) ;

if(SUCCEEDED(hr) )
{
pDocument->get_selection(&SelectObj);
pDocument->Release() ;
IDispatch* pDisp ;
wchar_t *TxtSrc;
SelectObj->createRange(&pDisp);
hr= pDisp->QueryInterface(IID_IHTMLTxtRange,
(void**)&TextRang) ;
if(SUCCEEDED(hr) )
{
TextRang->get_text(&TxtSrc);
m_SelText=AnsiString(TxtSrc).Trim();
if(m_SelText.Length()>2)
{
ShowMessage(m_SelText);
}
}//end of if
}//end of if
}
//---------------------------------------------------------------------------

0 new messages