Click here to Skip to main content
15,918,243 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Linking error Pin
Atlantys26-Jul-03 10:32
Atlantys26-Jul-03 10:32 
GeneralGetting Selection from CHTMLEditView Pin
Matt Gates25-Jul-03 15:53
Matt Gates25-Jul-03 15:53 
GeneralRe: Getting Selection from CHTMLEditView Pin
Tom Archer25-Jul-03 16:32
Tom Archer25-Jul-03 16:32 
GeneralRe: Getting Selection from CHTMLEditView Pin
Matt Gates25-Jul-03 19:53
Matt Gates25-Jul-03 19:53 
GeneralRe: Getting Selection from CHTMLEditView Pin
Tom Archer26-Jul-03 2:33
Tom Archer26-Jul-03 2:33 
GeneralRe: Getting Selection from CHTMLEditView Pin
Tom Archer26-Jul-03 2:35
Tom Archer26-Jul-03 2:35 
GeneralRe: Getting Selection from CHTMLEditView Pin
Matt Gates26-Jul-03 15:58
Matt Gates26-Jul-03 15:58 
GeneralRe: Getting Selection from CHTMLEditView Pin
Niall Barr26-Jul-03 4:30
professionalNiall Barr26-Jul-03 4:30 
This seems to work...

//Derived from a table insert function that I can't remember the original source of.
CString CHTMLEditView::GetSelection(void)
{
	IDispatch * pDocDisp = NULL;
	IHTMLDocument2* pDoc;
	IHTMLSelectionObject* pSelObj;
	IHTMLTxtRange* pTxtRange;
	CString cstext;
	pDocDisp = GetHtmlDocument();
	HRESULT hr = pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
	if (SUCCEEDED(hr)) {
		hr = pDoc->get_selection(&pSelObj);
		CComBSTR p;
		pSelObj->get_type(&p); // Should test this is suitable "Text" or "None"
		if ((SUCCEEDED(hr))&&((p==L"Text")||(p==L"None"))) {
			hr = pSelObj->createRange((IDispatch**)&pTxtRange);
			if (SUCCEEDED(hr)) {
				BSTR text;
				pTxtRange->get_htmlText(&text);
				cstext = text;
				SysFreeString(text);
				pTxtRange->Release();
			}
			pSelObj->Release();
		}
		pDocDisp->Release();
		pDoc->Release();
	}
	return cstext;
}

To put a string back into the selection use pTxtRange->pasteHTML(text) instead of pTxtRange->get_htmlText(&text)

Niall.
Questionhow to make a groupbox's title transparent Pin
allenhu25-Jul-03 15:28
allenhu25-Jul-03 15:28 
AnswerRe: how to make a groupbox's title transparent Pin
Tom Archer25-Jul-03 17:15
Tom Archer25-Jul-03 17:15 
GeneralSymbolic Link, I think Pin
amleth25-Jul-03 15:02
amleth25-Jul-03 15:02 
GeneralRe: Symbolic Link, I think Pin
jbannon25-Jul-03 22:50
jbannon25-Jul-03 22:50 
GeneralEnabling/Disabling Menu Items Pin
Frank Deo25-Jul-03 14:41
Frank Deo25-Jul-03 14:41 
GeneralRe: Enabling/Disabling Menu Items Pin
Chris Maunder25-Jul-03 15:01
cofounderChris Maunder25-Jul-03 15:01 
GeneralRe: Enabling/Disabling Menu Items Pin
Frank Deo25-Jul-03 16:51
Frank Deo25-Jul-03 16:51 
GeneralRe: Enabling/Disabling Menu Items Pin
Toni7825-Jul-03 15:03
Toni7825-Jul-03 15:03 
GeneralRe: Enabling/Disabling Menu Items Pin
Frank Deo25-Jul-03 16:52
Frank Deo25-Jul-03 16:52 
GeneralRe: Enabling/Disabling Menu Items Pin
Toni7826-Jul-03 7:45
Toni7826-Jul-03 7:45 
GeneralGetting selected folder in a namespace extension Pin
Mike Hartway25-Jul-03 14:27
Mike Hartway25-Jul-03 14:27 
GeneralHelp Pin
Snyp25-Jul-03 13:34
Snyp25-Jul-03 13:34 
GeneralRe: Help Pin
Beer2625-Jul-03 13:42
Beer2625-Jul-03 13:42 
GeneralRe: Help Pin
Snyp25-Jul-03 13:51
Snyp25-Jul-03 13:51 
GeneralRe: Help Pin
Beer2625-Jul-03 13:53
Beer2625-Jul-03 13:53 
QuestionHow to set default view with CFileDialog Pin
plsmith25-Jul-03 12:30
plsmith25-Jul-03 12:30 
AnswerRe: How to set default view with CFileDialog Pin
Neville Franks25-Jul-03 13:21
Neville Franks25-Jul-03 13:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.