Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Manipulation of SVG Dom, new object not visible


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 0
Andre Engelshove

Posts: 1
Registered: 7/10/14
Manipulation of SVG Dom, new object not visible  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 17, 2015 6:58 AM
Hi!

I try to insert a new rect into a svg using the TWebBrowser: (SvgDoc = ISVGDocument)

procedure MakeTextBox(textElement: ISvgTextContentElement);
  var
    doc: IHTMLDocument7;
    newHtmlElement: IHTMLElement;
    parentNode: IHTMLElement;
    parentNodeNode: IHTMLDOMNode;
    oldHtmlNode: IHTMLDOMNode;
    newHtmlNode: IHTMLDOMNode;
    textHtmlElement: IHtmlElement;
  begin
    SvgDoc.QueryInterface(IID_IHTMLDocument7, doc);
    NS := 'http://www.w3.org/2000/svg';
 
    newHtmlElement := doc.createElementNS(NS, 'rect');
 
    setAttributeNS(newHtmlElement, cSVGstroke, ColorToSvgColor(clBlue));
    setAttributeNS(newHtmlElement, cSVGfill, ColorToSvgColor(clBlue));
    setAttributeNS(newHtmlElement, 'x', 10);
    setAttributeNS(newHtmlElement, 'y', 10);
    setAttributeNS(newHtmlElement, 'width', 50);
    setAttributeNS(newHtmlElement, 'height', 50);
 
    newHtmlElement.QueryInterface(IID_IHTMLDOMNode, newHtmlNode);
 
    textElement.QueryInterface(IID_IHTMLElement, textHtmlElement);
 
    parentNode := textHtmlElement.parentElement;
    parentNode.QueryInterface(IID_IHTMLDOMNode, parentNodeNode);
    textElement.QueryInterface(IID_IHTMLDOMNode, oldHtmlNode);
 
// parentNodeNode.removeChild(oldHtmlNode);
// parentNodeNode.appendChild(newHtmlNode);
 
// parentNodeNode.insertBefore(newHtmlNode, oldHtmlNode);
 
    newHtmlNode := parentNodeNode.replaceChild(newHtmlNode, oldHtmlNode);
  end; 


The new object is not visible, except I save and reload the svg. Does anybody know what I do wrong?

Best regards

André Engelshove
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02