Click here to Skip to main content
15,919,613 members
Home / Discussions / C#
   

C#

 
QuestionSQL Report Ranking Pin
jatin.sabarmati17-Nov-08 14:15
jatin.sabarmati17-Nov-08 14:15 
AnswerRe: SQL Report Ranking Pin
Christian Graus17-Nov-08 15:18
protectorChristian Graus17-Nov-08 15:18 
Questionxml Pin
arkiboys17-Nov-08 11:12
arkiboys17-Nov-08 11:12 
QuestionRe: xml Pin
nelsonpaixao17-Nov-08 12:39
nelsonpaixao17-Nov-08 12:39 
AnswerRe: xml Pin
Christian Graus17-Nov-08 14:49
protectorChristian Graus17-Nov-08 14:49 
AnswerRe: xml Pin
Brij17-Nov-08 17:13
mentorBrij17-Nov-08 17:13 
GeneralRe: xml Pin
arkiboys18-Nov-08 5:09
arkiboys18-Nov-08 5:09 
QuestionProblem with html parsing using mshtml. offsetHeight, offsetWidth, offsetLeft and offsetTop (properties of IHTMLElement interface) always return zero. Pin
Terasbetoni17-Nov-08 10:41
Terasbetoni17-Nov-08 10:41 
Hello. I want to learn positions of all elements on a page. I do so:


public class MsHtmlSharpParser {

  IHTMLDocument2 htmlDocument;
  public HtmlTreeNode htmlTree;

  public MsHtmlSharpParser() {
    htmlDocument = new HTMLDocumentClass();
  }
  public void LoadContent(string content) {
    htmlDocument.write(new object[] { content });
    htmlDocument.close();
    ((HTMLDocumentClass)htmlDocument).recalc(true);
    htmlTree = new HtmlTreeNode((IHTMLDOMNode)htmlDocument.body);
  }
}



public class HtmlTreeNode {
  public IHTMLDOMNode htmlDomNode;
  public List<htmltreenode> children;

  internal HtmlTreeNode(IHTMLDOMNode htmlElement) {
    this.htmlDomNode = htmlElement;
    children = new List<htmltreenode>();
    IHTMLDOMChildrenCollection collection = (IHTMLDOMChildrenCollection)htmlElement.childNodes;
    int i1, n1 = collection.length;
    for(i1=0;i1<n1;i1++)>
      children.Add(new HtmlTreeNode((IHTMLDOMNode)collection.item(i1)));
  }

  public void GetAbsolutePosition(out int x, out int y, out int width, out int height) {
    if (htmlDomNode is IHTMLElement) {
      x = 0;
      y = 0;
      x = ((IHTMLElement)htmlDomNode).offsetLeft;
      y = ((IHTMLElement)htmlDomNode).offsetTop;

      IHTMLElement offsetParent = ((IHTMLElement)htmlDomNode).offsetParent;
      IHTMLDOMNode parentNode = htmlDomNode.parentNode;

      while (offsetParent != null) {
        x += offsetParent.offsetLeft;
        y += offsetParent.offsetTop;
        parentNode = ((IHTMLDOMNode)offsetParent).parentNode;
        offsetParent = offsetParent.offsetParent;
      }
      width = ((IHTMLElement)htmlDomNode).offsetWidth;
      height = ((IHTMLElement)htmlDomNode).offsetHeight;
    } else
      x = y = width = height = -1;
  }
}</htmltreenode></htmltreenode>


I call LoadContent to load html page and parse it. It works successifully, the object tree is built. But if I try to call GetAbsolutePosition, I will see that offsetHeight, offsetWidth, offsetLeft and offsetTop always return zero. Why is it so and how to solve this problem?

Thank you.
Questionfunction pointers/delegates/callbacks/managed/unmanaged code with c# Pin
kinar17-Nov-08 9:03
kinar17-Nov-08 9:03 
AnswerRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
led mike17-Nov-08 9:36
led mike17-Nov-08 9:36 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
kinar17-Nov-08 10:10
kinar17-Nov-08 10:10 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
led mike17-Nov-08 11:02
led mike17-Nov-08 11:02 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
kinar18-Nov-08 3:20
kinar18-Nov-08 3:20 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
led mike18-Nov-08 5:41
led mike18-Nov-08 5:41 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
kinar18-Nov-08 7:53
kinar18-Nov-08 7:53 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
led mike18-Nov-08 8:22
led mike18-Nov-08 8:22 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
kinar18-Nov-08 9:11
kinar18-Nov-08 9:11 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
led mike18-Nov-08 10:16
led mike18-Nov-08 10:16 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
kinar18-Nov-08 11:43
kinar18-Nov-08 11:43 
GeneralRe: function pointers/delegates/callbacks/managed/unmanaged code with c# Pin
led mike18-Nov-08 11:57
led mike18-Nov-08 11:57 
Questionscreen position of control Pin
Eli Nurman17-Nov-08 8:57
Eli Nurman17-Nov-08 8:57 
AnswerRe: screen position of control Pin
Samer Aburabie17-Nov-08 10:54
Samer Aburabie17-Nov-08 10:54 
QuestionHow to list Com Port usage and list of devices using those ports Pin
serkan197717-Nov-08 8:33
serkan197717-Nov-08 8:33 
AnswerRe: How to list Com Port usage and list of devices using those ports Pin
Samer Aburabie17-Nov-08 11:02
Samer Aburabie17-Nov-08 11:02 
GeneralRe: How to list Com Port usage and list of devices using those ports Pin
Rahul.RK17-Nov-08 20:03
Rahul.RK17-Nov-08 20:03 

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.