Jump to content

Rolf Fankhauser

Members
  • Content Count

    24
  • Joined

  • Last visited

Community Reputation

1 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.3 Rio

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Rolf Fankhauser

    How do I use a range-based for loop to sum all elements

    Thanks Remy for the explanation! I run it several times and got different results for the invalid indexes. Index 7 always returned 14880996, the other results seem to be random : 7 (because myArray[2] = 7) 9 (because myArray[4] = 9) 14880996 16789504 16448156 7 9 14880996 3264512 2095744 7 9 14880996 4907008 7338908
  2. Rolf Fankhauser

    How do I use a range-based for loop to sum all elements

    I wonder why there is no AV or exception in the case of "sum +=myArray[x]" when the index is out of range? Because it's C++?
  3. Rolf Fankhauser

    How to use Open XML SDK in C++Builder

    Ok, I found Bruno Sonnino's Blog. He shows how to create OpenXML files in Delphi without using the SDK but directly generating the XML code (but it looks rather cumbersome...). I think that should also be possible in C++Builder. So, many thanks to Bruno for this tutorial and sharing the code !! But hints how to use the SDK in C++Builder would be still appreciated...
  4. Rolf Fankhauser

    How to use Open XML SDK in C++Builder

    I would like to use Open XML SDK in C++Builder. I found instructions, docs and forums only for VS C++. I tried the Direct Office library for Delphi but it doesn't support C++Builder. Thanks in advance for any hints!
  5. Hi, I generate in my application dynamically svg code using a javascript version of GraphViz (viz.js). The nodes are created as follows: <g class="node" id="node1"><title>B Regen</title> <polygon fill="none" stroke="black" points="63.9539,-396 0.0460627,-396 0.0460627,-360 63.9539,-360 63.9539,-396" /> <text font-family="Times,serif" font-size="14" text-anchor="middle" x="32" y="-373.8">B Regen</text> </g> Because I want to show some data of the objects (nodes) on MouseOver I changed the innerText of <title> (which is shown as hint by default by the browser) by the following C++ code: // helpers for interface reference counting // could alternatively use TComInterface instead of DelphiInterface typedef DelphiInterface<IHTMLDocument3> _di_IHTMLDocument3; typedef DelphiInterface<IHTMLElement> _di_IHTMLElement; typedef DelphiInterface<IHTMLElementCollection> _di_IHTMLElementCollection; typedef DelphiInterface<IHTMLWindow2> _di_IHTMLWindow; // Get Data: _di_IHTMLDocument3 doc = CppWebBrowser1->Document; _di_IHTMLElement elem; _di_IHTMLElementCollection collection; _di_IHTMLWindow window; long len; TVariant value; // only for testing OleCheck(doc->getElementById(WideString("svg"), &elem)); if (elem) { elem->getAttribute(WideString("viewBox"), 2, &value); ShowMessage("viewBox: " + value); } // fill the title tags with data to show on Mouse over: OleCheck(doc->getElementsByTagName(WideString("title"), &collection)); collection->get_length(&len); //ShowMessage("Collection length: " + IntToStr(len)); //ShowMessage(Commands->Text); WideString tmp, tmp2; int line; for (long i = 0; i < len; ++i) { TVariant name = i; TVariant index = 0; DelphiInterface<IDispatch> disp; if(SUCCEEDED(collection->item(name, index, &disp))) { DelphiInterface<IHTMLElement> element; if( SUCCEEDED(disp->QueryInterface(IID_IHTMLElement, (LPVOID*)&element))) { element->get_innerText(&tmp); //reading element name line = FindElementInMemo(Commands, Trim(tmp)); //finding the element in a memo if (line != -1) { tmp2 = ExtractParameters(Commands->Strings[line]); //extracting the data to show //if (tmp != WideString("Output")) { if (tmp2 == WideString("")) tmp2 = WideString("a<br>b"); //test to format the data on two lines OleCheck(element->put_innerHTML(tmp2)); //replace the original text of the element name by the element data } } } } All is working but the text is not shown on multiple lines. ExtractParameters returns one line, so I made a test by creating constant data of 2 lines by "a<br>b". I tried with put_innerText and put_innerHTML but without success. Any idea why this doesn't work? Could I define a separate event handler for onmouseover using doc->execScript ? Thanks, Rolf
  6. Did you try to generate import libraries with mkexp?
  7. In my application I generate a SVG graphic in a TCppWebBrowser by providing GraphViz dot language code that is converted to SVG by a JavaScript version of GraphViz viz.js. File _test.html shows the original HTML page (dot code and JavaScript code) that produces the SVG output shown in file test.html. In the form with the TCppWebBrowser component I added some buttons to zoom in, out and reset to 100%: //--------------------------------------------------------------------------- void __fastcall TFormViewer::btZoomInClick(TObject *Sender) { ZoomFactor *= 1.1; OleVariant ZoomFac = int(ZoomFactor); CppWebBrowser1->ExecWB(63, OLECMDEXECOPT_DONTPROMPTUSER, ZoomFac, 0); } //--------------------------------------------------------------------------- void __fastcall TFormViewer::btZoomOutClick(TObject *Sender) { ZoomFactor *= 0.9; OleVariant ZoomFac = int(ZoomFactor); CppWebBrowser1->ExecWB(63, OLECMDEXECOPT_DONTPROMPTUSER, ZoomFac, 0); } //--------------------------------------------------------------------------- // void __fastcall TFormViewer::btResizeClick(TObject *Sender) { ZoomFactor = 100; OleVariant ZoomFac = int(ZoomFactor); CppWebBrowser1->ExecWB(63, OLECMDEXECOPT_DONTPROMPTUSER, ZoomFac, 0); } This works fine but for huge networks with hundreds of elements I would like to zoom to a specific element by name (in test.html e.g. to "HE M15". My idea is to change the viewBox attribute of the svg object. So, I need to find the element with the specific name (e.g. "HE M15"), read the x, y coordinates of the text and change the viewBox accordingly. Would this be possible by IHTMLWindow2::execScript (JavaScript code) or other tools to access the DOM... or would it be easier to save the html page, load it in a StringList, search the element and coordinates there and change the viewBox attribute, save the file and load it into the TCppWebBrowser component again? __test.html test.html
  8. Rolf Fankhauser

    What about additional free open source C++ libraries on GetIt ?

    @oliwe: I have already encountered VTK when I worked shortly with Paraview using some CFD software and VisIt (3D visualization of MRI slices) and recently when I was looking for a graph drawing library. Many programs and libraries are built on top of VTK. At the moment I use Graphviz in C++Builder for drawing graphs/networks. But I use a Javascript implementation of Graphviz viz.js. There is also a COM library WinGraphviz that could be used.
  9. Rolf Fankhauser

    What about additional free open source C++ libraries on GetIt ?

    Here is an example for install documentation of NLopt It would be nice to have more such documentation for important free open source libraries (with a license allowing commercial use). Installation over GetIt would be perfect but not a must. Installing documentation would be enough.
  10. Rolf Fankhauser

    Timer game delphi 7

    Please find attached unit StopWatch for Delphi 7 (StopWatch.pas) This is from Zarko Gajic, possibly not exactly identical to that from System.Diagnostics.
  11. I tried to install and use OpenCV under C++Builder 10.3.3 (see stack overflow), until now without success. Wouldn't it possible that Embarcadero could make this important library available via GetIt or at least provide a short installation tutorial with working dll's and import libs ? For Delphi there is a project on GitHub (Delphi-OpenCV) but it's an old version and I don't know if it can be used in C++Builder. At the moment there are 15 C++ libraries available on GetIt. Not very much compared to MS VC (ca. 800) . I don't need 800 but it is rather frustrating if I see an interesting library but install/compiling instructions only for GCC or MS VC or just precompiled packages only for MS VC.. Some libraries are easier to install than OpenCV, e.g. NLopt for non-linear optimization that I tested. Would also be a candidate for GetIt. Maybe I belong to a minority of RAD Studio users because I need many mathematical and scientific libraries and these libraries have low priority for Embarcadero. Then let me know...
  12. Rolf Fankhauser

    Problems using embedded python package for Windows

    I installed the PyQt5 package: ...\python> cd Scripts ...\python\Scripts> pip install PyQt5 Now matplotlib is working with GUI because there is now Qt as a GUI backend. The window doesn't look really native, Tk looks nicer.
  13. Rolf Fankhauser

    Problems using embedded python package for Windows

    I now installed the newest version with python 3.9.4. There is a file python39._pth (I checked it: Indeed, the python35 package didn't have a file python35._pth) So, I changed all according to the instructions. I installed numpy and matplotlib but when I try matplotlib from the command prompt and want to plot I get the following warning: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. Only this backend "agg" is installed, no others. If I try to install Tkinter I get the same error as before with the python35 package: ERROR: Could not find a version that satisfies the requirement Tkinter ERROR: No matching distribution found for Tkinter Can I use a Delphi window as backend? Saving the plot as png or svg and display it in Delphi would be a workaround but rather complicated.
  14. Rolf Fankhauser

    Problems using embedded python package for Windows

    Hello SwiftExpat Thanks for the links. I already know the first link. The problem is that I have no such file python35._pth. I will check the other link and possibly download and install the embeddable distribution again.
  15. Rolf Fankhauser

    Poor performance of Python script

    Thanks a lot !! This reference counting is annoying !! Thanks for the link, I will study the article. I supposed that ExtractPythonObjectFrom does increment the reference count. I corrected my code with your above suggestions. You forgot to remove PythonEngine1: var PyInput := PE.PythonEngine1.PyFloat_FromDouble(Input); Performance didn't change
×