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
}
//---------------------------------------------------------------------------