Click here to Skip to main content
15,909,373 members
Home / Discussions / COM
   

COM

 
QuestionLearning COM Pin
vipin_nvk30-Oct-07 22:54
vipin_nvk30-Oct-07 22:54 
AnswerRe: Learning COM Pin
CPallini30-Oct-07 23:12
mveCPallini30-Oct-07 23:12 
AnswerRe: Learning COM Pin
Hakan Bulut1-Nov-07 5:11
Hakan Bulut1-Nov-07 5:11 
JokeRe: Learning COM Pin
CPallini1-Nov-07 22:06
mveCPallini1-Nov-07 22:06 
GeneralRe: Learning COM Pin
Hakan Bulut1-Nov-07 23:29
Hakan Bulut1-Nov-07 23:29 
GeneralNOT competitive! Pin
CPallini1-Nov-07 23:39
mveCPallini1-Nov-07 23:39 
JokeRe: NOT competitive! [modified] Pin
Hakan Bulut2-Nov-07 8:11
Hakan Bulut2-Nov-07 8:11 
QuestionHow can I get the coordinates IHTMLLIElement at www.microsoft.com Pin
Alexxx30-Oct-07 21:18
Alexxx30-Oct-07 21:18 
Hi all.

How can I get the coordinates IHTMLLIElement (Highlights, Latest releases, Using your computer, ..) at www.microsoft.com

code:

pDoc2 - pointer to the document frame containing element
pElement - pointer at the element
Text - text links

void CExplorerWindow::GetLinkRect(CComPtr<ihtmldocument2> pDoc2, CComQIPtr<ihtmlelement,&iid_ihtmlelement> pElement, BSTR Text, LPRECT Rect)
{
long Top = 0;
long Hight = 0;
long Left = 0;
long Width = 0;

CComPtr<idispatch> pDisp = NULL;

if (pWebBrowser2)
{
pWebBrowser2->get_Document (&pDisp);
if (pDisp)
{
CComPtr<ihtmldocument2> pDoc = NULL;
pDisp->QueryInterface (IID_IHTMLDocument2, (void **) &pDoc);

if (pDoc)
{
CComPtr<ihtmlframescollection2> m_frame = NULL;
pDoc->get_frames(&m_frame);

if (m_frame)
{
long len = 0;
m_frame->get_length (&len);
if (len)
{
CComQIPtr<ihtmlelement> pEl ;
if (SUCCEEDED(pDoc2->get_body(&pEl)))
{
CComQIPtr<ihtmlbodyelement> pBodyElement ;
pBodyElement = pEl;
if (pBodyElement)
{
CComQIPtr<ihtmltxtrange> pTxtRange;
pBodyElement->createTextRange(&pTxtRange);
if (pTxtRange)
{
if (pTxtRange->moveToElementText(pElement) == S_OK)
{
VARIANT_BOOL ok;
if (pTxtRange->findText(Text,wcslen(Text),0,&ok) == S_OK)
{
CComQIPtr<ihtmltextrangemetrics2> pTextRangeMetrics2;
pTextRangeMetrics2 = pTxtRange;

CComQIPtr<ihtmlrectcollection> ptrRectColl;
CComQIPtr<ihtmlrect> ptrHTMLRect;

if (pTextRangeMetrics2->getClientRects(&ptrRectColl) == S_OK)
{
long Len;
ptrRectColl->get_length(&Len);

if (Len)
{
VARIANT VarInd, VarDisp;
VarInd.vt = VT_I4;



for(int i = 0; i < Len;i++)
{
VarInd.lVal = i;

ptrRectColl->item (&VarInd, &VarDisp);
ptrHTMLRect = VarDisp.pdispVal;

long Top = 0;
long Right = 0;
long Left = 0;
long Bottom = 0;

if (ptrHTMLRect)
{
ptrHTMLRect->get_left (&Left);
ptrHTMLRect->get_top (&Top);
ptrHTMLRect->get_right (&Right);
ptrHTMLRect->get_bottom(&Bottom);

//!!! Left, Top, Right, Bottom - 0
}

SetRect(Rect, Left, Top, Right, Bottom);

}
}
else
{
pElement->get_offsetHeight(&Hight);
pElement->get_offsetWidth(&Width);

pElement->get_offsetTop(&Top);
pElement->get_offsetLeft(&Left);
IHTMLElement* pParentElement = NULL;

while (SUCCEEDED(pElement->get_offsetParent(&pParentElement)))
{
if (!pParentElement) break;
long ParentLeft, ParentTop;
pParentElement->get_offsetTop(&ParentTop);
pParentElement->get_offsetLeft(&ParentLeft);
Top += ParentTop;
Left +=ParentLeft;
pElement = pParentElement;
pParentElement->Release();
}
}

ptrRectColl.Detach();

}
}
}

}
}
}

}
else // no frames
{

CComQIPtr<ihtmlelement2> pElement2(pElement);
CComPtr<ihtmlrect> BoundingRect;
if (pElement2)
{
if (SUCCEEDED(pElement2->getBoundingClientRect(&BoundingRect)) && BoundingRect)
{
BoundingRect->get_top(&Top);
BoundingRect->get_left(&Left);
}
else
{
Top = 0; Left = 0;
}
}
pElement->get_offsetHeight(&Hight);
pElement->get_offsetWidth(&Width);

SetRect(Rect, Left, Top, Left + Width, Top + Hight);
}
}
else //m_frame == 0
{
CComQIPtr<ihtmlelement2> pElement2(pElement);
CComPtr<ihtmlrect> BoundingRect;
if (pElement2)
{
if (SUCCEEDED(pElement2->getBoundingClientRect(&BoundingRect)) && BoundingRect)
{
BoundingRect->get_top(&Top);
BoundingRect->get_left(&Left);
}
else
{
Top = 0; Left = 0;
}
}
pElement->get_offsetHeight(&Hight);
pElement->get_offsetWidth(&Width);

SetRect(Rect, Left, Top, Left + Width, Top + Hight);
}
}

}

}


if (IsRectEmpty(Rect)) Beep(200,100); - only if pElement == Highlights, Latest releases, Using your computer, ..
}
QuestionUsing COM to extract words from a Word2003 Document Pin
ms_wtg330-Oct-07 17:54
ms_wtg330-Oct-07 17:54 
QuestionIStream object of HTTP in ActiveX Web Control Pin
Maruf Maniruzzaman30-Oct-07 17:51
Maruf Maniruzzaman30-Oct-07 17:51 
AnswerRe: IStream object of HTTP in ActiveX Web Control Pin
myshketer5-Nov-07 21:43
myshketer5-Nov-07 21:43 
QuestionGetDesktopItemCount() ofIActive desktop is returing count as '1' even if more than one are present Pin
ROBS12330-Oct-07 0:01
ROBS12330-Oct-07 0:01 
QuestionCOM+ security - IsUserInRole Pin
sthotakura30-Oct-07 0:01
sthotakura30-Oct-07 0:01 
QuestionJavaScript and BHO communication? Pin
conman11029-Oct-07 9:39
conman11029-Oct-07 9:39 
QuestionGet ProgID or CLSID if i have only pointer to some IDispatch interface Pin
IWannaTalk29-Oct-07 0:55
IWannaTalk29-Oct-07 0:55 
AnswerRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
Mike Dimmick29-Oct-07 2:36
Mike Dimmick29-Oct-07 2:36 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
IWannaTalk29-Oct-07 3:43
IWannaTalk29-Oct-07 3:43 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
CPallini29-Oct-07 5:39
mveCPallini29-Oct-07 5:39 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
User 21559729-Oct-07 6:22
User 21559729-Oct-07 6:22 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
IWannaTalk29-Oct-07 6:33
IWannaTalk29-Oct-07 6:33 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
User 21559729-Oct-07 6:47
User 21559729-Oct-07 6:47 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
IWannaTalk29-Oct-07 6:52
IWannaTalk29-Oct-07 6:52 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
User 21559729-Oct-07 7:26
User 21559729-Oct-07 7:26 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
IWannaTalk29-Oct-07 7:40
IWannaTalk29-Oct-07 7:40 
GeneralRe: Get ProgID or CLSID if i have only pointer to some IDispatch interface Pin
Nathan Holt at EMOM29-Oct-07 9:42
Nathan Holt at EMOM29-Oct-07 9:42 

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.